File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,23 @@ def warn(message):
249
249
250
250
return True
251
251
252
+ def _initialize_consent (self ):
253
+ cookies = self ._get_cookies ('https://www.youtube.com/' )
254
+ if cookies .get ('__Secure-3PSID' ):
255
+ return
256
+ consent_id = None
257
+ consent = cookies .get ('CONSENT' )
258
+ if consent :
259
+ if 'YES' in consent .value :
260
+ return
261
+ consent_id = self ._search_regex (
262
+ r'PENDING\+(\d+)' , consent .value , 'consent' , default = None )
263
+ if not consent_id :
264
+ consent_id = random .randint (100 , 999 )
265
+ self ._set_cookie ('.youtube.com' , 'CONSENT' , 'YES+cb.20210328-17-p0.en+FX+%s' % consent_id )
266
+
252
267
def _real_initialize (self ):
268
+ self ._initialize_consent ()
253
269
if self ._downloader is None :
254
270
return
255
271
if not self ._login ():
You can’t perform that action at this time.
0 commit comments