aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>2023-11-15 18:54:31 -0500
committerdirkf <fieldhouse@gmx.net>2023-11-29 21:43:02 +0000
commitb7fca0fab36c71fee02d6ecf81acbbaa46942be4 (patch)
treee17862ce05bf865e8fc7ab44ed5a192d95f25065 /youtube_dl/extractor
parent00ef748cc0e35ee60efd0f7a00e373ab8d1af86b (diff)
downloadyoutube-dl-b7fca0fab36c71fee02d6ecf81acbbaa46942be4.tar.xz
[Youtube] Update consent cookie handling to match site
Apologies for force push! [skip ci]
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/youtube.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 9c419c002..3bf483c1c 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -260,16 +260,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 _real_initialize(self):
self._initialize_consent()