From b83c2a1fa8a21ed7357c3ae8a1e2e44a3dcebcd9 Mon Sep 17 00:00:00 2001 From: Jakob Linskeseder Date: Sat, 19 Jun 2021 15:07:41 +0200 Subject: [PATCH] Automatically consent to YouTube cookies Since Kodi doesn't store any cookies, we can simply consent to the YouTube cookie-policy by simply sending a consent-cookie with every request. Fixes #139 #145 --- 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 b6618d9c0..4d91fa2fa 100644 --- a/resources/lib/youtube_plugin/youtube/helper/video_info.py +++ b/resources/lib/youtube_plugin/youtube/helper/video_info.py @@ -528,12 +528,14 @@ def get_watch_page(self, video_id): '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/watch' - 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} def get_embed_page(self, video_id):