Skip to content

[script.timers] 4.1.0 #2704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions script.timers/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.timers" name="Timers" version="4.0.2" provider-name="Heckie">
<addon id="script.timers" name="Timers" version="4.1.0" provider-name="Heckie">
<requires>
<import addon="xbmc.python" version="3.0.0" />
</requires>
Expand Down Expand Up @@ -66,6 +66,9 @@
<website>https://github.com/Heckie75/kodi-addon-timers</website>
<source>https://github.com/Heckie75/kodi-addon-timers</source>
<news>
v4.1.0 (2024-12-19)
* New feature: support for smart playlists (music and video)

v4.0.2 (2024-12-12)
* Bugfix: Fix exception when settings timer in EPG with program that runs over midnight

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

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

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

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

v3.8.0 (2023-08-06)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def is_supported(self, label: str, path: str) -> bool:
elif vfs_utils.is_pvr(path):
return vfs_utils.is_pvr_channel(path) or vfs_utils.is_pvr_recording(path) or xbmc.getCondVisibility("Window.IsVisible(tvguide)|Window.IsVisible(radioguide)")
else:
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)
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)

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

Expand Down
10 changes: 8 additions & 2 deletions script.timers/resources/lib/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,21 @@ def _playAV(self, playlist: PlayList, startpos=0, seektime=None, repeat=player_u
self._seektime = seektime
self._skip_next_stop_event_until_started = True

if playlist.getPlayListId() == TYPES.index(VIDEO):
playListId = playlist.getPlayListId()
if playListId == TYPES.index(VIDEO):
self.stopPlayer(PICTURE)

xbmc.executebuiltin("CECActivateSource")

if self.__is_unit_test__:
self.setRepeat(repeat)

self.play(playlist.directUrl or playlist, startpos=startpos)
if player_utils.is_smart_playlist(playlist.directUrl):
player_utils.play_directory(playlist.directUrl)

else:
self.play(playlist.directUrl or playlist, startpos=startpos)

self.setRepeat(repeat)
self.setShuffled(shuffled)
self.setSpeed(speed)
Expand Down
11 changes: 10 additions & 1 deletion script.timers/resources/lib/player/player_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from resources.lib.utils.jsonrpc_utils import json_rpc
from resources.lib.utils.vfs_utils import (build_playlist, convert_to_playlist,
get_asset_path, get_files_and_type,
get_longest_common_path, is_script)
get_longest_common_path, is_script,
is_smart_playlist)

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

elif is_smart_playlist(timer.path):
play_directory(timer.path)

elif timer.media_type == PICTURE:
if timer.shuffle and timer.is_play_at_start_timer() and timer.is_stop_at_end_timer():
amount = 1 + timer.duration_timedelta.total_seconds() // get_slideshow_staytime()
Expand All @@ -68,6 +72,11 @@ def preview(addon: xbmcaddon.Addon, timerid: int, player: 'xbmc.Player') -> None
32027), addon.getLocalizedString(32109))


def play_directory(url: str) -> None:

xbmc.executebuiltin('PlayMedia("%s","isdir")' % url)


def play_slideshow(path: str, beginSlide: str = None, shuffle=False, amount=0) -> None:

if shuffle and amount:
Expand Down
23 changes: 16 additions & 7 deletions script.timers/resources/lib/utils/vfs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ def is_folder(path: str) -> bool:
return len(dirs) > 0 or len(files) > 0


def is_smart_playlist(path: str) -> bool:

if not path:
return False

ext = get_file_extension(path)
return path.startswith("special://profile/playlists/") and ext and ext == ".xsp"


def is_playlist(path: str) -> bool:

ext = get_file_extension(path)
Expand Down Expand Up @@ -181,7 +190,7 @@ def build_path_to_ressource(path: str, file: str) -> str:

def has_items_in_path(path: str) -> bool:

return len(scan_item_paths(path, limit=1)) > 0
return not is_smart_playlist(path) and len(scan_item_paths(path, limit=1)) > 0


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

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

_type_id = TYPES.index(type or VIDEO)
playlist = PlayList(_type_id)
type_id = TYPES.index(type or VIDEO)
playlist = PlayList(type_id)
playlist.clear()

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])):
playlist.directUrl = paths[0]
return playlist

for path in paths:
label = label if label and len(paths) == 1 else get_file_name(path)
li = xbmcgui.ListItem(label=label, path=path)
playlist.add(url=path, listitem=li)
if is_pvr(path) or is_audio_plugin(path) or is_video_plugin(path):
playlist.clear()
playlist.directUrl = path
break

return playlist

Expand Down
Loading