Skip to content

Commit

Permalink
[sites:youtube] New consent initialization (Fixes #219)
Browse files Browse the repository at this point in the history
  • Loading branch information
pboettcher committed Aug 31, 2023
1 parent 52bf6e5 commit a980e41
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions chat_downloader/sites/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,21 +1355,10 @@ def get_playlist_items(self, playlist_url, params=None):
def _initialize_consent(self):
if self.get_cookie_value('__Secure-3PSID'):
return

consent_id = None
consent = self.get_cookie_value('CONSENT')

if consent:
if 'YES' in consent:
return

consent_id = regex_search(consent, self._CONSENT_ID_REGEX)

if not consent_id:
consent_id = random.randint(100, 999)

self.set_cookie_value('.youtube.com', 'CONSENT',
f'YES+cb.20210328-17-p0.en+FX+{consent_id}')
socs = self.get_cookie_value('SOCS')
if socs and not socs.value.startswith('CAA'): # not consented
return
self.set_cookie_value('.youtube.com', 'SOCS', 'CAI', secure=True) # accept all (required for mixes)

def _generate_sapisidhash_header(self):
sapis_id = self.get_cookie_value('SAPISID')
Expand Down

0 comments on commit a980e41

Please sign in to comment.