aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoletdjnz <coletdjnz@protonmail.com>2023-08-12 16:26:08 +1200
committerGitHub <noreply@github.com>2023-08-12 04:26:08 +0000
commit378ae9f9fb8e8c86e6ac89c4c5b815b48ce93620 (patch)
tree5145d7415fc9982e83c56d736d7654bd4ee92bf5
parentdb7b054a6111ca387220d0eb87bf342f9c130eb8 (diff)
downloadhypervideo-pre-378ae9f9fb8e8c86e6ac89c4c5b815b48ce93620.tar.lz
hypervideo-pre-378ae9f9fb8e8c86e6ac89c4c5b815b48ce93620.tar.xz
hypervideo-pre-378ae9f9fb8e8c86e6ac89c4c5b815b48ce93620.zip
[ie/youtube] Fix consent cookie (#7774)
Fixes #7594 Authored by: coletdjnz
-rw-r--r--yt_dlp/extractor/youtube.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 1e16631b1..023d8fd8c 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -496,16 +496,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
cookies = self._get_cookies('https://www.youtube.com/')
if cookies.get('__Secure-3PSID'):
return
- consent_id = None
- consent = cookies.get('CONSENT')
- if consent:
- if 'YES' in consent.value:
- return
- consent_id = self._search_regex(
- r'PENDING\+(\d+)', consent.value, 'consent', default=None)
- if not consent_id:
- consent_id = random.randint(100, 999)
- self._set_cookie('.youtube.com', 'CONSENT', 'YES+cb.20210328-17-p0.en+FX+%s' % consent_id)
+ socs = cookies.get('SOCS')
+ if socs and not socs.value.startswith('CAA'): # not consented
+ return
+ self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True) # accept all (required for mixes)
def _initialize_pref(self):
cookies = self._get_cookies('https://www.youtube.com/')