Skip to content

Commit

Permalink
fix(youtube): update extractor handling consent
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored and dirkf committed Nov 22, 2023
1 parent 00ef748 commit aaed488
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,10 @@ def _initialize_consent(self):
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()
Expand Down

0 comments on commit aaed488

Please sign in to comment.