diff --git a/resources/lib/youtube_plugin/youtube/client/youtube.py b/resources/lib/youtube_plugin/youtube/client/youtube.py index efac5edfe..6006fa35f 100644 --- a/resources/lib/youtube_plugin/youtube/client/youtube.py +++ b/resources/lib/youtube_plugin/youtube/client/youtube.py @@ -883,7 +883,7 @@ def get_channel_sections(self, channel_id, **kwargs): **kwargs) def get_playlists_of_channel(self, channel_id, page_token='', **kwargs): - params = {'part': 'snippet', + params = {'part': 'snippet,status,contentDetails', 'maxResults': str(self.max_results())} if channel_id == 'mine': params['mine'] = True diff --git a/resources/lib/youtube_plugin/youtube/helper/resource_manager.py b/resources/lib/youtube_plugin/youtube/helper/resource_manager.py index 2eb81eee2..44dac2ed7 100644 --- a/resources/lib/youtube_plugin/youtube/helper/resource_manager.py +++ b/resources/lib/youtube_plugin/youtube/helper/resource_manager.py @@ -251,7 +251,7 @@ def get_playlists(self, ids, suppress_errors=False, defer_cache=False): result = {} else: data_cache = context.get_data_cache() - result = data_cache.get_items(ids, data_cache.ONE_MONTH) + result = data_cache.get_items(ids, data_cache.ONE_DAY) to_update = [id_ for id_ in ids if id_ not in result or not result[id_] @@ -415,6 +415,30 @@ def get_related_playlists(self, channel_id, defer_cache=False): return None return item.get('contentDetails', {}).get('relatedPlaylists') + def get_my_playlists(self, channel_id, page_token, defer_cache=False): + context = self._context + client = self._provider.get_client(context) + + result = client.get_playlists_of_channel(channel_id, page_token) + if not result: + return None + + new_data = { + yt_item['id']: yt_item + for yt_item in result.get('items', []) + if yt_item + } + if new_data: + context.debug_log and context.log_debug( + 'ResourceManager.get_my_playlists' + ' - Retrieved new data for playlists' + '\n\tPlaylist IDs: {ids}' + .format(ids=list(new_data)) + ) + self.cache_data(new_data, defer=defer_cache) + + return result + def get_videos(self, ids, live_details=False, diff --git a/resources/lib/youtube_plugin/youtube/provider.py b/resources/lib/youtube_plugin/youtube/provider.py index 0d496a2ff..0e165aef5 100644 --- a/resources/lib/youtube_plugin/youtube/provider.py +++ b/resources/lib/youtube_plugin/youtube/provider.py @@ -470,9 +470,7 @@ def on_channel_playlists(provider, context, re_match): else: result = False - json_data = provider.get_client(context).get_playlists_of_channel( - channel_id, page_token - ) + json_data = resource_manager.get_my_playlists(channel_id, page_token) if not json_data: return result