From 07dbce20b9d2e6361b59b8c7fff09d2834962967 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Fri, 26 Jul 2024 03:13:44 +1000 Subject: [PATCH 1/5] Fix disabling certification verification after 5ba1813 and 97f9170 #841 --- resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py | 4 ++-- resources/lib/youtube_plugin/kodion/network/requests.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py b/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py index a286e3c8d..99569e4e8 100644 --- a/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py +++ b/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py @@ -418,11 +418,11 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs): if current_system_version.compatible(21, 0): isa_capabilities = context.inputstream_adaptive_capabilities() - if video_item.live and isa_capabilities['manifest_config_prop']: + if video_item.live and 'manifest_config_prop' in isa_capabilities: props['inputstream.adaptive.manifest_config'] = dumps({ 'timeshift_bufferlimit': 4 * 60 * 60, }) - if not settings.verify_ssl() and isa_capabilities['config_prop']: + if not settings.verify_ssl() and 'config_prop' in isa_capabilities: props['inputstream.adaptive.config'] = dumps({ 'ssl_verify_peer': False, }) diff --git a/resources/lib/youtube_plugin/kodion/network/requests.py b/resources/lib/youtube_plugin/kodion/network/requests.py index f735a6bea..4c060c4d6 100644 --- a/resources/lib/youtube_plugin/kodion/network/requests.py +++ b/resources/lib/youtube_plugin/kodion/network/requests.py @@ -35,8 +35,11 @@ class SSLHTTPAdapter(HTTPAdapter): def init_poolmanager(self, *args, **kwargs): kwargs['ssl_context'] = self._ssl_context - super(SSLHTTPAdapter, self).init_poolmanager(*args, **kwargs) + return super(SSLHTTPAdapter, self).init_poolmanager(*args, **kwargs) + def cert_verify(self, conn, url, verify, cert): + self._ssl_context.check_hostname = bool(verify) + return super(SSLHTTPAdapter, self).cert_verify(conn, url, verify, cert) class BaseRequestsClass(object): _session = Session() From be34f5da6a577f000959412ea2bd434bbf276542 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Fri, 26 Jul 2024 20:49:09 +1000 Subject: [PATCH 2/5] Fix not using player request fallbacks #845 --- .../youtube/helper/stream_info.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/stream_info.py b/resources/lib/youtube_plugin/youtube/helper/stream_info.py index 91f92e4de..d4f2398a1 100644 --- a/resources/lib/youtube_plugin/youtube/helper/stream_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/stream_info.py @@ -1360,9 +1360,11 @@ def _get_stream_info(self): if self._access_token: client_data['_access_token'] = self._access_token + last_status = None + num_errors = num_requests = 0 while 1: for client_name in self._prioritised_clients: - if status is not None: + if last_status: self._context.log_warning( 'Failed to retrieve video info - ' 'video_id: {0}, client: {1}, auth: {2},\n' @@ -1370,7 +1372,7 @@ def _get_stream_info(self): video_id, client['_name'], bool(client.get('_access_token')), - status, + last_status, reason or 'UNKNOWN', ) ) @@ -1393,9 +1395,10 @@ def _get_stream_info(self): **client ) + num_requests += 1 video_details = result.get('videoDetails', {}) playability_status = result.get('playabilityStatus', {}) - status = playability_status.get('status', '').upper() + status = playability_status.get('status', 'ERROR').upper() reason = playability_status.get('reason', '') if video_details and video_id != video_details.get('videoId'): @@ -1406,7 +1409,6 @@ def _get_stream_info(self): if status == 'OK': break elif status in { - '', 'AGE_CHECK_REQUIRED', 'AGE_VERIFICATION_REQUIRED', 'CONTENT_CHECK_REQUIRED', @@ -1415,6 +1417,9 @@ def _get_stream_info(self): 'LOGIN_REQUIRED', 'UNPLAYABLE', }: + if not last_status or status == last_status: + num_errors += 1 + last_status = status if (playability_status.get('desktopLegacyAgeGateReason') and _settings.age_gate()): break @@ -1447,17 +1452,16 @@ def _get_stream_info(self): ) if url and url.startswith('//support.google.com/youtube/answer/12318250'): status = 'CONTENT_NOT_AVAILABLE_IN_THIS_APP' - continue else: self._context.log_debug( 'Unknown playabilityStatus in player response:\n|{0}|' .format(playability_status) ) - continue - break # Only attempt to remove Authorization header if clients iterable # was exhausted i.e. request attempted using all clients else: + if num_errors == num_requests: + break if '_access_token' in client_data: del client_data['_access_token'] continue From ee3feef0760eb4f9931e0c6fde1a683ade510999 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:18:09 +1000 Subject: [PATCH 3/5] Fix incorrectly identifying VP9 streams #833 --- resources/lib/youtube_plugin/youtube/helper/stream_info.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/stream_info.py b/resources/lib/youtube_plugin/youtube/helper/stream_info.py index d4f2398a1..eea0b3c36 100644 --- a/resources/lib/youtube_plugin/youtube/helper/stream_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/stream_info.py @@ -662,7 +662,9 @@ class StreamInfo(YouTubeRequestClient): # video - order based on comparative compression ratio 'av01': 1, 'vp9': 0.75, + 'vp09': 0.75, 'vp8': 0.55, + 'vp08': 0.55, 'avc1': 0.5, 'h.264': 0.5, 'h.263': 0.4, @@ -1791,7 +1793,7 @@ def _process_stream_data(self, stream_data, default_lang_code='und'): codec = re.match(r'codecs="([a-z0-9]+([.\-][0-9](?="))?)', codecs) if codec: codec = codec.group(1) - if codec.startswith('vp9'): + if codec.startswith(('vp9', 'vp09')): codec = 'vp9' elif codec.startswith('dts'): codec = 'dts' From e0d77f5d4f1901ccb790a7b76dfca5b948aadf2f Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:50:35 +1000 Subject: [PATCH 4/5] Allow disabling http server sleep #810 --- .../youtube_plugin/kodion/constants/const_settings.py | 1 + .../youtube_plugin/kodion/monitors/service_monitor.py | 8 ++++++-- resources/lib/youtube_plugin/kodion/service_runner.py | 9 ++++++--- .../youtube_plugin/kodion/settings/abstract_settings.py | 5 +++++ resources/settings.xml | 5 +++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/resources/lib/youtube_plugin/kodion/constants/const_settings.py b/resources/lib/youtube_plugin/kodion/constants/const_settings.py index a2099a811..c02f1d1d2 100644 --- a/resources/lib/youtube_plugin/kodion/constants/const_settings.py +++ b/resources/lib/youtube_plugin/kodion/constants/const_settings.py @@ -81,3 +81,4 @@ HTTPD_PORT = 'kodion.http.port' # (number) HTTPD_LISTEN = 'kodion.http.listen' # (string) HTTPD_WHITELIST = 'kodion.http.ip.whitelist' # (string) +HTTPD_IDLE_SLEEP = 'youtube.http.idle_sleep' # (bool) diff --git a/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py b/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py index a704d9573..5a35fffaf 100644 --- a/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py +++ b/resources/lib/youtube_plugin/kodion/monitors/service_monitor.py @@ -42,7 +42,7 @@ def __init__(self, context): self.httpd = None self.httpd_thread = None - self.httpd_sleep_allowed = True + self.httpd_sleep_allowed = settings.httpd_sleep_allowed() self.system_idle = False self.refresh = False @@ -106,7 +106,7 @@ def onNotification(self, sender, method, data): self.interrupt = True elif target == SERVER_WAKEUP: if not self.httpd and self.httpd_required(): - self.httpd_sleep_allowed = False + self.httpd_sleep_allowed = None self.start_httpd() if data.get('response_required'): self.set_property(WAKEUP, target) @@ -164,6 +164,10 @@ def onSettingsChanged(self): self._whitelist = whitelist httpd_restart = httpd_started + sleep_allowed = settings.httpd_sleep_allowed() + if sleep_allowed is False: + self.httpd_sleep_allowed = False + if self.httpd_required(settings): if httpd_restart: self.restart_httpd() diff --git a/resources/lib/youtube_plugin/kodion/service_runner.py b/resources/lib/youtube_plugin/kodion/service_runner.py index 1e3efa730..89fc41fff 100644 --- a/resources/lib/youtube_plugin/kodion/service_runner.py +++ b/resources/lib/youtube_plugin/kodion/service_runner.py @@ -90,9 +90,12 @@ def run(): httpd_idle_time_ms = 0 monitor.shutdown_httpd(sleep=True) else: - if pop_property(SERVER_POST_START): - monitor.httpd_sleep_allowed = True - httpd_idle_time_ms = 0 + if monitor.httpd_sleep_allowed is None: + if pop_property(SERVER_POST_START): + monitor.httpd_sleep_allowed = True + httpd_idle_time_ms = 0 + else: + pop_property(SERVER_POST_START) else: if httpd_idle_time_ms >= httpd_ping_period_ms: httpd_idle_time_ms = 0 diff --git a/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py b/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py index 3af3346fd..3e51fa107 100644 --- a/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py +++ b/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py @@ -290,6 +290,11 @@ def httpd_whitelist(self): allow_list.append('.'.join(map(str, octets))) return allow_list + def httpd_sleep_allowed(self, value=None): + if value is not None: + return self.set_bool(SETTINGS.HTTPD_IDLE_SLEEP, value) + return self.get_bool(SETTINGS.HTTPD_IDLE_SLEEP, True) + def api_config_page(self): return self.get_bool(SETTINGS.API_CONFIG_PAGE, False) diff --git a/resources/settings.xml b/resources/settings.xml index 604bbcc1d..1bd96ae23 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -994,6 +994,11 @@ RunScript($ID,config/show_client_ip) + + 0 + true + + From f3a30595a53d7cdaba0a354fa80d58947381065b Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:57:27 +1000 Subject: [PATCH 5/5] Version bump v7.0.9+beta.5 --- addon.xml | 2 +- changelog.txt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index f3a9876ab..82080ea3b 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/changelog.txt b/changelog.txt index 5f4318280..5d76f7b58 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +## v7.0.9+beta.5 +### Fixed +- Fix disabling certification verification #841 +- Fix not using player request fallbacks #845 +- Fix incorrectly identifying VP9 streams #833 +- Fix videos not able to be re-opened from Kodi playlist #810 + ## v7.0.9+beta.4 ### Fixed - Fix issues with next page and jump to page in related video listings