mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[ie/youtube] Fix consent cookie (#7774)
Fixes #7594 Authored by: coletdjnz
This commit is contained in:
		| @@ -496,16 +496,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: |             return | ||||||
|             if 'YES' in consent.value: |         self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True)  # accept all (required for mixes) | ||||||
|                 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) |  | ||||||
| 
 | 
 | ||||||
|     def _initialize_pref(self): |     def _initialize_pref(self): | ||||||
|         cookies = self._get_cookies('https://www.youtube.com/') |         cookies = self._get_cookies('https://www.youtube.com/') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 coletdjnz
					coletdjnz