From c4fe9d05fc2e84c1c414cd136d0f19b6e714099e Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Sun, 8 Dec 2024 15:42:13 +1100 Subject: [PATCH] Improve playlist playback handling via context menu - Avoids unnecessary routing and loss of window history --- .../lib/youtube_plugin/kodion/abstract_provider.py | 1 + .../lib/youtube_plugin/kodion/items/menu_items.py | 4 ++-- .../youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py | 12 ++++-------- .../lib/youtube_plugin/youtube/helper/yt_play.py | 7 +++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/resources/lib/youtube_plugin/kodion/abstract_provider.py b/resources/lib/youtube_plugin/kodion/abstract_provider.py index 6e44220ae..696764bf7 100644 --- a/resources/lib/youtube_plugin/kodion/abstract_provider.py +++ b/resources/lib/youtube_plugin/kodion/abstract_provider.py @@ -37,6 +37,7 @@ class AbstractProvider(object): RESULT_CACHE_TO_DISC = 'cache_to_disc' # (bool) RESULT_FALLBACK = 'fallback' # (bool) + RESULT_FORCE_PLAY = 'force_play' # (bool) RESULT_FORCE_RESOLVE = 'force_resolve' # (bool) RESULT_UPDATE_LISTING = 'update_listing' # (bool) diff --git a/resources/lib/youtube_plugin/kodion/items/menu_items.py b/resources/lib/youtube_plugin/kodion/items/menu_items.py index ce7b79c76..1762d9cb6 100644 --- a/resources/lib/youtube_plugin/kodion/items/menu_items.py +++ b/resources/lib/youtube_plugin/kodion/items/menu_items.py @@ -177,11 +177,11 @@ def shuffle_playlist(context, playlist_id): return ( context.localize('playlist.play.shuffle'), context.create_uri( - (PATHS.ROUTE, PATHS.PLAY,), + (PATHS.PLAY,), { 'playlist_id': playlist_id, 'order': 'shuffle', - 'action': 'list', + 'action': 'play', }, run=True, ), diff --git a/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py b/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py index 4598d77d0..721a62388 100644 --- a/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py +++ b/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py @@ -236,17 +236,13 @@ def run(self, provider, context, focused=None): show_fanart=show_fanart, ) uri = result.get_uri() - result = xbmcplugin.addDirectoryItem(handle, - url=uri, - listitem=item) - if route: + if options.get(provider.RESULT_FORCE_PLAY): playlist_player = context.get_playlist_player() playlist_player.play_item(item=uri, listitem=item) else: - xbmcplugin.setResolvedUrl(handle, - succeeded=result, - listitem=item) - + xbmcplugin.setResolvedUrl( + handle, succeeded=True, listitem=item + ) else: result, post_run_action = self.uri_action(context, uri) diff --git a/resources/lib/youtube_plugin/youtube/helper/yt_play.py b/resources/lib/youtube_plugin/youtube/helper/yt_play.py index a83ac8653..fecf8a973 100644 --- a/resources/lib/youtube_plugin/youtube/helper/yt_play.py +++ b/resources/lib/youtube_plugin/youtube/helper/yt_play.py @@ -223,9 +223,9 @@ def _play_playlist(provider, context): return ( process_items_for_playlist(context, video_items, action, video_id), { - provider.RESULT_CACHE_TO_DISC: False, - provider.RESULT_FORCE_RESOLVE: True, - provider.RESULT_UPDATE_LISTING: True, + provider.RESULT_CACHE_TO_DISC: action == 'list', + provider.RESULT_FORCE_RESOLVE: action != 'list', + provider.RESULT_UPDATE_LISTING: action != 'list', }, ) @@ -426,5 +426,4 @@ def process_items_for_playlist(context, items, action=None, play_from=None): return items if action == 'play': playlist_player.play_playlist_item(playlist_position + 1) - return False return items[playlist_position]