From 14603bdc4e95b1f1b51886ecac39b5633ac0b7e7 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:11:00 +1100 Subject: [PATCH] Misc tidy ups --- .../kodion/abstract_provider.py | 16 ++-- .../kodion/items/favorites_item.py | 2 +- .../youtube_plugin/kodion/items/menu_items.py | 86 +++++++++---------- .../kodion/items/new_search_item.py | 4 +- .../kodion/items/search_history_item.py | 4 +- .../kodion/items/search_item.py | 4 +- .../kodion/items/watch_later_item.py | 2 +- .../kodion/plugin/xbmc/xbmc_runner.py | 4 +- .../kodion/ui/xbmc/xbmc_items.py | 4 +- .../youtube/client/login_client.py | 12 +-- .../youtube/client/request_client.py | 7 +- .../youtube_plugin/youtube/helper/__init__.py | 1 - .../youtube/helper/resource_manager.py | 2 +- .../lib/youtube_plugin/youtube/helper/tv.py | 8 +- .../youtube/helper/url_to_item_converter.py | 37 +++++--- .../youtube_plugin/youtube/helper/utils.py | 5 +- .../youtube/helper/yt_specials.py | 13 +-- .../lib/youtube_plugin/youtube/provider.py | 35 ++++---- 18 files changed, 124 insertions(+), 122 deletions(-) diff --git a/resources/lib/youtube_plugin/kodion/abstract_provider.py b/resources/lib/youtube_plugin/kodion/abstract_provider.py index b7fbe6537..c7f85f70b 100644 --- a/resources/lib/youtube_plugin/kodion/abstract_provider.py +++ b/resources/lib/youtube_plugin/kodion/abstract_provider.py @@ -37,29 +37,29 @@ def __init__(self): # register some default paths self.register_path(r'^/$', '_internal_root') - self.register_path(r''.join([ + self.register_path(r''.join(( '^/', paths.WATCH_LATER, '/(?Padd|clear|list|remove)/?$' - ]), '_internal_watch_later') + )), '_internal_watch_later') - self.register_path(r''.join([ + self.register_path(r''.join(( '^/', paths.FAVORITES, '/(?Padd|clear|list|remove)/?$' - ]), '_internal_favorite') + )), '_internal_favorite') - self.register_path(r''.join([ + self.register_path(r''.join(( '^/', paths.SEARCH, '/(?Pinput|query|list|remove|clear|rename)/?$' - ]), '_internal_search') + )), '_internal_search') - self.register_path(r''.join([ + self.register_path(r''.join(( '^/', paths.HISTORY, '/$' - ]), 'on_playback_history') + )), 'on_playback_history') self.register_path(r'(?P.*\/)extrafanart\/([\?#].+)?$', '_internal_on_extra_fanart') diff --git a/resources/lib/youtube_plugin/kodion/items/favorites_item.py b/resources/lib/youtube_plugin/kodion/items/favorites_item.py index 580c343ca..242d9eef6 100644 --- a/resources/lib/youtube_plugin/kodion/items/favorites_item.py +++ b/resources/lib/youtube_plugin/kodion/items/favorites_item.py @@ -24,7 +24,7 @@ def __init__(self, context, name=None, image=None, fanart=None): super(FavoritesItem, self).__init__(name, context.create_uri( - [paths.FAVORITES, 'list'] + (paths.FAVORITES, 'list',), ), image=image) diff --git a/resources/lib/youtube_plugin/kodion/items/menu_items.py b/resources/lib/youtube_plugin/kodion/items/menu_items.py index 04a34d729..fd707a9b3 100644 --- a/resources/lib/youtube_plugin/kodion/items/menu_items.py +++ b/resources/lib/youtube_plugin/kodion/items/menu_items.py @@ -22,7 +22,7 @@ def more_for_video(context, video_id, logged_in=False, refresh_container=False): 'video_id': video_id, 'logged_in': logged_in, 'refresh_container': refresh_container, - } + }, )) ) @@ -34,7 +34,7 @@ def related_videos(context, video_id): ('special', 'related_videos',), { 'video_id': video_id, - } + }, )) ) @@ -46,7 +46,7 @@ def video_comments(context, video_id): ('special', 'parent_comments',), { 'video_id': video_id, - } + }, )) ) @@ -58,7 +58,7 @@ def content_from_description(context, video_id): ('special', 'description_links',), { 'video_id': video_id, - } + }, )) ) @@ -97,7 +97,7 @@ def play_all_from_playlist(context, playlist_id, video_id=''): 'playlist_id': playlist_id, 'video_id': video_id, 'play': True, - } + }, )) ) return ( @@ -107,7 +107,7 @@ def play_all_from_playlist(context, playlist_id, video_id=''): { 'playlist_id': playlist_id, 'play': True, - } + }, )) ) @@ -119,7 +119,7 @@ def add_video_to_playlist(context, video_id): ('playlist', 'select', 'playlist',), { 'video_id': video_id, - } + }, )) ) @@ -133,7 +133,7 @@ def remove_video_from_playlist(context, playlist_id, video_id, video_name): 'playlist_id': playlist_id, 'video_id': video_id, 'video_name': video_name, - } + }, )) ) @@ -146,7 +146,7 @@ def rename_playlist(context, playlist_id, playlist_name): { 'playlist_id': playlist_id, 'playlist_name': playlist_name - } + }, )) ) @@ -159,7 +159,7 @@ def delete_playlist(context, playlist_id, playlist_name): { 'playlist_id': playlist_id, 'playlist_name': playlist_name - } + }, )) ) @@ -172,7 +172,7 @@ def remove_as_watch_later(context, playlist_id, playlist_name): { 'playlist_id': playlist_id, 'playlist_name': playlist_name - } + }, )) ) @@ -185,7 +185,7 @@ def set_as_watch_later(context, playlist_id, playlist_name): { 'playlist_id': playlist_id, 'playlist_name': playlist_name - } + }, )) ) @@ -198,7 +198,7 @@ def remove_as_history(context, playlist_id, playlist_name): { 'playlist_id': playlist_id, 'playlist_name': playlist_name - } + }, )) ) @@ -211,7 +211,7 @@ def set_as_history(context, playlist_id, playlist_name): { 'playlist_id': playlist_id, 'playlist_name': playlist_name - } + }, )) ) @@ -224,7 +224,7 @@ def remove_my_subscriptions_filter(context, channel_name): { 'channel_name': channel_name, 'action': 'remove' - } + }, )) ) @@ -237,7 +237,7 @@ def add_my_subscriptions_filter(context, channel_name): { 'channel_name': channel_name, 'action': 'add', - } + }, )) ) @@ -250,7 +250,7 @@ def rate_video(context, video_id, refresh_container=False): { 'video_id': video_id, 'refresh_container': refresh_container, - } + }, )) ) @@ -263,7 +263,7 @@ def watch_later_add(context, playlist_id, video_id): { 'playlist_id': playlist_id, 'video_id': video_id, - } + }, )) ) @@ -276,7 +276,7 @@ def watch_later_local_add(context, item): { 'video_id': item.video_id, 'item': item.dumps(), - } + }, )) ) @@ -288,7 +288,7 @@ def watch_later_local_remove(context, video_id): (paths.WATCH_LATER, 'remove',), { 'video_id': video_id, - } + }, )) ) @@ -297,7 +297,7 @@ def watch_later_local_clear(context): return ( context.localize('watch_later.clear'), 'RunPlugin({0})'.format(context.create_uri( - (paths.WATCH_LATER, 'clear',) + (paths.WATCH_LATER, 'clear',), )) ) @@ -306,7 +306,7 @@ def go_to_channel(context, channel_id, channel_name): return ( context.localize('go_to_channel') % context.get_ui().bold(channel_name), 'ActivateWindow(Videos, {0}, return)'.format(context.create_uri( - ('channel', channel_id,) + ('channel', channel_id,), )) ) @@ -319,7 +319,7 @@ def subscribe_to_channel(context, channel_id, channel_name=''): ('subscriptions', 'add',), { 'subscription_id': channel_id, - } + }, )) ) return ( @@ -328,7 +328,7 @@ def subscribe_to_channel(context, channel_id, channel_name=''): ('subscriptions', 'add',), { 'subscription_id': channel_id, - } + }, )) ) @@ -340,7 +340,7 @@ def unsubscribe_from_channel(context, channel_id): ('subscriptions', 'remove',), { 'subscription_id': channel_id, - } + }, )) ) @@ -353,7 +353,7 @@ def play_with_subtitles(context, video_id): { 'video_id': video_id, 'prompt_for_subtitles': True, - } + }, )) ) @@ -366,7 +366,7 @@ def play_audio_only(context, video_id): { 'video_id': video_id, 'audio_only': True, - } + }, )) ) @@ -379,7 +379,7 @@ def play_ask_for_quality(context, video_id): { 'video_id': video_id, 'ask_for_quality': True, - } + }, )) ) @@ -388,11 +388,11 @@ def history_remove(context, video_id): return ( context.localize('history.remove'), 'RunPlugin({0})'.format(context.create_uri( - [paths.HISTORY], + (paths.HISTORY,), { 'action': 'remove', 'video_id': video_id - } + }, )) ) @@ -401,10 +401,10 @@ def history_clear(context): return ( context.localize('history.clear'), 'RunPlugin({0})'.format(context.create_uri( - [paths.HISTORY], + (paths.HISTORY,), { 'action': 'clear' - } + }, )) ) @@ -413,11 +413,11 @@ def history_mark_watched(context, video_id): return ( context.localize('history.mark.watched'), 'RunPlugin({0})'.format(context.create_uri( - [paths.HISTORY], + (paths.HISTORY,), { 'video_id': video_id, 'action': 'mark_watched', - } + }, )) ) @@ -426,11 +426,11 @@ def history_mark_unwatched(context, video_id): return ( context.localize('history.mark.unwatched'), 'RunPlugin({0})'.format(context.create_uri( - [paths.HISTORY], + (paths.HISTORY,), { 'video_id': video_id, 'action': 'mark_unwatched', - } + }, )) ) @@ -439,11 +439,11 @@ def history_reset_resume(context, video_id): return ( context.localize('history.reset.resume_point'), 'RunPlugin({0})'.format(context.create_uri( - [paths.HISTORY], + (paths.HISTORY,), { 'video_id': video_id, 'action': 'reset_resume', - } + }, )) ) @@ -456,7 +456,7 @@ def favorites_add(context, item): { 'video_id': item.video_id, 'item': item.dumps(), - } + }, )) ) @@ -468,7 +468,7 @@ def favorites_remove(context, video_id): (paths.FAVORITES, 'remove',), { 'vide_id': video_id, - } + }, )) ) @@ -480,7 +480,7 @@ def search_remove(context, query): (paths.SEARCH, 'remove',), { 'q': query, - } + }, )) ) @@ -492,7 +492,7 @@ def search_rename(context, query): (paths.SEARCH, 'rename',), { 'q': query, - } + }, )) ) @@ -501,6 +501,6 @@ def search_clear(context): return ( context.localize('search.clear'), 'RunPlugin({0})'.format(context.create_uri( - (paths.SEARCH, 'clear',) + (paths.SEARCH, 'clear',), )) ) diff --git a/resources/lib/youtube_plugin/kodion/items/new_search_item.py b/resources/lib/youtube_plugin/kodion/items/new_search_item.py index 73a052e98..397e72ec0 100644 --- a/resources/lib/youtube_plugin/kodion/items/new_search_item.py +++ b/resources/lib/youtube_plugin/kodion/items/new_search_item.py @@ -42,8 +42,8 @@ def __init__(self, super(NewSearchItem, self).__init__(name, context.create_uri( - [paths.SEARCH, 'input'], - params=params + (paths.SEARCH, 'input',), + params=params, ), image=image) if fanart: diff --git a/resources/lib/youtube_plugin/kodion/items/search_history_item.py b/resources/lib/youtube_plugin/kodion/items/search_history_item.py index afd349683..93f2e3ba9 100644 --- a/resources/lib/youtube_plugin/kodion/items/search_history_item.py +++ b/resources/lib/youtube_plugin/kodion/items/search_history_item.py @@ -26,8 +26,8 @@ def __init__(self, context, query, image=None, fanart=None, location=False): super(SearchHistoryItem, self).__init__(query, context.create_uri( - [paths.SEARCH, 'query'], - params=params + (paths.SEARCH, 'query',), + params=params, ), image=image) diff --git a/resources/lib/youtube_plugin/kodion/items/search_item.py b/resources/lib/youtube_plugin/kodion/items/search_item.py index e505b67be..4b909c54c 100644 --- a/resources/lib/youtube_plugin/kodion/items/search_item.py +++ b/resources/lib/youtube_plugin/kodion/items/search_item.py @@ -33,8 +33,8 @@ def __init__(self, super(SearchItem, self).__init__(name, context.create_uri( - [paths.SEARCH, 'list'], - params=params + (paths.SEARCH, 'list',), + params=params, ), image=image) diff --git a/resources/lib/youtube_plugin/kodion/items/watch_later_item.py b/resources/lib/youtube_plugin/kodion/items/watch_later_item.py index 6ae79116e..de8b12419 100644 --- a/resources/lib/youtube_plugin/kodion/items/watch_later_item.py +++ b/resources/lib/youtube_plugin/kodion/items/watch_later_item.py @@ -24,7 +24,7 @@ def __init__(self, context, name=None, image=None, fanart=None): super(WatchLaterItem, self).__init__(name, context.create_uri( - [paths.WATCH_LATER, 'list'] + (paths.WATCH_LATER, 'list',), ), image=image) diff --git a/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_runner.py b/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_runner.py index b94d781a7..c06ae42d4 100644 --- a/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_runner.py +++ b/resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_runner.py @@ -47,9 +47,9 @@ def run(self, provider, context): items = ui.get_property('playlist') if items: ui.clear_property('playlist') - context.log_error('Multiple busy dialogs active - playlist' - ' reloading to prevent Kodi crashing') playlist.add_items(items, loads=True) + context.log_error('Multiple busy dialogs active - ' + 'playlist reloaded to prevent Kodi crash') return False if settings.is_setup_wizard_enabled(): diff --git a/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_items.py b/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_items.py index 3cf8fdb7a..50de065b0 100644 --- a/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_items.py +++ b/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_items.py @@ -111,9 +111,9 @@ def video_playback_item(context, video_item, show_fanart=None): if show_fanart is None: show_fanart = settings.show_fanart() - image = video_item.get_image() or 'DefaultVideo.png' + image = video_item.get_image() list_item.setArt({ - 'icon': image, + 'icon': image or 'DefaultVideo.png', 'fanart': show_fanart and video_item.get_fanart() or '', 'thumb': image, }) diff --git a/resources/lib/youtube_plugin/youtube/client/login_client.py b/resources/lib/youtube_plugin/youtube/client/login_client.py index bdf07ede6..4937adefb 100644 --- a/resources/lib/youtube_plugin/youtube/client/login_client.py +++ b/resources/lib/youtube_plugin/youtube/client/login_client.py @@ -154,12 +154,12 @@ def refresh_token(self, refresh_token, client_id='', client_secret=''): 'grant_type': 'refresh_token'} config_type = self._get_config_type(client_id, client_secret) - client = ''.join([ + client = ''.join(( '(config_type: |', config_type, '| client_id: |', client_id[:3], '...', client_id[-5:], '| client_secret: |', client_secret[:3], '...', client_secret[-3:], '|)' - ]) + )) log_debug('Refresh token for {0}'.format(client)) json_data = self.request(self.TOKEN_URL, @@ -203,12 +203,12 @@ def request_access_token(self, code, client_id='', client_secret=''): 'grant_type': 'http://oauth.net/grant_type/device/1.0'} config_type = self._get_config_type(client_id, client_secret) - client = ''.join([ + client = ''.join(( '(config_type: |', config_type, '| client_id: |', client_id[:3], '...', client_id[-5:], '| client_secret: |', client_secret[:3], '...', client_secret[-3:], '|)' - ]) + )) log_debug('Requesting access token for {0}'.format(client)) json_data = self.request(self.TOKEN_URL, @@ -241,10 +241,10 @@ def request_device_and_user_code(self, client_id=''): 'scope': 'https://www.googleapis.com/auth/youtube'} config_type = self._get_config_type(client_id) - client = ''.join([ + client = ''.join(( '(config_type: |', config_type, '|', ' client_id: |', client_id[:5], '...|)', - ]) + )) log_debug('Requesting device and user code for {0}'.format(client)) json_data = self.request(self.DEVICE_CODE_URL, diff --git a/resources/lib/youtube_plugin/youtube/client/request_client.py b/resources/lib/youtube_plugin/youtube/client/request_client.py index 3d330787f..13c2d5f53 100644 --- a/resources/lib/youtube_plugin/youtube/client/request_client.py +++ b/resources/lib/youtube_plugin/youtube/client/request_client.py @@ -258,13 +258,12 @@ class YouTubeRequestClient(BaseRequestsClass): }, } - def __init__(self, language='en_US', region='US', exc_type=None, **_kwargs): + def __init__(self, language=None, region=None, exc_type=None, **_kwargs): common_client = self.CLIENTS['_common']['json']['context']['client'] # the default language is always en_US (like YouTube on the WEB) - if language: - language = language.replace('-', '_') + language = language.replace('-', '_') if language else 'en_US' self._language = common_client['hl'] = language - self._region = common_client['gl'] = region + self._region = common_client['gl'] = region if region else 'US' if isinstance(exc_type, tuple): exc_type = (YouTubeException,) + exc_type diff --git a/resources/lib/youtube_plugin/youtube/helper/__init__.py b/resources/lib/youtube_plugin/youtube/helper/__init__.py index 12b93382c..3fff8d215 100644 --- a/resources/lib/youtube_plugin/youtube/helper/__init__.py +++ b/resources/lib/youtube_plugin/youtube/helper/__init__.py @@ -13,4 +13,3 @@ from .resource_manager import ResourceManager from .url_resolver import UrlResolver from .url_to_item_converter import UrlToItemConverter -from .utils import extract_urls diff --git a/resources/lib/youtube_plugin/youtube/helper/resource_manager.py b/resources/lib/youtube_plugin/youtube/helper/resource_manager.py index 7c124349f..05ac7f873 100644 --- a/resources/lib/youtube_plugin/youtube/helper/resource_manager.py +++ b/resources/lib/youtube_plugin/youtube/helper/resource_manager.py @@ -243,7 +243,7 @@ def get_playlist_items(self, ids=None, batch_id=None, defer_cache=False): return result def get_related_playlists(self, channel_id, defer_cache=False): - result = self.get_channels([channel_id], defer_cache=defer_cache) + result = self.get_channels((channel_id,), defer_cache=defer_cache) # transform item = None diff --git a/resources/lib/youtube_plugin/youtube/helper/tv.py b/resources/lib/youtube_plugin/youtube/helper/tv.py index 6c532038c..d87151f89 100644 --- a/resources/lib/youtube_plugin/youtube/helper/tv.py +++ b/resources/lib/youtube_plugin/youtube/helper/tv.py @@ -41,7 +41,7 @@ def my_subscriptions_to_items(provider, context, json_data, do_filter=False): or (not black_list and channel in filter_list)): video_id = item['id'] item_params['video_id'] = video_id - item_uri = context.create_uri(['play'], item_params) + item_uri = context.create_uri(('play',), item_params) video_item = VideoItem(item['title'], uri=item_uri) if incognito: video_item.set_play_count(0) @@ -89,7 +89,7 @@ def tv_videos_to_items(provider, context, json_data): for item in items: video_id = item['id'] item_params['video_id'] = video_id - item_uri = context.create_uri(['play'], item_params) + item_uri = context.create_uri(('play',), item_params) video_item = VideoItem(item['title'], uri=item_uri) if incognito: video_item.set_play_count(0) @@ -144,12 +144,12 @@ def saved_playlists_to_items(provider, context, json_data): if channel_id: item_uri = context.create_uri( - ['channel', channel_id, 'playlist', playlist_id], + ('channel', channel_id, 'playlist', playlist_id,), item_params, ) else: item_uri = context.create_uri( - ['playlist', playlist_id], + ('playlist', playlist_id), item_params, ) diff --git a/resources/lib/youtube_plugin/youtube/helper/url_to_item_converter.py b/resources/lib/youtube_plugin/youtube/helper/url_to_item_converter.py index 0bde8abe2..3c4e800d3 100644 --- a/resources/lib/youtube_plugin/youtube/helper/url_to_item_converter.py +++ b/resources/lib/youtube_plugin/youtube/helper/url_to_item_converter.py @@ -85,7 +85,7 @@ def add_url(self, url, context): video_id = new_params['video_id'] video_item = VideoItem( - '', context.create_uri(['play'], new_params) + '', context.create_uri(('play',), new_params) ) self._video_id_dict[video_id] = video_item @@ -97,7 +97,7 @@ def add_url(self, url, context): return playlist_item = DirectoryItem( - '', context.create_uri(['playlist', playlist_id], new_params), + '', context.create_uri(('playlist', playlist_id,), new_params), ) self._playlist_id_dict[playlist_id] = playlist_item @@ -110,9 +110,9 @@ def add_url(self, url, context): return channel_item = VideoItem( - '', context.create_uri(['play'], new_params) + '', context.create_uri(('play',), new_params) ) if live else DirectoryItem( - '', context.create_uri(['channel', channel_id], new_params) + '', context.create_uri(('channel', channel_id,), new_params) ) self._channel_id_dict[channel_id] = channel_item @@ -132,9 +132,12 @@ def get_items(self, provider, context, skip_title=False): channels_item = DirectoryItem( context.get_ui().bold(context.localize('channels')), - context.create_uri(['special', 'description_links'], { - 'channel_ids': ','.join(self._channel_ids), - }), + context.create_uri( + ('special', 'description_links',), + { + 'channel_ids': ','.join(self._channel_ids), + }, + ), image='{media}/playlist.png' ) result.append(channels_item) @@ -144,16 +147,22 @@ def get_items(self, provider, context, skip_title=False): self._playlist_ids = list(set(self._playlist_ids)) playlists_item = UriItem( - context.create_uri(['play'], { - 'playlist_ids': ','.join(self._playlist_ids), - 'play': True, - }), + context.create_uri( + ('play',), + { + 'playlist_ids': ','.join(self._playlist_ids), + 'play': True, + }, + ), playable=True ) if context.get_param('uri') else DirectoryItem( context.get_ui().bold(context.localize('playlists')), - context.create_uri(['special', 'description_links'], { - 'playlist_ids': ','.join(self._playlist_ids), - }), + context.create_uri( + ('special', 'description_links',), + { + 'playlist_ids': ','.join(self._playlist_ids), + }, + ), image='{media}/playlist.png' ) result.append(playlists_item) diff --git a/resources/lib/youtube_plugin/youtube/helper/utils.py b/resources/lib/youtube_plugin/youtube/helper/utils.py index d2f06749c..c956915c6 100644 --- a/resources/lib/youtube_plugin/youtube/helper/utils.py +++ b/resources/lib/youtube_plugin/youtube/helper/utils.py @@ -607,8 +607,8 @@ def update_video_infos(provider, context, video_id_dict, ) ) - # provide 'remove' for videos in my playlists - # we support all playlist except 'Watch History' + # provide 'remove' for videos in my playlists + # we support all playlist except 'Watch History' if (logged_in and video_id in playlist_item_id_dict and playlist_id and playlist_channel_id == 'mine' and playlist_id.strip().lower() not in ('hl', 'wl')): @@ -621,7 +621,6 @@ def update_video_infos(provider, context, video_id_dict, ) ) - # got to [CHANNEL] only if we are not directly in the channel if (channel_id and channel_name and create_path('channel', channel_id) != path): diff --git a/resources/lib/youtube_plugin/youtube/helper/yt_specials.py b/resources/lib/youtube_plugin/youtube/helper/yt_specials.py index 5dd84e491..f388a5d84 100644 --- a/resources/lib/youtube_plugin/youtube/helper/yt_specials.py +++ b/resources/lib/youtube_plugin/youtube/helper/yt_specials.py @@ -10,14 +10,7 @@ from __future__ import absolute_import, division, unicode_literals -from . import utils -from ..helper import ( - UrlResolver, - UrlToItemConverter, - extract_urls, - tv, - v3, -) +from . import UrlResolver, UrlToItemConverter, tv, utils, v3 from ...kodion import KodionException from ...kodion.constants import content from ...kodion.items import DirectoryItem, UriItem @@ -226,7 +219,7 @@ def _display_channels(channel_ids): channel_id_dict = {} for channel_id in channel_ids: channel_item = DirectoryItem( - '', context.create_uri(['channel', channel_id], item_params) + '', context.create_uri(('channel', channel_id,), item_params) ) channel_id_dict[channel_id] = channel_item @@ -251,7 +244,7 @@ def _display_playlists(playlist_ids): playlist_id_dict = {} for playlist_id in playlist_ids: playlist_item = DirectoryItem( - '', context.create_uri(['playlist', playlist_id], item_params) + '', context.create_uri(('playlist', playlist_id,), item_params) ) playlist_id_dict[playlist_id] = playlist_item diff --git a/resources/lib/youtube_plugin/youtube/provider.py b/resources/lib/youtube_plugin/youtube/provider.py index c80fa141a..d403ba6d3 100644 --- a/resources/lib/youtube_plugin/youtube/provider.py +++ b/resources/lib/youtube_plugin/youtube/provider.py @@ -332,8 +332,8 @@ def _on_channel_playlists(self, context, re_match): uploads_item = DirectoryItem( context.get_ui().bold(context.localize('uploads')), context.create_uri( - ['channel', channel_id, 'playlist', uploads_playlist], - new_params + ('channel', channel_id, 'playlist', uploads_playlist), + new_params, ), image='{media}/playlist.png', ) @@ -464,7 +464,10 @@ def _on_channel(self, context, re_match): if not hide_playlists: playlists_item = DirectoryItem( ui.bold(localize('playlists')), - create_uri(['channel', channel_id, 'playlists'], new_params), + create_uri( + ('channel', channel_id, 'playlists'), + new_params, + ), image='{media}/playlist.png', fanart=channel_fanarts.get(channel_id), ) @@ -484,7 +487,7 @@ def _on_channel(self, context, re_match): if not hide_live: live_item = DirectoryItem( ui.bold(localize('live')), - create_uri(['channel', search_live_id, 'live'], new_params), + create_uri(('channel', search_live_id, 'live'), new_params), image='{media}/live.png', ) result.append(live_item) @@ -527,8 +530,8 @@ def _on_my_location(self, context, re_match): live_events_item = DirectoryItem( localize('live.completed'), create_uri( - ['special', 'completed_live'], - params={'location': True} + ('special', 'completed_live'), + params={'location': True}, ), image='{media}/live.png', ) @@ -539,8 +542,8 @@ def _on_my_location(self, context, re_match): live_events_item = DirectoryItem( localize('live.upcoming'), create_uri( - ['special', 'upcoming_live'], - params={'location': True} + ('special', 'upcoming_live'), + params={'location': True}, ), image='{media}/live.png', ) @@ -550,8 +553,8 @@ def _on_my_location(self, context, re_match): live_events_item = DirectoryItem( localize('live'), create_uri( - ['special', 'live'], - params={'location': True} + ('special', 'live'), + params={'location': True}, ), image='{media}/live.png', ) @@ -636,7 +639,7 @@ def on_play(self, context, re_match): if builtin: context.execute(builtin.format( - context.create_uri(['play'], params) + context.create_uri(('play',), params) )) return False return yt_play.play_video(self, context) @@ -759,7 +762,7 @@ def on_search(self, search_text, context, re_match): channel_params = dict(params, search_type='channel') channel_item = DirectoryItem( context.get_ui().bold(context.localize('channels')), - context.create_uri([context.get_path()], channel_params), + context.create_uri((context.get_path(),), channel_params), image='{media}/channels.png', ) result.append(channel_item) @@ -768,7 +771,7 @@ def on_search(self, search_text, context, re_match): playlist_params = dict(params, search_type='playlist') playlist_item = DirectoryItem( context.get_ui().bold(context.localize('playlists')), - context.create_uri([context.get_path()], playlist_params), + context.create_uri((context.get_path(),), playlist_params), image='{media}/playlist.png', ) result.append(playlist_item) @@ -781,8 +784,8 @@ def on_search(self, search_text, context, re_match): live_item = DirectoryItem( context.get_ui().bold(context.localize('live')), context.create_uri( - [context.get_path().replace('input', 'query')], - live_params + (context.get_path().replace('input', 'query'),), + live_params, ), image='{media}/live.png', ) @@ -1209,7 +1212,7 @@ def on_root(self, context, re_match): elif local_history: watch_history_item = DirectoryItem( localize('history'), - create_uri([paths.HISTORY], params={'action': 'list'}), + create_uri((paths.HISTORY,), params={'action': 'list'}), image='{media}/history.png', ) result.append(watch_history_item)