diff --git a/addon.xml b/addon.xml index 2c8ffd672..b526f7fcc 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/changelog.txt b/changelog.txt index aa93b75e7..82ec7ef4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,11 @@ +## v7.1.1+beta.7 +### Fixed +- Fix loading of Watch Later playlist #971 + - Also fix other incorrect/missing parameter names + +### Changed +- Don't retry server wakeup on error unless settings change + ## v7.1.1+beta.6 ### Fixed - Ensure http server is started prior to creating MPD for playback #961 diff --git a/resources/lib/youtube_plugin/kodion/abstract_provider.py b/resources/lib/youtube_plugin/kodion/abstract_provider.py index 7ceaaa048..54885c37a 100644 --- a/resources/lib/youtube_plugin/kodion/abstract_provider.py +++ b/resources/lib/youtube_plugin/kodion/abstract_provider.py @@ -122,11 +122,8 @@ def run_wizard(self, context): # ui local variable used for ui.get_view_manager() in unofficial version ui = context.get_ui() - context.wakeup( - CHECK_SETTINGS, - timeout=5, - payload={'state': 'defer'}, - ) + settings_state = {'state': 'defer'} + context.wakeup(CHECK_SETTINGS, timeout=5, payload=settings_state) wizard_steps = self.get_wizard_steps() @@ -150,11 +147,8 @@ def run_wizard(self, context): finally: settings = context.get_settings(refresh=True) settings.setup_wizard_enabled(False) - context.wakeup( - CHECK_SETTINGS, - timeout=5, - payload={'state': 'process'}, - ) + settings_state['state'] = 'process' + context.wakeup(CHECK_SETTINGS, timeout=5, payload=settings_state) @staticmethod def get_wizard_steps(): 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 4368ccbb3..c13a9dbb7 100644 --- a/resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py +++ b/resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py @@ -61,10 +61,8 @@ class XbmcContext(AbstractContext): 'api.personal.disabled': 30637, 'api.personal.failed': 30599, 'api.secret': 30203, - 'archive': 30105, 'are_you_sure': 750, 'ask': 863, - 'auto_remove_watch_later': 30515, 'bookmark': 30101, 'bookmark.channel': 30803, 'bookmark.created': 21362, @@ -125,8 +123,6 @@ class XbmcContext(AbstractContext): 'inputstreamhelper.is_installed': 30625, 'isa.enable.check': 30579, 'key.requirement': 30731, - 'latest_videos': 30109, - 'library': 30103, 'liked.video': 30716, 'live': 839, 'live.completed': 30647, diff --git a/resources/lib/youtube_plugin/kodion/items/base_item.py b/resources/lib/youtube_plugin/kodion/items/base_item.py index fe44b0b28..5f7649990 100644 --- a/resources/lib/youtube_plugin/kodion/items/base_item.py +++ b/resources/lib/youtube_plugin/kodion/items/base_item.py @@ -127,7 +127,7 @@ def parse_item_ids_from_uri(self): def set_name(self, name): try: name = unescape(name) - except: + except Exception: pass self._name = name return name diff --git a/resources/lib/youtube_plugin/kodion/items/directory_item.py b/resources/lib/youtube_plugin/kodion/items/directory_item.py index a4cab88be..e34c61e76 100644 --- a/resources/lib/youtube_plugin/kodion/items/directory_item.py +++ b/resources/lib/youtube_plugin/kodion/items/directory_item.py @@ -71,7 +71,7 @@ def get_category_label(self): def set_plot(self, plot): try: plot = unescape(plot) - except: + except Exception: pass self._plot = plot diff --git a/resources/lib/youtube_plugin/kodion/items/media_item.py b/resources/lib/youtube_plugin/kodion/items/media_item.py index c05ca7545..0a8554d85 100644 --- a/resources/lib/youtube_plugin/kodion/items/media_item.py +++ b/resources/lib/youtube_plugin/kodion/items/media_item.py @@ -31,7 +31,11 @@ def __init__(self, image='DefaultFile.png', fanart=None, plot=None, - video_id=None,): + video_id=None, + channel_id=None, + playlist_id=None, + playlist_item_id=None, + subscription_id=None): super(MediaItem, self).__init__(name, uri, image, fanart) self._aired = None self._premiered = None @@ -64,10 +68,10 @@ def __init__(self, self._vod = False self._video_id = video_id - self._channel_id = None - self._subscription_id = None - self._playlist_id = None - self._playlist_item_id = None + self._channel_id = channel_id + self._subscription_id = subscription_id + self._playlist_id = playlist_id + self._playlist_item_id = playlist_item_id def set_aired(self, year, month, day): self._aired = date(year, month, day) @@ -181,7 +185,7 @@ def get_mediatype(self): def set_plot(self, plot): try: plot = unescape(plot) - except: + except Exception: pass self._plot = plot @@ -202,7 +206,7 @@ def get_rating(self): def set_title(self, title): try: title = unescape(title) - except: + except Exception: pass self._name = self._title = title @@ -342,13 +346,21 @@ def __init__(self, image='DefaultAudio.png', fanart=None, plot=None, - video_id=None): + video_id=None, + channel_id=None, + playlist_id=None, + playlist_item_id=None, + subscription_id=None): super(AudioItem, self).__init__(name, uri, image, fanart, plot, - video_id) + video_id, + channel_id, + playlist_id, + playlist_item_id, + subscription_id) self._album = None def set_album_name(self, album_name): @@ -374,13 +386,21 @@ def __init__(self, image='DefaultVideo.png', fanart=None, plot=None, - video_id=None): + video_id=None, + channel_id=None, + playlist_id=None, + playlist_item_id=None, + subscription_id=None): super(VideoItem, self).__init__(name, uri, image, fanart, plot, - video_id) + video_id, + channel_id, + playlist_id, + playlist_item_id, + subscription_id) self._directors = None self._episode = None self._imdb_id = None diff --git a/resources/lib/youtube_plugin/kodion/json_store/access_manager.py b/resources/lib/youtube_plugin/kodion/json_store/access_manager.py index 0f836475e..a6d8b62d5 100644 --- a/resources/lib/youtube_plugin/kodion/json_store/access_manager.py +++ b/resources/lib/youtube_plugin/kodion/json_store/access_manager.py @@ -439,6 +439,7 @@ def update_access_token(self, refresh_token=None): """ Updates the old access token with the new one. + :param addon_id: :param access_token: :param expiry: :param refresh_token: diff --git a/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py b/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py index 535c764d5..426ba56a8 100644 --- a/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py +++ b/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py @@ -41,6 +41,7 @@ def __init__(self, context): self._old_httpd_address = None self._old_httpd_port = None self._use_httpd = None + self._httpd_error = False self.httpd = None self.httpd_thread = None @@ -137,7 +138,7 @@ def onNotification(self, sender, method, data): if not self.httpd and self.httpd_required(): response = self.start_httpd() else: - response = True + response = bool(self.httpd) if self.httpd_sleep_allowed: self.httpd_sleep_allowed = None @@ -244,7 +245,8 @@ def httpd_address_sync(self): def start_httpd(self): if self.httpd: - return + self._httpd_error = False + return True context = self._context context.log_debug('HTTPServer: Starting |{ip}:{port}|' @@ -255,6 +257,7 @@ def start_httpd(self): port=self._httpd_port, context=context) if not self.httpd: + self._httpd_error = True return False self.httpd_thread = threading.Thread(target=self.httpd.serve_forever) @@ -264,6 +267,7 @@ def start_httpd(self): context.log_debug('HTTPServer: Listening on |{ip}:{port}|' .format(ip=address[0], port=address[1])) + self._httpd_error = False return True def shutdown_httpd(self): @@ -296,13 +300,21 @@ def ping_httpd(self): return self.httpd and httpd_status(self._context) def httpd_required(self, settings=None, while_idle=False): - if while_idle: + if settings: + required = (settings.use_isa() + or settings.api_config_page() + or settings.support_alternative_player()) + self._use_httpd = required + + elif self._httpd_error: + required = False + + elif while_idle: settings = self._context.get_settings() - return (settings.api_config_page() - or settings.support_alternative_player()) + required = (settings.api_config_page() + or settings.support_alternative_player()) - if settings: - self._use_httpd = (settings.use_isa() - or settings.api_config_page() - or settings.support_alternative_player()) - return self._use_httpd + else: + required = self._use_httpd + + return required 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 16f9526f1..e3e11c33f 100644 --- a/resources/lib/youtube_plugin/kodion/ui/abstract_progress_dialog.py +++ b/resources/lib/youtube_plugin/kodion/ui/abstract_progress_dialog.py @@ -61,7 +61,7 @@ def update_total(self, new_total, **kwargs): self._total = int(new_total) self.update(steps=0, **kwargs) - def grow_total(self, new_total, **kwargs): + def grow_total(self, new_total): total = int(new_total) if total > self._total: self._total = total diff --git a/resources/lib/youtube_plugin/kodion/utils/methods.py b/resources/lib/youtube_plugin/kodion/utils/methods.py index 655de452e..30e88b5b1 100644 --- a/resources/lib/youtube_plugin/kodion/utils/methods.py +++ b/resources/lib/youtube_plugin/kodion/utils/methods.py @@ -203,16 +203,17 @@ def find_video_id(plugin_path): return '' -def friendly_number(input, precision=3, scale=('', 'K', 'M', 'B'), as_str=True): - _input = float('{input:.{precision}g}'.format( - input=float(input), precision=precision +def friendly_number(value, precision=3, scale=('', 'K', 'M', 'B'), as_str=True): + value = float('{value:.{precision}g}'.format( + value=float(value), + precision=precision, )) - _abs_input = abs(_input) - magnitude = 0 if _abs_input < 1000 else int(log(floor(_abs_input), 1000)) + abs_value = abs(value) + magnitude = 0 if abs_value < 1000 else int(log(floor(abs_value), 1000)) output = '{output:f}'.format( - output=_input / 1000 ** magnitude + output=value / 1000 ** magnitude ).rstrip('0').rstrip('.') + scale[magnitude] - return output if as_str else (output, _input) + return output if as_str else (output, value) _RE_PERIODS = re.compile(r'([\d.]+)(d|h|m|s|$)') diff --git a/resources/lib/youtube_plugin/youtube/client/youtube.py b/resources/lib/youtube_plugin/youtube/client/youtube.py index 6406004c8..4ab1dc2de 100644 --- a/resources/lib/youtube_plugin/youtube/client/youtube.py +++ b/resources/lib/youtube_plugin/youtube/client/youtube.py @@ -147,9 +147,12 @@ def update_watch_history(self, context, video_id, url, status=None): ' current time={cmt},' ' segment start={st},' ' segment end={et},' - ' state={state}'.format( - video_id=video_id, cmt=cmt, st=st, et=et, state=state - )) + ' state={state}' + .format(video_id=video_id, + cmt=cmt, + st=st, + et=et, + state=state)) headers = { 'Host': 's.youtube.com', diff --git a/resources/lib/youtube_plugin/youtube/helper/stream_info.py b/resources/lib/youtube_plugin/youtube/helper/stream_info.py index 728749bf4..50044a8e2 100644 --- a/resources/lib/youtube_plugin/youtube/helper/stream_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/stream_info.py @@ -1669,10 +1669,10 @@ def load_stream_info(self, video_id): subtitles = Subtitles(context, video_id) query_subtitles = client.get('_query_subtitles') - if (not is_live or live_dvr) and ( - query_subtitles is True - or (query_subtitles - and subtitles.sub_selection == subtitles.LANG_ALL)): + if ((not is_live or live_dvr) + and (query_subtitles is True + or (query_subtitles + and subtitles.sub_selection == subtitles.LANG_ALL))): for client_name in ('smart_tv_embedded', 'web', 'android'): caption_client = self.build_client(client_name, client_data) if not caption_client: diff --git a/resources/lib/youtube_plugin/youtube/helper/subtitles.py b/resources/lib/youtube_plugin/youtube/helper/subtitles.py index 6ac9e8fd0..c9dc8b47a 100644 --- a/resources/lib/youtube_plugin/youtube/helper/subtitles.py +++ b/resources/lib/youtube_plugin/youtube/helper/subtitles.py @@ -166,7 +166,7 @@ def load(self, captions, headers=None): def _unescape(self, text): try: text = unescape(text) - except: + except Exception: self._context.log_error('Subtitles._unescape - failed: |{text}|' .format(text=text)) return text diff --git a/resources/lib/youtube_plugin/youtube/helper/utils.py b/resources/lib/youtube_plugin/youtube/helper/utils.py index 94c1c2044..40cc1e1f1 100644 --- a/resources/lib/youtube_plugin/youtube/helper/utils.py +++ b/resources/lib/youtube_plugin/youtube/helper/utils.py @@ -893,7 +893,7 @@ def update_video_infos(provider, context, video_id_dict, context, playlist_id=playlist_id, video_id=playlist_item_id, - item_name=media_item.get_name(), + video_name=media_item.get_name(), ) ) @@ -1212,7 +1212,7 @@ def add_related_video_to_playlist(provider, context, client, v3, video_id): json_data, process_next_page=False) page_token = json_data.get('nextPageToken', '') - except: + except Exception: context.get_ui().show_notification('Failed to add a suggested video.', time_ms=5000) if result_items: diff --git a/resources/lib/youtube_plugin/youtube/helper/v3.py b/resources/lib/youtube_plugin/youtube/helper/v3.py index 1c5e9f628..0cf27f06f 100644 --- a/resources/lib/youtube_plugin/youtube/helper/v3.py +++ b/resources/lib/youtube_plugin/youtube/helper/v3.py @@ -225,10 +225,10 @@ def _process_list_response(provider, playlist_id_dict[item_id] = item elif kind_type == 'playlistitem': - playlistitem_id = item_id + playlist_item_id = item_id item_id = snippet['resourceId']['videoId'] # store the id of the playlistItem - needed for deleting item - playlist_item_id_dict[item_id] = playlistitem_id + playlist_item_id_dict[item_id] = playlist_item_id item_params['video_id'] = item_id item_uri = context.create_uri( @@ -240,7 +240,8 @@ def _process_list_response(provider, image=image, fanart=fanart, plot=description, - video_id=item_id) + video_id=item_id, + playlist_item_id=playlist_item_id) video_id_dict[item_id] = item elif kind_type == 'activity':