diff --git a/resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py b/resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py index 369b3d012..58e05835e 100644 --- a/resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py +++ b/resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py @@ -143,6 +143,8 @@ class XbmcContext(AbstractContext): 'live.completed': 30647, 'live.upcoming': 30646, 'loading': 575, + 'loading.directory': 1040, + 'loading.directory.progress': 1042, 'maintenance.bookmarks': 30800, 'maintenance.data_cache': 30687, 'maintenance.feed_history': 30814, @@ -153,7 +155,7 @@ class XbmcContext(AbstractContext): 'my_channel': 30507, 'my_location': 30654, 'my_subscriptions': 30510, - 'my_subscriptions.loading': 575, + 'my_subscriptions.loading': 30510, 'my_subscriptions.filter.add': 30587, 'my_subscriptions.filter.added': 30589, 'my_subscriptions.filter.remove': 30588, diff --git a/resources/lib/youtube_plugin/kodion/ui/abstract_progress_dialog.py b/resources/lib/youtube_plugin/kodion/ui/abstract_progress_dialog.py index ef8149f23..f79d74747 100644 --- a/resources/lib/youtube_plugin/kodion/ui/abstract_progress_dialog.py +++ b/resources/lib/youtube_plugin/kodion/ui/abstract_progress_dialog.py @@ -29,7 +29,13 @@ def __init__(self, self._message = message self._message_template = message_template - self._template_params = template_params or {} + self._template_params = { + '_progress': (0, self._total), + '_current': 0, + '_total': self._total, + } + if template_params: + self._template_params.update(template_params) # simple reset because KODI won't do it :( self.update(position=0) @@ -97,10 +103,14 @@ def update(self, steps=1, position=None, message=None, **template_params): elif self._message_template: if template_params: self._template_params.update(template_params) - else: - self._template_params['current'] = self._position - self._template_params['total'] = self._total - message = self._message_template.format(**self._template_params) + template_params = self._template_params + progress = (self._position, self._total) + template_params['_progress'] = progress + template_params['_current'], template_params['_total'] = progress + message = self._message_template.format( + *template_params['_progress'], + **template_params + ) self._message = message self._dialog.update( diff --git a/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_context_ui.py b/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_context_ui.py index 08c25a6ad..efe731dab 100644 --- a/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_context_ui.py +++ b/resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_context_ui.py @@ -29,12 +29,13 @@ def create_progress_dialog(self, message_template=None, template_params=None): if not message_template: - message_template = ('{wait} {{current}}/{{total}}'.format( - wait=self._context.localize('please_wait') + message_template = ('{wait} {{_current}}/{{_total}}'.format( + wait=(message or self._context.localize('please_wait')) )) template_params = { - 'current': 0, - 'total': 0, + '_progress': (0, 100), + '_current': 0, + '_total': 100, } return XbmcProgressDialog( heading, message, background, message_template, template_params diff --git a/resources/lib/youtube_plugin/youtube/client/youtube.py b/resources/lib/youtube_plugin/youtube/client/youtube.py index 873d9decf..cb5101ad1 100644 --- a/resources/lib/youtube_plugin/youtube/client/youtube.py +++ b/resources/lib/youtube_plugin/youtube/client/youtube.py @@ -1744,9 +1744,7 @@ def _parse_feeds(feeds, _cache=cache): if progress_dialog: total = len(feeds) - progress_dialog.reset_total(new_total=total, - current=0, - total=total) + progress_dialog.reset_total(total) all_items = {} new_cache = {} @@ -1812,7 +1810,7 @@ def _parse_feeds(feeds, all_items[channel_id] = feed_items if progress_dialog: - progress_dialog.update(current=len(all_items)) + progress_dialog.update(position=len(all_items)) if new_cache: _cache.set_items(new_cache) @@ -1938,13 +1936,11 @@ def _threaded_fetch(kwargs, completed = [] iterator = iter(payloads) if progress_dialog: - total = progress_dialog.grow_total( - new_total=len(threaded_output['channel_ids']), + progress_dialog.grow_total( + len(threaded_output['channel_ids']), ) progress_dialog.update( - steps=0, - current=len(threaded_output['feeds']), - total=total, + position=len(threaded_output['feeds']), ) continue diff --git a/resources/lib/youtube_plugin/youtube/helper/v3.py b/resources/lib/youtube_plugin/youtube/helper/v3.py index 55649b141..19df74fdb 100644 --- a/resources/lib/youtube_plugin/youtube/helper/v3.py +++ b/resources/lib/youtube_plugin/youtube/helper/v3.py @@ -456,13 +456,13 @@ def _fetch(resource): threads['loop'].set() if progress_dialog: - total = (len(video_id_dict) + delta = (len(video_id_dict) + len(channel_id_dict) + len(playlist_id_dict) + len(playlist_item_id_dict) + len(subscription_id_dict)) - total = progress_dialog.grow_total(delta=total) - progress_dialog.update(steps=0, total=total) + progress_dialog.grow_total(delta=delta) + progress_dialog.update(steps=delta) while threads['loop'].wait(): try: @@ -539,8 +539,8 @@ def response_to_items(provider, next_page = None with context.get_ui().create_progress_dialog( - heading=context.localize('loading'), - message=context.localize('please_wait'), + heading=context.localize('loading.directory'), + message_template=context.localize('loading.directory.progress'), background=True, ) as progress_dialog: remaining = None diff --git a/resources/lib/youtube_plugin/youtube/helper/yt_play.py b/resources/lib/youtube_plugin/youtube/helper/yt_play.py index f85c7d84e..91633f7b1 100644 --- a/resources/lib/youtube_plugin/youtube/helper/yt_play.py +++ b/resources/lib/youtube_plugin/youtube/helper/yt_play.py @@ -201,12 +201,7 @@ def _play_playlist(provider, context): json_data = resource_manager.get_playlist_items(playlist_ids) total = sum(len(chunk.get('items', [])) for chunk in json_data.values()) - progress_dialog.set_total(total) - progress_dialog.update( - steps=0, - current=0, - total=total, - ) + progress_dialog.reset_total(total) # start the loop and fill the list with video items for chunk in json_data.values(): @@ -216,11 +211,7 @@ def _play_playlist(provider, context): process_next_page=False) video_items.extend(result) - progress_dialog.update( - steps=len(result), - current=len(video_items), - total=total, - ) + progress_dialog.update(steps=len(result)) if not video_items: return False diff --git a/resources/lib/youtube_plugin/youtube/helper/yt_specials.py b/resources/lib/youtube_plugin/youtube/helper/yt_specials.py index 0a044eb8a..519080944 100644 --- a/resources/lib/youtube_plugin/youtube/helper/yt_specials.py +++ b/resources/lib/youtube_plugin/youtube/helper/yt_specials.py @@ -328,7 +328,7 @@ def _process_my_subscriptions(provider, context, client, filtered=False): with context.get_ui().create_progress_dialog( heading=context.localize('my_subscriptions.loading'), - message=context.localize('please_wait'), + message=context.localize('channels'), background=True, ) as progress_dialog: json_data = client.get_my_subscriptions(