mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-22 10:11:52 +00:00
[Youtube] Update consent cookie handling to match site
Apologies for force push! [skip ci]
This commit is contained in:
parent
00ef748cc0
commit
b7fca0fab3
1 changed files with 4 additions and 10 deletions
|
@ -260,16 +260,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
cookies = self._get_cookies('https://www.youtube.com/')
|
cookies = self._get_cookies('https://www.youtube.com/')
|
||||||
if cookies.get('__Secure-3PSID'):
|
if cookies.get('__Secure-3PSID'):
|
||||||
return
|
return
|
||||||
consent_id = None
|
socs = cookies.get('SOCS')
|
||||||
consent = cookies.get('CONSENT')
|
if socs and not socs.value.startswith('CAA'): # not consented
|
||||||
if consent:
|
|
||||||
if 'YES' in consent.value:
|
|
||||||
return
|
return
|
||||||
consent_id = self._search_regex(
|
self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True) # accept all (required for mixes)
|
||||||
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)
|
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self._initialize_consent()
|
self._initialize_consent()
|
||||||
|
|
Loading…
Reference in a new issue