-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[youtube] Setup CONSENT cookie when needed (closes #28604)
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,7 +249,23 @@ def warn(message): | |
|
||
return True | ||
|
||
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) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
glubsy
|
||
|
||
def _real_initialize(self): | ||
self._initialize_consent() | ||
if self._downloader is None: | ||
return | ||
if not self._login(): | ||
|
Can anyone shed light on this hardcoded value? I assume the date is when the consent was "given" but what about the rest of it?