From e4dbcbf4b383424044889425554baa160eee3f29 Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Sat, 19 Jun 2021 11:37:43 -0400 Subject: [PATCH 1/4] apply cookie consent to all pages --- resources/lib/youtube_plugin/youtube/helper/video_info.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/video_info.py b/resources/lib/youtube_plugin/youtube/helper/video_info.py index 4d91fa2fa..eac55232f 100644 --- a/resources/lib/youtube_plugin/youtube/helper/video_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/video_info.py @@ -551,12 +551,14 @@ def get_embed_page(self, video_id): params = {'hl': self.language, 'gl': self.region} + cookies = {'CONSENT': 'YES+cb.20210615-14-p0.en+FX+294'} + if self._access_token: params['access_token'] = self._access_token url = 'https://www.youtube.com/embed/{video_id}'.format(video_id=video_id) - result = requests.get(url, params=params, headers=headers, verify=self._verify, allow_redirects=True) + result = requests.get(url, params=params, headers=headers, cookies=cookies, verify=self._verify, allow_redirects=True) return {'html': result.text, 'cookies': result.cookies} @staticmethod @@ -701,6 +703,10 @@ def requires_cipher(_fmts): curl_headers = '' cookies = page_result.get('cookies', {}) + cookies.update({ + 'CONSENT': 'YES+cb.20210615-14-p0.en+FX+294' + }) + if cookies: cookies_list = list() for c in cookies: From 7a8466e574c68b158c3db09f83fea53f3dd31f96 Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Sat, 19 Jun 2021 11:38:04 -0400 Subject: [PATCH 2/4] fix title encoding for some videos --- resources/lib/youtube_plugin/youtube/helper/video_info.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/video_info.py b/resources/lib/youtube_plugin/youtube/helper/video_info.py index eac55232f..2252e66af 100644 --- a/resources/lib/youtube_plugin/youtube/helper/video_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/video_info.py @@ -778,8 +778,12 @@ def requires_cipher(_fmts): if PY2: try: - meta_info['video']['title'] = meta_info['video']['title'].decode('utf-8') - meta_info['channel']['author'] = meta_info['channel']['author'].decode('utf-8') + if r'\u' not in meta_info['video']['title']: + meta_info['video']['title'] = meta_info['video']['title'].decode('utf-8') + meta_info['channel']['author'] = meta_info['channel']['author'].decode('utf-8') + else: + meta_info['video']['title'] = meta_info['video']['title'].decode('raw_unicode_escape') + meta_info['channel']['author'] = meta_info['channel']['author'].decode('raw_unicode_escape') except UnicodeDecodeError: meta_info['video']['title'] = meta_info['video']['title'].decode('raw_unicode_escape') meta_info['channel']['author'] = meta_info['channel']['author'].decode('raw_unicode_escape') From 2ffc434e9c249e3b03fcae5a6c46ffac267b1f9e Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Sat, 19 Jun 2021 11:52:25 -0400 Subject: [PATCH 3/4] fixup age gate detection --- resources/lib/youtube_plugin/youtube/helper/video_info.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/video_info.py b/resources/lib/youtube_plugin/youtube/helper/video_info.py index 2252e66af..f620ee1d3 100644 --- a/resources/lib/youtube_plugin/youtube/helper/video_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/video_info.py @@ -747,7 +747,9 @@ def requires_cipher(_fmts): result = requests.get(video_info_url, params=http_params, headers=headers, cookies=cookies, verify=self._verify, allow_redirects=True) data = result.text params = dict(urllib.parse.parse_qsl(data)) - player_response = json.loads(params.get('player_response', '{}')) + p_response = json.loads(params.get('player_response', '{}')) + if p_response: + player_response = p_response playability_status = player_response.get('playabilityStatus', {}) From a05112cd91c66039fe7dfef4058c17a4b8fc5891 Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Sat, 19 Jun 2021 11:56:00 -0400 Subject: [PATCH 4/4] Update changes --- addon.xml | 13 ++++--------- changelog.txt | 6 ++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addon.xml b/addon.xml index 0a1cca9b9..51f31d902 100644 --- a/addon.xml +++ b/addon.xml @@ -13,15 +13,10 @@ -6.8.14 -[fixup] playback of some streams due to encoding issues -[fixup] default player response type - -6.8.13 -[fix] player config and client discovery -[fix] No Streams Found |contrib: 14mRh4X0r| -[fix] capability map to contain unversioned capabilities |contrib: jmbreuer| -[lang] zh_tw strings |contrib: JuenTingShie| +[fixup] No streams found, consent cookies |contrib: jaylinski| +[fixup] Age gate detection, show age gate error instead of 'No streams found' +[fixup] encoding of some titles/authors - ie. russian +[lang] translation updates from Weblate icon.png diff --git a/changelog.txt b/changelog.txt index ceb48c274..5a2ce8253 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +6.8.15 +[fixup] No streams found, consent cookies |contrib: jaylinski| +[fixup] Age gate detection, show age gate error instead of 'No streams found' +[fixup] encoding of some titles/authors - ie. russian +[lang] translation updates from Weblate + 6.8.14 [fixup] playback of some streams due to encoding issues [fixup] default player response type