From 9cfd7f04e35674040d979a0099e56245bc9f5bbd Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:35:38 +1100 Subject: [PATCH 1/3] Fix typo that caused android player requests to fail --- .../youtube_plugin/youtube/client/request_client.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/client/request_client.py b/resources/lib/youtube_plugin/youtube/client/request_client.py index 3f5de4c02..5a54d7d63 100644 --- a/resources/lib/youtube_plugin/youtube/client/request_client.py +++ b/resources/lib/youtube_plugin/youtube/client/request_client.py @@ -15,10 +15,10 @@ class YouTubeRequestClient(BaseRequestsClass): - _ANDROID_PARAMS = 'CgIIAdgDAQ==', + _ANDROID_PARAMS = 'CgIIAdgDAQ==' # yt-dlp has chosen the following value, but this results in the android - # player response not including adaptive formats - # _ANDROID_PARAMS = 'CgIIAQ==', + # player response returning unexpected details sometimes. To be investigated + # _ANDROID_PARAMS = 'CgIIAQ==' CLIENTS = { # 4k no VP9 HDR @@ -57,9 +57,6 @@ class YouTubeRequestClient(BaseRequestsClass): '_query_subtitles': True, 'json': { 'params': _ANDROID_PARAMS, - # yt-dlp has chosen the following value, but this results in the - # player response not including adaptive formats - # 'params': 'CgIIAQ==', 'context': { 'client': { 'clientName': 'ANDROID', @@ -263,7 +260,7 @@ class YouTubeRequestClient(BaseRequestsClass): 'request': { 'internalExperimentFlags': [], 'useSsl': True, - } + }, }, 'playbackContext': { 'contentPlaybackContext': { From 8364a412d67d559000cf675e6733fcf65b9eb067 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:39:44 +1100 Subject: [PATCH 2/3] Update to allow for possible future support of DVR streams --- .../youtube/helper/video_info.py | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/video_info.py b/resources/lib/youtube_plugin/youtube/helper/video_info.py index e770396f6..83be1ed17 100644 --- a/resources/lib/youtube_plugin/youtube/helper/video_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/video_info.py @@ -1264,7 +1264,14 @@ def _get_video_info(self): .get('playerMicroformatRenderer', {})) streaming_data = result.get('streamingData', {}) is_live = video_details.get('isLiveContent', False) - thumb_suffix = '_live' if is_live else '' + if is_live: + live_type = _settings.live_stream_type() + live_dvr = video_details.get('isLiveDvrEnabled', False) + thumb_suffix = '_live' + else: + live_type = None + live_dvr = False + thumb_suffix = '' meta_info = { 'video': { @@ -1366,10 +1373,26 @@ def _get_video_info(self): self._cipher = Cipher(self._context, javascript=self._player_js) manifest_url = main_stream = None - live_type = _settings.live_stream_type() if is_live else None if live_type == 'isa_mpd' and 'dashManifestUrl' in streaming_data: manifest_url = streaming_data['dashManifestUrl'] + if '?' in manifest_url: + manifest_url += '&mpd_version=5' + elif manifest_url.endswith('/'): + manifest_url += 'mpd_version/5' + else: + manifest_url += '/mpd_version/5' + + video_stream = { + 'url': manifest_url, + 'meta': meta_info, + 'headers': curl_headers, + 'license_info': license_info, + 'playback_stats': playback_stats + } + details = self.FORMAT.get('9998') + video_stream.update(details) + stream_list.append(video_stream) elif 'hlsManifestUrl' in streaming_data: stream_list.extend(self._load_hls_manifest( streaming_data['hlsManifestUrl'], @@ -1433,15 +1456,7 @@ def _get_video_info(self): manifest_url, main_stream = self._generate_mpd_manifest( video_data, audio_data, subs_data, license_info.get('url') ) - live_type = None - - # extract non-adaptive streams - if all_fmts: - stream_list.extend(self._create_stream_list( - all_fmts, meta_info, client['headers'], playback_stats - )) - if manifest_url: video_stream = { 'url': manifest_url, 'meta': meta_info, @@ -1449,16 +1464,7 @@ def _get_video_info(self): 'license_info': license_info, 'playback_stats': playback_stats } - - if live_type: - if '?' in manifest_url: - video_stream['url'] = manifest_url + '&mpd_version=5' - elif manifest_url.endswith('/'): - video_stream['url'] = manifest_url + 'mpd_version/5' - else: - video_stream['url'] = manifest_url + '/mpd_version/5' - details = self.FORMAT.get('9998') - elif main_stream: + if main_stream: details = self.FORMAT.get('9999').copy() video_info = main_stream['video'] @@ -1495,8 +1501,14 @@ def _get_video_info(self): details['title'] = ''.join(details['title']) - video_stream.update(details) - stream_list.append(video_stream) + video_stream.update(details) + stream_list.append(video_stream) + + # extract non-adaptive streams + if all_fmts: + stream_list.extend(self._create_stream_list( + all_fmts, meta_info, client['headers'], playback_stats + )) if not stream_list: raise YouTubeException('No streams found') @@ -1517,8 +1529,6 @@ def _process_stream_data(self, stream_data, default_lang_code='und'): self.FRACTIONAL_FPS_SCALE) stream_select = _settings.stream_select() - - audio_data = {} video_data = {} preferred_audio = { @@ -1694,7 +1704,7 @@ def _process_stream_data(self, stream_data, default_lang_code='und'): .replace("<", "<") .replace(">", ">")) - data[mime_group][itag] = data[quality_group][itag] = { + details = { 'mimeType': mime_type, 'baseUrl': url, 'mediaType': media_type, @@ -1721,6 +1731,7 @@ def _process_stream_data(self, stream_data, default_lang_code='und'): 'sampleRate': sample_rate, 'channels': channels, } + data[mime_group][itag] = data[quality_group][itag] = details if not video_data: self._context.log_debug('Generate MPD: No video mime-types found') From 587b08825c0e115c0972ae7ce442cb1a97723982 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:53:11 +1100 Subject: [PATCH 3/3] Version bump - v7.0.5+beta.4 --- addon.xml | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index b31803092..9c0b9386f 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/changelog.txt b/changelog.txt index a8f12f650..5de9470b6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +## v7.0.5+beta.4 +### Fixed +- Fix typo that caused android player requests to fail + ## v7.0.5+beta.3 ### Fixed - Fix error message when rating video #666