Skip to content

Commit a9c5b90

Browse files
authored
Merge pull request #2704 from Heckie75/script.timers.4.1.0
[script.timers] 4.1.0
2 parents 2c68a67 + ef5e1b6 commit a9c5b90

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

script.timers/addon.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.timers" name="Timers" version="4.0.2" provider-name="Heckie">
2+
<addon id="script.timers" name="Timers" version="4.1.0" provider-name="Heckie">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0" />
55
</requires>
@@ -66,6 +66,9 @@
6666
<website>https://github.com/Heckie75/kodi-addon-timers</website>
6767
<source>https://github.com/Heckie75/kodi-addon-timers</source>
6868
<news>
69+
v4.1.0 (2024-12-19)
70+
* New feature: support for smart playlists (music and video)
71+
6972
v4.0.2 (2024-12-12)
7073
* Bugfix: Fix exception when settings timer in EPG with program that runs over midnight
7174

@@ -74,9 +77,9 @@ v4.0.1 (2024-12-08)
7477
- Bugfix: Prevent exception when turning off timers by deselecting all days of week
7578

7679
v4.0.0 (2024-08-31)
77-
- New Feature: programming timers with full date (not only day within upcoming 7 days, feature request #34)
80+
- New feature: programming timers with full date (not only day within upcoming 7 days, feature request #34)
7881
- Improved stop behavior of overlapping media timers acc. its priority
79-
- Bugfix / Workaround: [Kodi v21] Settings dialog is broken, issue #43
82+
- Bugfix / workaround: [Kodi v21] Settings dialog is broken, issue #43
8083
- Bugfix: [Kodi v21] Addon can't play PVR items anymore, issue #42
8184

8285
v3.9.3 (2024-08-02)
@@ -89,8 +92,8 @@ v3.9.1 (2024-06-30)
8992
- Bugfix: Prevent exception after changing already running non-fading-timer to fading-timer
9093

9194
v3.9.0 (2023-11-11)
92-
- Add new system action 'restart Kodi'
93-
- Add new extra feature to prevent display off when audio is playing
95+
- Added new system action 'restart Kodi'
96+
- Added new extra feature to prevent display off when audio is playing
9497
- Bugfix: Prevent exception in fader context
9598

9699
v3.8.0 (2023-08-06)

script.timers/resources/lib/contextmenu/abstract_set_timer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def is_supported(self, label: str, path: str) -> bool:
140140
elif vfs_utils.is_pvr(path):
141141
return vfs_utils.is_pvr_channel(path) or vfs_utils.is_pvr_recording(path) or xbmc.getCondVisibility("Window.IsVisible(tvguide)|Window.IsVisible(radioguide)")
142142
else:
143-
return vfs_utils.is_script(path) or vfs_utils.is_audio_plugin(path) or vfs_utils.is_video_plugin(path) or vfs_utils.is_external(path) or not vfs_utils.is_folder(path) or vfs_utils.has_items_in_path(path)
143+
return vfs_utils.is_smart_playlist(path) or vfs_utils.is_script(path) or vfs_utils.is_audio_plugin(path) or vfs_utils.is_video_plugin(path) or vfs_utils.is_external(path) or not vfs_utils.is_folder(path) or vfs_utils.has_items_in_path(path)
144144

145145
def perform_ahead(self, timer: Timer) -> bool:
146146

script.timers/resources/lib/player/player.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,21 @@ def _playAV(self, playlist: PlayList, startpos=0, seektime=None, repeat=player_u
121121
self._seektime = seektime
122122
self._skip_next_stop_event_until_started = True
123123

124-
if playlist.getPlayListId() == TYPES.index(VIDEO):
124+
playListId = playlist.getPlayListId()
125+
if playListId == TYPES.index(VIDEO):
125126
self.stopPlayer(PICTURE)
126127

127128
xbmc.executebuiltin("CECActivateSource")
128129

129130
if self.__is_unit_test__:
130131
self.setRepeat(repeat)
131132

132-
self.play(playlist.directUrl or playlist, startpos=startpos)
133+
if player_utils.is_smart_playlist(playlist.directUrl):
134+
player_utils.play_directory(playlist.directUrl)
135+
136+
else:
137+
self.play(playlist.directUrl or playlist, startpos=startpos)
138+
133139
self.setRepeat(repeat)
134140
self.setShuffled(shuffled)
135141
self.setSpeed(speed)

script.timers/resources/lib/player/player_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from resources.lib.utils.jsonrpc_utils import json_rpc
88
from resources.lib.utils.vfs_utils import (build_playlist, convert_to_playlist,
99
get_asset_path, get_files_and_type,
10-
get_longest_common_path, is_script)
10+
get_longest_common_path, is_script,
11+
is_smart_playlist)
1112

1213
REPEAT_OFF = "off"
1314
REPEAT_ONE = "one"
@@ -51,6 +52,9 @@ def preview(addon: xbmcaddon.Addon, timerid: int, player: 'xbmc.Player') -> None
5152
if is_script(timer.path):
5253
run_addon(timer.path)
5354

55+
elif is_smart_playlist(timer.path):
56+
play_directory(timer.path)
57+
5458
elif timer.media_type == PICTURE:
5559
if timer.shuffle and timer.is_play_at_start_timer() and timer.is_stop_at_end_timer():
5660
amount = 1 + timer.duration_timedelta.total_seconds() // get_slideshow_staytime()
@@ -68,6 +72,11 @@ def preview(addon: xbmcaddon.Addon, timerid: int, player: 'xbmc.Player') -> None
6872
32027), addon.getLocalizedString(32109))
6973

7074

75+
def play_directory(url: str) -> None:
76+
77+
xbmc.executebuiltin('PlayMedia("%s","isdir")' % url)
78+
79+
7180
def play_slideshow(path: str, beginSlide: str = None, shuffle=False, amount=0) -> None:
7281

7382
if shuffle and amount:

script.timers/resources/lib/utils/vfs_utils.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def is_folder(path: str) -> bool:
3232
return len(dirs) > 0 or len(files) > 0
3333

3434

35+
def is_smart_playlist(path: str) -> bool:
36+
37+
if not path:
38+
return False
39+
40+
ext = get_file_extension(path)
41+
return path.startswith("special://profile/playlists/") and ext and ext == ".xsp"
42+
43+
3544
def is_playlist(path: str) -> bool:
3645

3746
ext = get_file_extension(path)
@@ -181,7 +190,7 @@ def build_path_to_ressource(path: str, file: str) -> str:
181190

182191
def has_items_in_path(path: str) -> bool:
183192

184-
return len(scan_item_paths(path, limit=1)) > 0
193+
return not is_smart_playlist(path) and len(scan_item_paths(path, limit=1)) > 0
185194

186195

187196
def build_playlist(path: str, label: str) -> 'PlayList':
@@ -197,18 +206,18 @@ def build_playlist(path: str, label: str) -> 'PlayList':
197206

198207
def convert_to_playlist(paths: 'list[str]', type=VIDEO, label="") -> 'PlayList':
199208

200-
_type_id = TYPES.index(type or VIDEO)
201-
playlist = PlayList(_type_id)
209+
type_id = TYPES.index(type or VIDEO)
210+
playlist = PlayList(type_id)
202211
playlist.clear()
203212

213+
if paths and (is_pvr(paths[0]) or is_audio_plugin(paths[0]) or is_video_plugin(paths[0]) or is_smart_playlist(paths[0])):
214+
playlist.directUrl = paths[0]
215+
return playlist
216+
204217
for path in paths:
205218
label = label if label and len(paths) == 1 else get_file_name(path)
206219
li = xbmcgui.ListItem(label=label, path=path)
207220
playlist.add(url=path, listitem=li)
208-
if is_pvr(path) or is_audio_plugin(path) or is_video_plugin(path):
209-
playlist.clear()
210-
playlist.directUrl = path
211-
break
212221

213222
return playlist
214223

0 commit comments

Comments
 (0)