21 from .common
import InfoExtractor
, SearchInfoExtractor
22 from .openload
import PhantomJSwrapper
23 from ..compat
import functools
24 from ..jsinterp
import JSInterpreter
69 # any clients starting with _ cannot be explicitly requested by the user
72 'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
73 'INNERTUBE_CONTEXT': {
76 'clientVersion': '2.20220801.00.00',
79 'INNERTUBE_CONTEXT_CLIENT_NAME': 1
82 'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
83 'INNERTUBE_CONTEXT': {
85 'clientName': 'WEB_EMBEDDED_PLAYER',
86 'clientVersion': '1.20220731.00.00',
89 'INNERTUBE_CONTEXT_CLIENT_NAME': 56
92 'INNERTUBE_API_KEY': 'AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30',
93 'INNERTUBE_HOST': 'music.youtube.com',
94 'INNERTUBE_CONTEXT': {
96 'clientName': 'WEB_REMIX',
97 'clientVersion': '1.20220727.01.00',
100 'INNERTUBE_CONTEXT_CLIENT_NAME': 67,
103 'INNERTUBE_API_KEY': 'AIzaSyBUPetSUmoZL-OhlxA7wSac5XinrygCqMo',
104 'INNERTUBE_CONTEXT': {
106 'clientName': 'WEB_CREATOR',
107 'clientVersion': '1.20220726.00.00',
110 'INNERTUBE_CONTEXT_CLIENT_NAME': 62,
113 'INNERTUBE_API_KEY': 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w',
114 'INNERTUBE_CONTEXT': {
116 'clientName': 'ANDROID',
117 'clientVersion': '17.31.35',
118 'androidSdkVersion': 30,
119 'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip'
122 'INNERTUBE_CONTEXT_CLIENT_NAME': 3,
123 'REQUIRE_JS_PLAYER': False
125 'android_embedded': {
126 'INNERTUBE_API_KEY': 'AIzaSyCjc_pVEDi4qsv5MtC2dMXzpIaDoRFLsxw',
127 'INNERTUBE_CONTEXT': {
129 'clientName': 'ANDROID_EMBEDDED_PLAYER',
130 'clientVersion': '17.31.35',
131 'androidSdkVersion': 30,
132 'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip'
135 'INNERTUBE_CONTEXT_CLIENT_NAME': 55,
136 'REQUIRE_JS_PLAYER': False
139 'INNERTUBE_API_KEY': 'AIzaSyAOghZGza2MQSZkY_zfZ370N-PUdXEo8AI',
140 'INNERTUBE_CONTEXT': {
142 'clientName': 'ANDROID_MUSIC',
143 'clientVersion': '5.16.51',
144 'androidSdkVersion': 30,
145 'userAgent': 'com.google.android.apps.youtube.music/5.16.51 (Linux; U; Android 11) gzip'
148 'INNERTUBE_CONTEXT_CLIENT_NAME': 21,
149 'REQUIRE_JS_PLAYER': False
152 'INNERTUBE_API_KEY': 'AIzaSyD_qjV8zaaUMehtLkrKFgVeSX_Iqbtyws8',
153 'INNERTUBE_CONTEXT': {
155 'clientName': 'ANDROID_CREATOR',
156 'clientVersion': '22.30.100',
157 'androidSdkVersion': 30,
158 'userAgent': 'com.google.android.apps.youtube.creator/22.30.100 (Linux; U; Android 11) gzip'
161 'INNERTUBE_CONTEXT_CLIENT_NAME': 14,
162 'REQUIRE_JS_PLAYER': False
164 # iOS clients have HLS live streams. Setting device model to get 60fps formats.
165 # See: https://github.com/TeamNewPipe/NewPipeExtractor/issues/680#issuecomment-1002724558
167 'INNERTUBE_API_KEY': 'AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc',
168 'INNERTUBE_CONTEXT': {
171 'clientVersion': '17.33.2',
172 'deviceModel': 'iPhone14,3',
173 'userAgent': 'com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
176 'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
177 'REQUIRE_JS_PLAYER': False
180 'INNERTUBE_CONTEXT': {
182 'clientName': 'IOS_MESSAGES_EXTENSION',
183 'clientVersion': '17.33.2',
184 'deviceModel': 'iPhone14,3',
185 'userAgent': 'com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
188 'INNERTUBE_CONTEXT_CLIENT_NAME': 66,
189 'REQUIRE_JS_PLAYER': False
192 'INNERTUBE_API_KEY': 'AIzaSyBAETezhkwP0ZWA02RsqT1zu78Fpt0bC_s',
193 'INNERTUBE_CONTEXT': {
195 'clientName': 'IOS_MUSIC',
196 'clientVersion': '5.21',
197 'deviceModel': 'iPhone14,3',
198 'userAgent': 'com.google.ios.youtubemusic/5.21 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
201 'INNERTUBE_CONTEXT_CLIENT_NAME': 26,
202 'REQUIRE_JS_PLAYER': False
205 'INNERTUBE_CONTEXT': {
207 'clientName': 'IOS_CREATOR',
208 'clientVersion': '22.33.101',
209 'deviceModel': 'iPhone14,3',
210 'userAgent': 'com.google.ios.ytcreator/22.33.101 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
213 'INNERTUBE_CONTEXT_CLIENT_NAME': 15,
214 'REQUIRE_JS_PLAYER': False
216 # mweb has 'ultralow' formats
217 # See: https://github.com/yt-dlp/yt-dlp/pull/557
219 'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
220 'INNERTUBE_CONTEXT': {
222 'clientName': 'MWEB',
223 'clientVersion': '2.20220801.00.00',
226 'INNERTUBE_CONTEXT_CLIENT_NAME': 2
228 # This client can access age restricted videos (unless the uploader has disabled the 'allow embedding' option)
229 # See: https://github.com/zerodytrash/YouTube-Internal-Clients
231 'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
232 'INNERTUBE_CONTEXT': {
234 'clientName': 'TVHTML5_SIMPLY_EMBEDDED_PLAYER',
235 'clientVersion': '2.0',
238 'INNERTUBE_CONTEXT_CLIENT_NAME': 85
243 def _split_innertube_client(client_name
):
244 variant
, *base
= client_name
.rsplit('.', 1)
246 return variant
, base
[0], variant
247 base
, *variant
= client_name
.split('_', 1)
248 return client_name
, base
, variant
[0] if variant
else None
251 def build_innertube_clients():
253 'embedUrl': 'https://www.youtube.com/', # Can be any valid URL
255 BASE_CLIENTS
= ('android', 'web', 'tv', 'ios', 'mweb')
256 priority
= qualities(BASE_CLIENTS
[::-1])
258 for client
, ytcfg
in tuple(INNERTUBE_CLIENTS
.items()):
259 ytcfg
.setdefault('INNERTUBE_API_KEY', 'AIzaSyDCU8hByM-4DrUqRUYnGn-3llEO78bcxq8')
260 ytcfg
.setdefault('INNERTUBE_HOST', 'www.youtube.com')
261 ytcfg
.setdefault('REQUIRE_JS_PLAYER', True)
262 ytcfg
['INNERTUBE_CONTEXT']['client'].setdefault('hl', 'en')
264 _
, base_client
, variant
= _split_innertube_client(client
)
265 ytcfg
['priority'] = 10 * priority(base_client
)
268 INNERTUBE_CLIENTS
[f
'{client}_embedscreen'] = embedscreen
= copy
.deepcopy(ytcfg
)
269 embedscreen
['INNERTUBE_CONTEXT']['client']['clientScreen'] = 'EMBED'
270 embedscreen
['INNERTUBE_CONTEXT']['thirdParty'] = THIRD_PARTY
271 embedscreen
['priority'] -= 3
272 elif variant
== 'embedded':
273 ytcfg
['INNERTUBE_CONTEXT']['thirdParty'] = THIRD_PARTY
274 ytcfg
['priority'] -= 2
276 ytcfg
['priority'] -= 3
279 build_innertube_clients()
282 class BadgeType(enum
.Enum
):
283 AVAILABILITY_UNLISTED
= enum
.auto()
284 AVAILABILITY_PRIVATE
= enum
.auto()
285 AVAILABILITY_PUBLIC
= enum
.auto()
286 AVAILABILITY_PREMIUM
= enum
.auto()
287 AVAILABILITY_SUBSCRIPTION
= enum
.auto()
288 LIVE_NOW
= enum
.auto()
291 class YoutubeBaseInfoExtractor(InfoExtractor
):
292 """Provide base functions for Youtube extractors"""
295 r
'channel|c|user|playlist|watch|w|v|embed|e|live|watch_popup|clip|'
296 r
'shorts|movies|results|search|shared|hashtag|trending|explore|feed|feeds|'
297 r
'browse|oembed|get_video_info|iframe_api|s/player|source|'
298 r
'storefront|oops|index|account|t/terms|about|upload|signin|logout')
300 _PLAYLIST_ID_RE
= r
'(?:(?:PL|LL|EC|UU|FL|RD|UL|TL|PU|OLAK5uy_)[0-9A-Za-z-_]{10,}|RDMM|WL|LL|LM)'
302 # _NETRC_MACHINE = 'youtube'
304 # If True it will raise an error if no login info is provided
305 _LOGIN_REQUIRED
= False
308 # invidious-redirect websites
309 r
'(?:www\.)?redirect\.invidious\.io',
310 r
'(?:(?:www|dev)\.)?invidio\.us',
311 # Invidious instances taken from https://github.com/iv-org/documentation/blob/master/docs/instances.md
312 r
'(?:www\.)?invidious\.pussthecat\.org',
313 r
'(?:www\.)?invidious\.zee\.li',
314 r
'(?:www\.)?invidious\.ethibox\.fr',
315 r
'(?:www\.)?iv\.ggtyler\.dev',
316 r
'(?:www\.)?inv\.vern\.i2p',
317 r
'(?:www\.)?am74vkcrjp2d5v36lcdqgsj2m6x36tbrkhsruoegwfcizzabnfgf5zyd\.onion',
318 r
'(?:www\.)?inv\.riverside\.rocks',
319 r
'(?:www\.)?invidious\.silur\.me',
320 r
'(?:www\.)?inv\.bp\.projectsegfau\.lt',
321 r
'(?:www\.)?invidious\.g4c3eya4clenolymqbpgwz3q3tawoxw56yhzk4vugqrl6dtu3ejvhjid\.onion',
322 r
'(?:www\.)?invidious\.slipfox\.xyz',
323 r
'(?:www\.)?invidious\.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd\.onion',
324 r
'(?:www\.)?inv\.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad\.onion',
325 r
'(?:www\.)?invidious\.tiekoetter\.com',
326 r
'(?:www\.)?iv\.odysfvr23q5wgt7i456o5t3trw2cw5dgn56vbjfbq2m7xsc5vqbqpcyd\.onion',
327 r
'(?:www\.)?invidious\.nerdvpn\.de',
328 r
'(?:www\.)?invidious\.weblibre\.org',
329 r
'(?:www\.)?inv\.odyssey346\.dev',
330 r
'(?:www\.)?invidious\.dhusch\.de',
331 r
'(?:www\.)?iv\.melmac\.space',
332 r
'(?:www\.)?watch\.thekitty\.zone',
333 r
'(?:www\.)?invidious\.privacydev\.net',
334 r
'(?:www\.)?ng27owmagn5amdm7l5s3rsqxwscl5ynppnis5dqcasogkyxcfqn7psid\.onion',
335 r
'(?:www\.)?invidious\.drivet\.xyz',
336 r
'(?:www\.)?vid\.priv\.au',
337 r
'(?:www\.)?euxxcnhsynwmfidvhjf6uzptsmh4dipkmgdmcmxxuo7tunp3ad2jrwyd\.onion',
338 r
'(?:www\.)?inv\.vern\.cc',
339 r
'(?:www\.)?invidious\.esmailelbob\.xyz',
340 r
'(?:www\.)?invidious\.sethforprivacy\.com',
341 r
'(?:www\.)?yt\.oelrichsgarcia\.de',
342 r
'(?:www\.)?yt\.artemislena\.eu',
343 r
'(?:www\.)?invidious\.flokinet\.to',
344 r
'(?:www\.)?invidious\.baczek\.me',
345 r
'(?:www\.)?y\.com\.sb',
346 r
'(?:www\.)?invidious\.epicsite\.xyz',
347 r
'(?:www\.)?invidious\.lidarshield\.cloud',
348 r
'(?:www\.)?yt\.funami\.tech',
349 r
'(?:www\.)?invidious\.3o7z6yfxhbw7n3za4rss6l434kmv55cgw2vuziwuigpwegswvwzqipyd\.onion',
350 r
'(?:www\.)?osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd\.onion',
351 r
'(?:www\.)?u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad\.onion',
352 # youtube-dl invidious instances list
353 r
'(?:(?:www|no)\.)?invidiou\.sh',
354 r
'(?:(?:www|fi)\.)?invidious\.snopyta\.org',
355 r
'(?:www\.)?invidious\.kabi\.tk',
356 r
'(?:www\.)?invidious\.mastodon\.host',
357 r
'(?:www\.)?invidious\.zapashcanon\.fr',
358 r
'(?:www\.)?(?:invidious(?:-us)?|piped)\.kavin\.rocks',
359 r
'(?:www\.)?invidious\.tinfoil-hat\.net',
360 r
'(?:www\.)?invidious\.himiko\.cloud',
361 r
'(?:www\.)?invidious\.reallyancient\.tech',
362 r
'(?:www\.)?invidious\.tube',
363 r
'(?:www\.)?invidiou\.site',
364 r
'(?:www\.)?invidious\.site',
365 r
'(?:www\.)?invidious\.xyz',
366 r
'(?:www\.)?invidious\.nixnet\.xyz',
367 r
'(?:www\.)?invidious\.048596\.xyz',
368 r
'(?:www\.)?invidious\.drycat\.fr',
369 r
'(?:www\.)?inv\.skyn3t\.in',
370 r
'(?:www\.)?tube\.poal\.co',
371 r
'(?:www\.)?tube\.connect\.cafe',
372 r
'(?:www\.)?vid\.wxzm\.sx',
373 r
'(?:www\.)?vid\.mint\.lgbt',
374 r
'(?:www\.)?vid\.puffyan\.us',
375 r
'(?:www\.)?yewtu\.be',
376 r
'(?:www\.)?yt\.elukerio\.org',
377 r
'(?:www\.)?yt\.lelux\.fi',
378 r
'(?:www\.)?invidious\.ggc-project\.de',
379 r
'(?:www\.)?yt\.maisputain\.ovh',
380 r
'(?:www\.)?ytprivate\.com',
381 r
'(?:www\.)?invidious\.13ad\.de',
382 r
'(?:www\.)?invidious\.toot\.koeln',
383 r
'(?:www\.)?invidious\.fdn\.fr',
384 r
'(?:www\.)?watch\.nettohikari\.com',
385 r
'(?:www\.)?invidious\.namazso\.eu',
386 r
'(?:www\.)?invidious\.silkky\.cloud',
387 r
'(?:www\.)?invidious\.exonip\.de',
388 r
'(?:www\.)?invidious\.riverside\.rocks',
389 r
'(?:www\.)?invidious\.blamefran\.net',
390 r
'(?:www\.)?invidious\.moomoo\.de',
391 r
'(?:www\.)?ytb\.trom\.tf',
392 r
'(?:www\.)?yt\.cyberhost\.uk',
393 r
'(?:www\.)?kgg2m7yk5aybusll\.onion',
394 r
'(?:www\.)?qklhadlycap4cnod\.onion',
395 r
'(?:www\.)?axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid\.onion',
396 r
'(?:www\.)?c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid\.onion',
397 r
'(?:www\.)?fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad\.onion',
398 r
'(?:www\.)?invidious\.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd\.onion',
399 r
'(?:www\.)?owxfohz4kjyv25fvlqilyxast7inivgiktls3th44jhk3ej3i7ya\.b32\.i2p',
400 r
'(?:www\.)?4l2dgddgsrkf2ous66i6seeyi6etzfgrue332grh2n7madpwopotugyd\.onion',
401 r
'(?:www\.)?w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd\.onion',
402 r
'(?:www\.)?kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad\.onion',
403 r
'(?:www\.)?grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad\.onion',
404 r
'(?:www\.)?hpniueoejy4opn7bc4ftgazyqjoeqwlvh2uiku2xqku6zpoa4bf5ruid\.onion',
405 # piped instances from https://github.com/TeamPiped/Piped/wiki/Instances
406 r
'(?:www\.)?piped\.kavin\.rocks',
407 r
'(?:www\.)?piped\.tokhmi\.xyz',
408 r
'(?:www\.)?piped\.syncpundit\.io',
409 r
'(?:www\.)?piped\.mha\.fi',
410 r
'(?:www\.)?watch\.whatever\.social',
411 r
'(?:www\.)?piped\.garudalinux\.org',
412 r
'(?:www\.)?piped\.rivo\.lol',
413 r
'(?:www\.)?piped-libre\.kavin\.rocks',
414 r
'(?:www\.)?yt\.jae\.fi',
415 r
'(?:www\.)?piped\.mint\.lgbt',
417 r
'(?:www\.)?piped\.esmailelbob\.xyz',
418 r
'(?:www\.)?piped\.projectsegfau\.lt',
419 r
'(?:www\.)?piped\.privacydev\.net',
420 r
'(?:www\.)?piped\.palveluntarjoaja\.eu',
421 r
'(?:www\.)?piped\.smnz\.de',
422 r
'(?:www\.)?piped\.adminforge\.de',
423 r
'(?:www\.)?watch\.whatevertinfoil\.de',
424 r
'(?:www\.)?piped\.qdi\.fi',
425 r
'(?:www\.)?piped\.video',
426 r
'(?:www\.)?piped\.aeong\.one',
427 r
'(?:www\.)?piped\.moomoo\.me',
428 r
'(?:www\.)?piped\.chauvet\.pro',
429 r
'(?:www\.)?watch\.leptons\.xyz',
430 r
'(?:www\.)?pd\.vern\.cc',
431 r
'(?:www\.)?piped\.hostux\.net',
432 r
'(?:www\.)?piped\.lunar\.icu',
433 # Hyperpipe instances from https://hyperpipe.codeberg.page/
434 r
'(?:www\.)?hyperpipe\.surge\.sh',
435 r
'(?:www\.)?hyperpipe\.esmailelbob\.xyz',
436 r
'(?:www\.)?listen\.whatever\.social',
437 r
'(?:www\.)?music\.adminforge\.de',
440 # extracted from account/account_menu ep
441 # XXX: These are the supported YouTube UI and API languages,
442 # which is slightly different from languages supported for translation in YouTube studio
443 _SUPPORTED_LANG_CODES
= [
444 'af', 'az', 'id', 'ms', 'bs', 'ca', 'cs', 'da', 'de', 'et', 'en-IN', 'en-GB', 'en', 'es',
445 'es-419', 'es-US', 'eu', 'fil', 'fr', 'fr-CA', 'gl', 'hr', 'zu', 'is', 'it', 'sw', 'lv',
446 'lt', 'hu', 'nl', 'no', 'uz', 'pl', 'pt-PT', 'pt', 'ro', 'sq', 'sk', 'sl', 'sr-Latn', 'fi',
447 'sv', 'vi', 'tr', 'be', 'bg', 'ky', 'kk', 'mk', 'mn', 'ru', 'sr', 'uk', 'el', 'hy', 'iw',
448 'ur', 'ar', 'fa', 'ne', 'mr', 'hi', 'as', 'bn', 'pa', 'gu', 'or', 'ta', 'te', 'kn', 'ml',
449 'si', 'th', 'lo', 'my', 'ka', 'am', 'km', 'zh-CN', 'zh-TW', 'zh-HK', 'ja', 'ko'
452 _IGNORED_WARNINGS
= {'Unavailable videos will be hidden during playback'}
454 @functools.cached_property
455 def _preferred_lang(self
):
457 Returns a language code supported by YouTube for the user preferred language.
458 Returns None if no preferred language set.
460 preferred_lang
= self
._configuration
_arg
('lang', ie_key
='Youtube', casesense
=True, default
=[''])[0]
461 if not preferred_lang
:
463 if preferred_lang
not in self
._SUPPORTED
_LANG
_CODES
:
464 raise ExtractorError(
465 f
'Unsupported language code: {preferred_lang}. Supported language codes (case-sensitive): {join_nonempty(*self._SUPPORTED_LANG_CODES, delim=", ")}.',
467 elif preferred_lang
!= 'en':
469 f
'Preferring "{preferred_lang}" translated fields. Note that some metadata extraction may fail or be incorrect.')
470 return preferred_lang
472 def _initialize_consent(self
):
473 cookies
= self
._get
_cookies
('https://www.youtube.com/')
474 if cookies
.get('__Secure-3PSID'):
477 consent
= cookies
.get('CONSENT')
479 if 'YES' in consent
.value
:
481 consent_id
= self
._search
_regex
(
482 r
'PENDING\+(\d+)', consent
.value
, 'consent', default
=None)
484 consent_id
= random
.randint(100, 999)
485 self
._set
_cookie
('.youtube.com', 'CONSENT', 'YES+cb.20210328-17-p0.en+FX+%s' % consent_id
)
487 def _initialize_pref(self
):
488 cookies
= self
._get
_cookies
('https://www.youtube.com/')
489 pref_cookie
= cookies
.get('PREF')
493 pref
= dict(urllib
.parse
.parse_qsl(pref_cookie
.value
))
495 self
.report_warning('Failed to parse user PREF cookie' + bug_reports_message())
496 pref
.update({'hl': self._preferred_lang or 'en', 'tz': 'UTC'}
)
497 self
._set
_cookie
('.youtube.com', name
='PREF', value
=urllib
.parse
.urlencode(pref
))
499 def _real_initialize(self
):
500 self
._initialize
_pref
()
501 self
._initialize
_consent
()
502 self
._check
_login
_required
()
504 def _check_login_required(self
):
505 if self
._LOGIN
_REQUIRED
and not self
._cookies
_passed
:
506 self
.raise_login_required('Login details are needed to download this content', method
='cookies')
508 _YT_INITIAL_DATA_RE
= r
'(?:window\s*\[\s*["\']ytInitialData
["\']\s*\]|ytInitialData)\s*='
509 _YT_INITIAL_PLAYER_RESPONSE_RE = r'ytInitialPlayerResponse\s*='
511 def _get_default_ytcfg(self, client='web'):
512 return copy.deepcopy(INNERTUBE_CLIENTS[client])
514 def _get_innertube_host(self, client='web'):
515 return INNERTUBE_CLIENTS[client]['INNERTUBE_HOST']
517 def _ytcfg_get_safe(self, ytcfg, getter, expected_type=None, default_client='web'):
518 # try_get but with fallback to default ytcfg client values when present
519 _func = lambda y: try_get(y, getter, expected_type)
520 return _func(ytcfg) or _func(self._get_default_ytcfg(default_client))
522 def _extract_client_name(self, ytcfg, default_client='web'):
523 return self._ytcfg_get_safe(
524 ytcfg, (lambda x: x['INNERTUBE_CLIENT_NAME'],
525 lambda x: x['INNERTUBE_CONTEXT']['client']['clientName']), str, default_client)
527 def _extract_client_version(self, ytcfg, default_client='web'):
528 return self._ytcfg_get_safe(
529 ytcfg, (lambda x: x['INNERTUBE_CLIENT_VERSION'],
530 lambda x: x['INNERTUBE_CONTEXT']['client']['clientVersion']), str, default_client)
532 def _select_api_hostname(self, req_api_hostname, default_client=None):
533 return (self._configuration_arg('innertube_host', [''], ie_key=YoutubeIE.ie_key())[0]
534 or req_api_hostname or self._get_innertube_host(default_client or 'web'))
536 def _extract_api_key(self, ytcfg=None, default_client='web'):
537 return self._ytcfg_get_safe(ytcfg, lambda x: x['INNERTUBE_API_KEY'], str, default_client)
539 def _extract_context(self, ytcfg=None, default_client='web'):
541 (ytcfg, self._get_default_ytcfg(default_client)), 'INNERTUBE_CONTEXT', expected_type=dict)
542 # Enforce language and tz for extraction
543 client_context = traverse_obj(context, 'client', expected_type=dict, default={})
544 client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
549 def _generate_sapisidhash_header(self, origin='https://www.youtube.com'):
550 time_now = round(time.time())
551 if self._SAPISID is None:
552 yt_cookies = self._get_cookies('https://www.youtube.com')
553 # Sometimes SAPISID cookie isn't present but __Secure-3PAPISID is.
554 # See: https://github.com/yt-dlp/yt-dlp/issues/393
555 sapisid_cookie = dict_get(
556 yt_cookies, ('__Secure-3PAPISID', 'SAPISID'))
557 if sapisid_cookie and sapisid_cookie.value:
558 self._SAPISID = sapisid_cookie.value
559 self.write_debug('Extracted SAPISID cookie')
560 # SAPISID cookie is required if not already present
561 if not yt_cookies.get('SAPISID'):
562 self.write_debug('Copying __Secure-3PAPISID cookie to SAPISID cookie')
564 '.youtube.com', 'SAPISID', self._SAPISID, secure=True, expire_time=time_now + 3600)
566 self._SAPISID = False
567 if not self._SAPISID:
569 # SAPISIDHASH algorithm from https://stackoverflow.com/a/32065323
570 sapisidhash = hashlib.sha1(
571 f'{time_now} {self._SAPISID} {origin}'.encode()).hexdigest()
572 return f'SAPISIDHASH {time_now}_{sapisidhash}'
574 def _call_api(self, ep, query, video_id, fatal=True, headers=None,
575 note='Downloading API JSON', errnote='Unable to download API page',
576 context=None, api_key=None, api_hostname=None, default_client='web'):
578 data = {'context': context} if context else {'context': self._extract_context(default_client=default_client)}
580 real_headers = self.generate_api_headers(default_client=default_client)
581 real_headers.update({'content-type': 'application/json'})
583 real_headers.update(headers)
584 api_key = (self._configuration_arg('innertube_key', [''], ie_key=YoutubeIE.ie_key(), casesense=True)[0]
585 or api_key or self._extract_api_key(default_client=default_client))
586 return self._download_json(
587 f'https://{self._select_api_hostname(api_hostname, default_client)}/youtubei/v1/{ep}',
588 video_id=video_id, fatal=fatal, note=note, errnote=errnote,
589 data=json.dumps(data).encode('utf8'), headers=real_headers,
590 query={'key': api_key, 'prettyPrint': 'false'})
592 def extract_yt_initial_data(self, item_id, webpage, fatal=True):
593 return self._search_json(self._YT_INITIAL_DATA_RE, webpage, 'yt initial data', item_id, fatal=fatal)
596 def _extract_session_index(*data):
598 Index of current account in account list.
599 See: https://github.com/yt-dlp/yt-dlp/pull/519
602 session_index = int_or_none(try_get(ytcfg, lambda x: x['SESSION_INDEX']))
603 if session_index is not None:
607 def _extract_identity_token(self, ytcfg=None, webpage=None):
609 token = try_get(ytcfg, lambda x: x['ID_TOKEN'], str)
613 return self._search_regex(
614 r'\bID_TOKEN["\']\s
*:\s
*["\'](.+?)["\']', webpage,
615 'identity token
', default=None, fatal=False)
618 def _extract_account_syncid(*args):
620 Extract syncId required to download private playlists of secondary channels
621 @params response and/or ytcfg
624 # ytcfg includes channel_syncid if on secondary channel
625 delegated_sid = try_get(data, lambda x: x['DELEGATED_SESSION_ID
'], str)
629 data, (lambda x: x['responseContext
']['mainAppWebResponseContext
']['datasyncId
'],
630 lambda x: x['DATASYNC_ID
']), str) or '').split('||
')
631 if len(sync_ids) >= 2 and sync_ids[1]:
632 # datasyncid is of the form "channel_syncid||user_syncid" for secondary channel
633 # and just "user_syncid||" for primary channel. We only want the channel_syncid
637 def _extract_visitor_data(*args):
639 Extracts visitorData from an API response or ytcfg
640 Appears to be used to track session state
643 args, [('VISITOR_DATA
', ('INNERTUBE_CONTEXT
', 'client
', 'visitorData
'), ('responseContext
', 'visitorData
'))],
646 @functools.cached_property
647 def is_authenticated(self):
648 return bool(self._generate_sapisidhash_header())
650 def extract_ytcfg(self, video_id, webpage):
653 return self._parse_json(
655 r'ytcfg\
.set\s
*\
(\s
*({.+?}
)\s
*\
)\s
*;', webpage, 'ytcfg
',
656 default='{}'), video_id, fatal=False) or {}
658 def generate_api_headers(
659 self
, *, ytcfg
=None, account_syncid
=None, session_index
=None,
660 visitor_data
=None, identity_token
=None, api_hostname
=None, default_client
='web'):
662 origin
= 'https://' + (self
._select
_api
_hostname
(api_hostname
, default_client
))
664 'X-YouTube-Client-Name': str(
665 self
._ytcfg
_get
_safe
(ytcfg
, lambda x
: x
['INNERTUBE_CONTEXT_CLIENT_NAME'], default_client
=default_client
)),
666 'X-YouTube-Client-Version': self
._extract
_client
_version
(ytcfg
, default_client
),
668 'X-Youtube-Identity-Token': identity_token
or self
._extract
_identity
_token
(ytcfg
),
669 'X-Goog-PageId': account_syncid
or self
._extract
_account
_syncid
(ytcfg
),
670 'X-Goog-Visitor-Id': visitor_data
or self
._extract
_visitor
_data
(ytcfg
),
671 'User-Agent': self
._ytcfg
_get
_safe
(ytcfg
, lambda x
: x
['INNERTUBE_CONTEXT']['client']['userAgent'], default_client
=default_client
)
673 if session_index
is None:
674 session_index
= self
._extract
_session
_index
(ytcfg
)
675 if account_syncid
or session_index
is not None:
676 headers
['X-Goog-AuthUser'] = session_index
if session_index
is not None else 0
678 auth
= self
._generate
_sapisidhash
_header
(origin
)
680 headers
['Authorization'] = auth
681 headers
['X-Origin'] = origin
682 return filter_dict(headers
)
684 def _download_ytcfg(self
, client
, video_id
):
686 'web': 'https://www.youtube.com',
687 'web_music': 'https://music.youtube.com',
688 'web_embedded': f
'https://www.youtube.com/embed/{video_id}?html5=1'
692 webpage
= self
._download
_webpage
(
693 url
, video_id
, fatal
=False, note
=f
'Downloading {client.replace("_", " ").strip()} client config')
694 return self
.extract_ytcfg(video_id
, webpage
) or {}
697 def _build_api_continuation_query(continuation
, ctp
=None):
699 'continuation': continuation
701 # TODO: Inconsistency with clickTrackingParams.
702 # Currently we have a fixed ctp contained within context (from ytcfg)
703 # and a ctp in root query for continuation.
705 query
['clickTracking'] = {'clickTrackingParams': ctp}
709 def _extract_next_continuation_data(cls
, renderer
):
710 next_continuation
= try_get(
711 renderer
, (lambda x
: x
['continuations'][0]['nextContinuationData'],
712 lambda x
: x
['continuation']['reloadContinuationData']), dict)
713 if not next_continuation
:
715 continuation
= next_continuation
.get('continuation')
718 ctp
= next_continuation
.get('clickTrackingParams')
719 return cls
._build
_api
_continuation
_query
(continuation
, ctp
)
722 def _extract_continuation_ep_data(cls
, continuation_ep
: dict):
723 if isinstance(continuation_ep
, dict):
724 continuation
= try_get(
725 continuation_ep
, lambda x
: x
['continuationCommand']['token'], str)
728 ctp
= continuation_ep
.get('clickTrackingParams')
729 return cls
._build
_api
_continuation
_query
(continuation
, ctp
)
732 def _extract_continuation(cls
, renderer
):
733 next_continuation
= cls
._extract
_next
_continuation
_data
(renderer
)
734 if next_continuation
:
735 return next_continuation
737 return traverse_obj(renderer
, (
738 ('contents', 'items', 'rows'), ..., 'continuationItemRenderer',
739 ('continuationEndpoint', ('button', 'buttonRenderer', 'command'))
740 ), get_all
=False, expected_type
=cls
._extract
_continuation
_ep
_data
)
743 def _extract_alerts(cls
, data
):
744 for alert_dict
in try_get(data
, lambda x
: x
['alerts'], list) or []:
745 if not isinstance(alert_dict
, dict):
747 for alert
in alert_dict
.values():
748 alert_type
= alert
.get('type')
751 message
= cls
._get
_text
(alert
, 'text')
753 yield alert_type
, message
755 def _report_alerts(self
, alerts
, expected
=True, fatal
=True, only_once
=False):
756 errors
, warnings
= [], []
757 for alert_type
, alert_message
in alerts
:
758 if alert_type
.lower() == 'error' and fatal
:
759 errors
.append([alert_type
, alert_message
])
760 elif alert_message
not in self
._IGNORED
_WARNINGS
:
761 warnings
.append([alert_type
, alert_message
])
763 for alert_type
, alert_message
in (warnings
+ errors
[:-1]):
764 self
.report_warning(f
'YouTube said: {alert_type} - {alert_message}', only_once
=only_once
)
766 raise ExtractorError('YouTube said: %s' % errors
[-1][1], expected
=expected
)
768 def _extract_and_report_alerts(self
, data
, *args
, **kwargs
):
769 return self
._report
_alerts
(self
._extract
_alerts
(data
), *args
, **kwargs
)
771 def _extract_badges(self
, renderer
: dict):
773 'PRIVACY_UNLISTED': BadgeType
.AVAILABILITY_UNLISTED
,
774 'PRIVACY_PRIVATE': BadgeType
.AVAILABILITY_PRIVATE
,
775 'PRIVACY_PUBLIC': BadgeType
.AVAILABILITY_PUBLIC
779 'BADGE_STYLE_TYPE_MEMBERS_ONLY': BadgeType
.AVAILABILITY_SUBSCRIPTION
,
780 'BADGE_STYLE_TYPE_PREMIUM': BadgeType
.AVAILABILITY_PREMIUM
,
781 'BADGE_STYLE_TYPE_LIVE_NOW': BadgeType
.LIVE_NOW
785 'unlisted': BadgeType
.AVAILABILITY_UNLISTED
,
786 'private': BadgeType
.AVAILABILITY_PRIVATE
,
787 'members only': BadgeType
.AVAILABILITY_SUBSCRIPTION
,
788 'live': BadgeType
.LIVE_NOW
,
789 'premium': BadgeType
.AVAILABILITY_PREMIUM
793 for badge
in traverse_obj(renderer
, ('badges', ..., 'metadataBadgeRenderer')):
795 privacy_icon_map
.get(traverse_obj(badge
, ('icon', 'iconType'), expected_type
=str))
796 or badge_style_map
.get(traverse_obj(badge
, 'style'))
799 badges
.append({'type': badge_type}
)
802 # fallback, won't work in some languages
803 label
= traverse_obj(badge
, 'label', expected_type
=str, default
='')
804 for match
, label_badge_type
in label_map
.items():
805 if match
in label
.lower():
806 badges
.append({'type': badge_type}
)
812 def _has_badge(badges
, badge_type
):
813 return bool(traverse_obj(badges
, lambda _
, v
: v
['type'] == badge_type
))
816 def _get_text(data
, *path_list
, max_runs
=None):
817 for path
in path_list
or [None]:
821 obj
= traverse_obj(data
, path
, default
=[])
822 if not any(key
is ... or isinstance(key
, (list, tuple)) for key
in variadic(path
)):
825 text
= try_get(item
, lambda x
: x
['simpleText'], str)
828 runs
= try_get(item
, lambda x
: x
['runs'], list) or []
829 if not runs
and isinstance(item
, list):
832 runs
= runs
[:min(len(runs
), max_runs
or len(runs
))]
833 text
= ''.join(traverse_obj(runs
, (..., 'text'), expected_type
=str))
837 def _get_count(self
, data
, *path_list
):
838 count_text
= self
._get
_text
(data
, *path_list
) or ''
839 count
= parse_count(count_text
)
842 self
._search
_regex
(r
'^([\d,]+)', re
.sub(r
'\s', '', count_text
), 'count', default
=None))
846 def _extract_thumbnails(data
, *path_list
):
848 Extract thumbnails from thumbnails dict
849 @param path_list: path list to level that contains 'thumbnails' key
852 for path
in path_list
or [()]:
853 for thumbnail
in traverse_obj(data
, (*variadic(path
), 'thumbnails', ...)):
854 thumbnail_url
= url_or_none(thumbnail
.get('url'))
855 if not thumbnail_url
:
857 # Sometimes youtube gives a wrong thumbnail URL. See:
858 # https://github.com/yt-dlp/yt-dlp/issues/233
859 # https://github.com/ytdl-org/youtube-dl/issues/28023
860 if 'maxresdefault' in thumbnail_url
:
861 thumbnail_url
= thumbnail_url
.split('?')[0]
863 'url': thumbnail_url
,
864 'height': int_or_none(thumbnail
.get('height')),
865 'width': int_or_none(thumbnail
.get('width')),
870 def extract_relative_time(relative_time_text
):
872 Extracts a relative time from string and converts to dt object
873 e.g. 'streamed 6 days ago', '5 seconds ago (edited)', 'updated today'
875 mobj
= re
.search(r
'(?P<start>today|yesterday|now)|(?P<time>\d+)\s*(?P<unit>microsecond|second|minute|hour|day|week|month|year)s?\s*ago', relative_time_text
)
877 start
= mobj
.group('start')
879 return datetime_from_str(start
)
881 return datetime_from_str('now-%s%s' % (mobj
.group('time'), mobj
.group('unit')))
885 def _parse_time_text(self
, text
):
888 dt
= self
.extract_relative_time(text
)
890 if isinstance(dt
, datetime
.datetime
):
891 timestamp
= calendar
.timegm(dt
.timetuple())
893 if timestamp
is None:
895 unified_timestamp(text
) or unified_timestamp(
897 (r
'([a-z]+\s*\d{1,2},?\s*20\d{2})', r
'(?:.+|^)(?:live|premieres|ed|ing)(?:\s*(?:on|for))?\s*(.+\d)'),
898 text
.lower(), 'time text', default
=None)))
900 if text
and timestamp
is None and self
._preferred
_lang
in (None, 'en'):
902 f
'Cannot parse localized time text "{text}"', only_once
=True)
905 def _extract_response(self
, item_id
, query
, note
='Downloading API JSON', headers
=None,
906 ytcfg
=None, check_get_keys
=None, ep
='browse', fatal
=True, api_hostname
=None,
907 default_client
='web'):
908 for retry
in self
.RetryManager():
910 response
= self
._call
_api
(
911 ep
=ep
, fatal
=True, headers
=headers
,
912 video_id
=item_id
, query
=query
, note
=note
,
913 context
=self
._extract
_context
(ytcfg
, default_client
),
914 api_key
=self
._extract
_api
_key
(ytcfg
, default_client
),
915 api_hostname
=api_hostname
, default_client
=default_client
)
916 except ExtractorError
as e
:
917 if not isinstance(e
.cause
, network_exceptions
):
918 return self
._error
_or
_warning
(e
, fatal
=fatal
)
919 elif not isinstance(e
.cause
, urllib
.error
.HTTPError
):
923 first_bytes
= e
.cause
.read(512)
924 if not is_html(first_bytes
):
927 self
._webpage
_read
_content
(e
.cause
, None, item_id
, prefix
=first_bytes
) or '{}', item_id
, fatal
=False),
928 lambda x
: x
['error']['message'], str)
930 self
._report
_alerts
([('ERROR', yt_error
)], fatal
=False)
931 # Downloading page may result in intermittent 5xx HTTP error
932 # Sometimes a 404 is also recieved. See: https://github.com/ytdl-org/youtube-dl/issues/28289
933 # We also want to catch all other network exceptions since errors in later pages can be troublesome
934 # See https://github.com/yt-dlp/yt-dlp/issues/507#issuecomment-880188210
935 if e
.cause
.code
not in (403, 429):
938 return self
._error
_or
_warning
(e
, fatal
=fatal
)
941 self
._extract
_and
_report
_alerts
(response
, only_once
=True)
942 except ExtractorError
as e
:
943 # YouTube servers may return errors we want to retry on in a 200 OK response
944 # See: https://github.com/yt-dlp/yt-dlp/issues/839
945 if 'unknown error' in e
.msg
.lower():
948 return self
._error
_or
_warning
(e
, fatal
=fatal
)
949 # Youtube sometimes sends incomplete data
950 # See: https://github.com/ytdl-org/youtube-dl/issues/28194
951 if not traverse_obj(response
, *variadic(check_get_keys
)):
952 retry
.error
= ExtractorError('Incomplete data received', expected
=True)
958 def is_music_url(url
):
959 return re
.match(r
'(https?://)?music\.youtube\.com/', url
) is not None
961 def _extract_video(self
, renderer
):
962 video_id
= renderer
.get('videoId')
964 reel_header_renderer
= traverse_obj(renderer
, (
965 'navigationEndpoint', 'reelWatchEndpoint', 'overlay', 'reelPlayerOverlayRenderer',
966 'reelPlayerHeaderSupportedRenderers', 'reelPlayerHeaderRenderer'))
968 title
= self
._get
_text
(renderer
, 'title', 'headline') or self
._get
_text
(reel_header_renderer
, 'reelTitleText')
969 description
= self
._get
_text
(renderer
, 'descriptionSnippet')
971 duration
= int_or_none(renderer
.get('lengthSeconds'))
973 duration
= parse_duration(self
._get
_text
(
974 renderer
, 'lengthText', ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'text')))
976 # XXX: should write a parser to be more general to support more cases (e.g. shorts in shorts tab)
977 duration
= parse_duration(self
._search
_regex
(
978 r
'(?i)(ago)(?!.*\1)\s+(?P<duration>[a-z0-9 ,]+?)(?:\s+[\d,]+\s+views)?(?:\s+-\s+play\s+short)?$',
979 traverse_obj(renderer
, ('title', 'accessibility', 'accessibilityData', 'label'), default
='', expected_type
=str),
980 video_id
, default
=None, group
='duration'))
982 channel_id
= traverse_obj(
983 renderer
, ('shortBylineText', 'runs', ..., 'navigationEndpoint', 'browseEndpoint', 'browseId'),
984 expected_type
=str, get_all
=False)
986 channel_id
= traverse_obj(reel_header_renderer
, ('channelNavigationEndpoint', 'browseEndpoint', 'browseId'))
988 overlay_style
= traverse_obj(
989 renderer
, ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'style'),
990 get_all
=False, expected_type
=str)
991 badges
= self
._extract
_badges
(renderer
)
993 navigation_url
= urljoin('https://www.youtube.com/', traverse_obj(
994 renderer
, ('navigationEndpoint', 'commandMetadata', 'webCommandMetadata', 'url'),
995 expected_type
=str)) or ''
996 url
= f
'https://www.youtube.com/watch?v={video_id}'
997 if overlay_style
== 'SHORTS' or '/shorts/' in navigation_url
:
998 url
= f
'https://www.youtube.com/shorts/{video_id}'
1000 time_text
= (self
._get
_text
(renderer
, 'publishedTimeText', 'videoInfo')
1001 or self
._get
_text
(reel_header_renderer
, 'timestampText') or '')
1002 scheduled_timestamp
= str_to_int(traverse_obj(renderer
, ('upcomingEventData', 'startTime'), get_all
=False))
1005 'is_upcoming' if scheduled_timestamp
is not None
1006 else 'was_live' if 'streamed' in time_text
.lower()
1007 else 'is_live' if overlay_style
== 'LIVE' or self
._has
_badge
(badges
, BadgeType
.LIVE_NOW
)
1010 # videoInfo is a string like '50K views • 10 years ago'.
1011 view_count_text
= self
._get
_text
(renderer
, 'viewCountText', 'shortViewCountText', 'videoInfo') or ''
1012 view_count
= (0 if 'no views' in view_count_text
.lower()
1013 else self
._get
_count
({'simpleText': view_count_text}
))
1014 view_count_field
= 'concurrent_view_count' if live_status
in ('is_live', 'is_upcoming') else 'view_count'
1018 'ie_key': YoutubeIE
.ie_key(),
1022 'description': description
,
1023 'duration': duration
,
1024 'channel_id': channel_id
,
1025 'channel': (self
._get
_text
(renderer
, 'ownerText', 'shortBylineText')
1026 or self
._get
_text
(reel_header_renderer
, 'channelTitleText')),
1027 'channel_url': f
'https://www.youtube.com/channel/{channel_id}' if channel_id
else None,
1028 'thumbnails': self
._extract
_thumbnails
(renderer
, 'thumbnail'),
1029 'timestamp': (self
._parse
_time
_text
(time_text
)
1030 if self
._configuration
_arg
('approximate_date', ie_key
=YoutubeTabIE
)
1032 'release_timestamp': scheduled_timestamp
,
1034 'public' if self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PUBLIC
)
1035 else self
._availability
(
1036 is_private
=self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PRIVATE
) or None,
1037 needs_premium
=self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PREMIUM
) or None,
1038 needs_subscription
=self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_SUBSCRIPTION
) or None,
1039 is_unlisted
=self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_UNLISTED
) or None),
1040 view_count_field
: view_count
,
1041 'live_status': live_status
1045 class YoutubeIE(YoutubeBaseInfoExtractor
):
1047 _VALID_URL
= r
"""(?x)^
1049 (?:https?://|//) # http(s):// or protocol-independent URL
1050 (?:(?:(?:(?:\w+\.)?[yY][oO][uU][tT][uU][bB][eE](?:-nocookie|kids)?\.com|
1051 (?:www\.)?deturl\.com/www\.youtube\.com|
1052 (?:www\.)?pwnyoutube\.com|
1053 (?:www\.)?hooktube\.com|
1054 (?:www\.)?yourepeat\.com|
1055 tube\.majestyc\.net|
1057 youtube\.googleapis\.com)/ # the various hostnames, with wildcard subdomains
1058 (?:.*?\#/)? # handle anchor (#/) redirect urls
1059 (?: # the various things that can precede the ID:
1060 (?:(?:v|embed|e|shorts|live)/(?!videoseries|live_stream)) # v/ or embed/ or e/ or shorts/
1061 |(?: # or the v= param in all its forms
1062 (?:(?:watch|movie)(?:_popup)?(?:\.php)?/?)? # preceding watch(_popup|.php) or nothing (like /?v=xxxx)
1063 (?:\?|\#!?) # the params delimiter ? or # or #!
1064 (?:.*?[&;])?? # any other preceding param (like /?s=tuff&v=xxxx or ?s=tuff&v=V36LpHqtcDY)
1069 youtu\.be| # just youtu.be/xxxx
1070 vid\.plus| # or vid.plus/xxxx
1071 zwearz\.com/watch| # or zwearz.com/watch/xxxx
1074 |(?:www\.)?cleanvideosearch\.com/media/action/yt/watch\?videoId=
1076 )? # all until now is optional -> you can pass the naked ID
1077 (?P<id>[0-9A-Za-z_-]{11}) # here is it! the YouTube video ID
1078 (?(1).+)? # if we found the ID, everything can follow
1080 'invidious': '|'.join(YoutubeBaseInfoExtractor
._INVIDIOUS
_SITES
),
1085 <(?:[0-9A-Za-z-]+?)?iframe[^>]+?src=|
1093 (?P
<url
>(?
:https?
:)?
//(?
:www\
.)?
youtube(?
:-nocookie
)?\
.com
/
1094 (?
:embed|v|p
)/[0-9A
-Za
-z_
-]{11}
.*?
)
1096 # https://wordpress.org/plugins/lazy-load-for-videos/
1098 <a\s
[^
>]*\bhref
="(?P<url>https://www\.youtube\.com/watch\?v=[0-9A-Za-z_-]{11})"
1099 \s
[^
>]*\bclass
="[^"]*\blazy
-load
-youtube
''',
1101 _RETURN_TYPE = 'video' # XXX: How to handle multifeed?
1104 r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})/player',
1105 r'/(?P<id>[a-zA-Z0-9_-]{8,})/player(?:_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?|-plasma-ias-(?:phone|tablet)-[a-z]{2}_[A-Z]{2}\.vflset)/base\.js$',
1106 r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.js$',
1109 '5': {'ext': 'flv', 'width': 400, 'height': 240, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'},
1110 '6': {'ext': 'flv', 'width': 450, 'height': 270, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'},
1111 '13': {'ext': '3gp', 'acodec': 'aac', 'vcodec': 'mp4v'},
1112 '17': {'ext': '3gp', 'width': 176, 'height': 144, 'acodec': 'aac', 'abr': 24, 'vcodec': 'mp4v'},
1113 '18': {'ext': 'mp4', 'width': 640, 'height': 360, 'acodec': 'aac', 'abr': 96, 'vcodec': 'h264'},
1114 '22': {'ext': 'mp4', 'width': 1280, 'height': 720, 'acodec': 'aac', 'abr': 192, 'vcodec': 'h264'},
1115 '34': {'ext': 'flv', 'width': 640, 'height': 360, 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264'},
1116 '35': {'ext': 'flv', 'width': 854, 'height': 480, 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264'},
1117 # itag 36 videos are either 320x180 (BaW_jenozKc) or 320x240 (__2ABJjxzNo), abr varies as well
1118 '36': {'ext': '3gp', 'width': 320, 'acodec': 'aac', 'vcodec': 'mp4v'},
1119 '37': {'ext': 'mp4', 'width': 1920, 'height': 1080, 'acodec': 'aac', 'abr': 192, 'vcodec': 'h264'},
1120 '38': {'ext': 'mp4', 'width': 4096, 'height': 3072, 'acodec': 'aac', 'abr': 192, 'vcodec': 'h264'},
1121 '43': {'ext': 'webm', 'width': 640, 'height': 360, 'acodec': 'vorbis', 'abr': 128, 'vcodec': 'vp8'},
1122 '44': {'ext': 'webm', 'width': 854, 'height': 480, 'acodec': 'vorbis', 'abr': 128, 'vcodec': 'vp8'},
1123 '45': {'ext': 'webm', 'width': 1280, 'height': 720, 'acodec': 'vorbis', 'abr': 192, 'vcodec': 'vp8'},
1124 '46': {'ext': 'webm', 'width': 1920, 'height': 1080, 'acodec': 'vorbis', 'abr': 192, 'vcodec': 'vp8'},
1125 '59': {'ext': 'mp4', 'width': 854, 'height': 480, 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264'},
1126 '78': {'ext': 'mp4', 'width': 854, 'height': 480, 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264'},
1130 '82': {'ext': 'mp4', 'height': 360, 'format_note': '3D', 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264', 'preference': -20},
1131 '83': {'ext': 'mp4', 'height': 480, 'format_note': '3D', 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264', 'preference': -20},
1132 '84': {'ext': 'mp4', 'height': 720, 'format_note': '3D', 'acodec': 'aac', 'abr': 192, 'vcodec': 'h264', 'preference': -20},
1133 '85': {'ext': 'mp4', 'height': 1080, 'format_note': '3D', 'acodec': 'aac', 'abr': 192, 'vcodec': 'h264', 'preference': -20},
1134 '100': {'ext': 'webm', 'height': 360, 'format_note': '3D', 'acodec': 'vorbis', 'abr': 128, 'vcodec': 'vp8', 'preference': -20},
1135 '101': {'ext': 'webm', 'height': 480, 'format_note': '3D', 'acodec': 'vorbis', 'abr': 192, 'vcodec': 'vp8', 'preference': -20},
1136 '102': {'ext': 'webm', 'height': 720, 'format_note': '3D', 'acodec': 'vorbis', 'abr': 192, 'vcodec': 'vp8', 'preference': -20},
1138 # Apple HTTP Live Streaming
1139 '91': {'ext': 'mp4', 'height': 144, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 48, 'vcodec': 'h264', 'preference': -10},
1140 '92': {'ext': 'mp4', 'height': 240, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 48, 'vcodec': 'h264', 'preference': -10},
1141 '93': {'ext': 'mp4', 'height': 360, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264', 'preference': -10},
1142 '94': {'ext': 'mp4', 'height': 480, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 128, 'vcodec': 'h264', 'preference': -10},
1143 '95': {'ext': 'mp4', 'height': 720, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 256, 'vcodec': 'h264', 'preference': -10},
1144 '96': {'ext': 'mp4', 'height': 1080, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 256, 'vcodec': 'h264', 'preference': -10},
1145 '132': {'ext': 'mp4', 'height': 240, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 48, 'vcodec': 'h264', 'preference': -10},
1146 '151': {'ext': 'mp4', 'height': 72, 'format_note': 'HLS', 'acodec': 'aac', 'abr': 24, 'vcodec': 'h264', 'preference': -10},
1149 '133': {'ext': 'mp4', 'height': 240, 'format_note': 'DASH video', 'vcodec': 'h264'},
1150 '134': {'ext': 'mp4', 'height': 360, 'format_note': 'DASH video', 'vcodec': 'h264'},
1151 '135': {'ext': 'mp4', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'h264'},
1152 '136': {'ext': 'mp4', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'h264'},
1153 '137': {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'h264'},
1154 '138': {'ext': 'mp4', 'format_note': 'DASH video', 'vcodec': 'h264'}, # Height can vary (https://github.com/ytdl-org/youtube-dl/issues/4559)
1155 '160': {'ext': 'mp4', 'height': 144, 'format_note': 'DASH video', 'vcodec': 'h264'},
1156 '212': {'ext': 'mp4', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'h264'},
1157 '264': {'ext': 'mp4', 'height': 1440, 'format_note': 'DASH video', 'vcodec': 'h264'},
1158 '298': {'ext': 'mp4', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'h264', 'fps': 60},
1159 '299': {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'h264', 'fps': 60},
1160 '266': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'h264'},
1163 '139': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'abr': 48, 'container': 'm4a_dash'},
1164 '140': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'abr': 128, 'container': 'm4a_dash'},
1165 '141': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'abr': 256, 'container': 'm4a_dash'},
1166 '256': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'container': 'm4a_dash'},
1167 '258': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'container': 'm4a_dash'},
1168 '325': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'dtse', 'container': 'm4a_dash'},
1169 '328': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'ec-3', 'container': 'm4a_dash'},
1172 '167': {'ext': 'webm', 'height': 360, 'width': 640, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp8'},
1173 '168': {'ext': 'webm', 'height': 480, 'width': 854, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp8'},
1174 '169': {'ext': 'webm', 'height': 720, 'width': 1280, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp8'},
1175 '170': {'ext': 'webm', 'height': 1080, 'width': 1920, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp8'},
1176 '218': {'ext': 'webm', 'height': 480, 'width': 854, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp8'},
1177 '219': {'ext': 'webm', 'height': 480, 'width': 854, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp8'},
1178 '278': {'ext': 'webm', 'height': 144, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'vp9'},
1179 '242': {'ext': 'webm', 'height': 240, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1180 '243': {'ext': 'webm', 'height': 360, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1181 '244': {'ext': 'webm', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1182 '245': {'ext': 'webm', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1183 '246': {'ext': 'webm', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1184 '247': {'ext': 'webm', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1185 '248': {'ext': 'webm', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1186 '271': {'ext': 'webm', 'height': 1440, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1187 # itag 272 videos are either 3840x2160 (e.g. RtoitU2A-3E) or 7680x4320 (sLprVF6d7Ug)
1188 '272': {'ext': 'webm', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1189 '302': {'ext': 'webm', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'vp9', 'fps': 60},
1190 '303': {'ext': 'webm', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'vp9', 'fps': 60},
1191 '308': {'ext': 'webm', 'height': 1440, 'format_note': 'DASH video', 'vcodec': 'vp9', 'fps': 60},
1192 '313': {'ext': 'webm', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'vp9'},
1193 '315': {'ext': 'webm', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'vp9', 'fps': 60},
1196 '171': {'ext': 'webm', 'acodec': 'vorbis', 'format_note': 'DASH audio', 'abr': 128},
1197 '172': {'ext': 'webm', 'acodec': 'vorbis', 'format_note': 'DASH audio', 'abr': 256},
1199 # Dash webm audio with opus inside
1200 '249': {'ext': 'webm', 'format_note': 'DASH audio', 'acodec': 'opus', 'abr': 50},
1201 '250': {'ext': 'webm', 'format_note': 'DASH audio', 'acodec': 'opus', 'abr': 70},
1202 '251': {'ext': 'webm', 'format_note': 'DASH audio', 'acodec': 'opus', 'abr': 160},
1205 '_rtmp': {'protocol': 'rtmp'},
1207 # av01 video only formats sometimes served with "unknown" codecs
1208 '394': {'ext': 'mp4', 'height': 144, 'format_note': 'DASH video', 'vcodec': 'av01.0.00M.08'},
1209 '395': {'ext': 'mp4', 'height': 240, 'format_note': 'DASH video', 'vcodec': 'av01.0.00M.08'},
1210 '396': {'ext': 'mp4', 'height': 360, 'format_note': 'DASH video', 'vcodec': 'av01.0.01M.08'},
1211 '397': {'ext': 'mp4', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'av01.0.04M.08'},
1212 '398': {'ext': 'mp4', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'av01.0.05M.08'},
1213 '399': {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'av01.0.08M.08'},
1214 '400': {'ext': 'mp4', 'height': 1440, 'format_note': 'DASH video', 'vcodec': 'av01.0.12M.08'},
1215 '401': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'av01.0.12M.08'},
1217 _SUBTITLE_FORMATS = ('json3', 'srv1', 'srv2', 'srv3', 'ttml', 'vtt')
1224 'url': 'https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9',
1226 'id': 'BaW_jenozKc',
1228 'title': 'youtube-dl test video "\'/\\ä↭𝕐',
1229 'uploader': 'Philipp Hagemeister',
1230 'uploader_id': 'phihag',
1231 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/phihag',
1232 'channel': 'Philipp Hagemeister',
1233 'channel_id': 'UCLqxVugv74EIW3VWh2NOa3Q',
1234 'channel_url': r're:https?://(?:www\.)?youtube\.com/channel/UCLqxVugv74EIW3VWh2NOa3Q',
1235 'upload_date': '20121002',
1236 'description': 'md5:8fb536f4877b8a7455c2ec23794dbc22',
1237 'categories': ['Science & Technology'],
1238 'tags': ['youtube-dl'],
1242 'availability': 'public',
1243 'playable_in_embed': True,
1244 'thumbnail': 'https://i.ytimg.com/vi/BaW_jenozKc/maxresdefault.jpg',
1245 'live_status': 'not_live',
1249 'comment_count': int,
1250 'channel_follower_count': int
1254 'url': '//www.YouTube.com/watch?v=yZIXLfi8CZQ',
1255 'note': 'Embed-only video (#1746)',
1257 'id': 'yZIXLfi8CZQ',
1259 'upload_date': '20120608',
1260 'title': 'Principal Sexually Assaults A Teacher - Episode 117 - 8th June 2012',
1261 'description': 'md5:09b78bd971f1e3e289601dfba15ca4f7',
1262 'uploader': 'SET India',
1263 'uploader_id': 'setindia',
1264 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/setindia',
1267 'skip': 'Private video',
1270 'url': 'https://www.youtube.com/watch?v=BaW_jenozKc&v=yZIXLfi8CZQ',
1271 'note': 'Use the first video ID in the URL',
1273 'id': 'BaW_jenozKc',
1275 'title': 'youtube-dl test video "\'/\\ä↭𝕐',
1276 'uploader': 'Philipp Hagemeister',
1277 'uploader_id': 'phihag',
1278 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/phihag',
1279 'channel': 'Philipp Hagemeister',
1280 'channel_id': 'UCLqxVugv74EIW3VWh2NOa3Q',
1281 'channel_url': r're:https?://(?:www\.)?youtube\.com/channel/UCLqxVugv74EIW3VWh2NOa3Q',
1282 'upload_date': '20121002',
1283 'description': 'md5:8fb536f4877b8a7455c2ec23794dbc22',
1284 'categories': ['Science & Technology'],
1285 'tags': ['youtube-dl'],
1289 'availability': 'public',
1290 'playable_in_embed': True,
1291 'thumbnail': 'https://i.ytimg.com/vi/BaW_jenozKc/maxresdefault.jpg',
1292 'live_status': 'not_live',
1294 'comment_count': int,
1295 'channel_follower_count': int
1298 'skip_download': True,
1302 'url': 'https://www.youtube.com/watch?v=a9LDPn-MO4I',
1303 'note': '256k DASH audio (format 141) via DASH manifest',
1305 'id': 'a9LDPn-MO4I',
1307 'upload_date': '20121002',
1308 'uploader_id': '8KVIDEO',
1309 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/8KVIDEO',
1311 'uploader': '8KVIDEO',
1312 'title': 'UHDTV TEST 8K VIDEO.mp4'
1315 'youtube_include_dash_manifest': True,
1318 'skip': 'format 141 not served anymore',
1320 # DASH manifest with encrypted signature
1322 'url': 'https://www.youtube.com/watch?v=IB3lcPjvWLA',
1324 'id': 'IB3lcPjvWLA',
1326 'title': 'Afrojack, Spree Wilson - The Spark (Official Music Video) ft. Spree Wilson',
1327 'description': 'md5:8f5e2b82460520b619ccac1f509d43bf',
1329 'uploader': 'AfrojackVEVO',
1330 'uploader_id': 'AfrojackVEVO',
1331 'upload_date': '20131011',
1334 'channel_id': 'UChuZAo1RKL85gev3Eal9_zg',
1335 'playable_in_embed': True,
1336 'channel_url': 'https://www.youtube.com/channel/UChuZAo1RKL85gev3Eal9_zg',
1338 'track': 'The Spark',
1339 'live_status': 'not_live',
1340 'thumbnail': 'https://i.ytimg.com/vi_webp/IB3lcPjvWLA/maxresdefault.webp',
1341 'channel': 'Afrojack',
1342 'uploader_url': 'http://www.youtube.com/user/AfrojackVEVO',
1344 'availability': 'public',
1345 'categories': ['Music'],
1347 'alt_title': 'The Spark',
1348 'channel_follower_count': int
1351 'youtube_include_dash_manifest': True,
1352 'format': '141/bestaudio[ext=m4a]',
1355 # Age-gate videos. See https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-888837000
1357 'note': 'Embed allowed age-gate video',
1358 'url': 'https://youtube.com/watch?v=HtVdAasjOgU',
1360 'id': 'HtVdAasjOgU',
1362 'title': 'The Witcher 3: Wild Hunt - The Sword Of Destiny Trailer',
1363 'description': r're:(?s).{100,}About the Game\n.*?The Witcher 3: Wild Hunt.{100,}',
1365 'uploader': 'The Witcher',
1366 'uploader_id': 'WitcherGame',
1367 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/WitcherGame',
1368 'upload_date': '20140605',
1370 'categories': ['Gaming'],
1371 'thumbnail': 'https://i.ytimg.com/vi_webp/HtVdAasjOgU/maxresdefault.webp',
1372 'availability': 'needs_auth',
1373 'channel_url': 'https://www.youtube.com/channel/UCzybXLxv08IApdjdN0mJhEg',
1375 'channel': 'The Witcher',
1376 'live_status': 'not_live',
1378 'channel_id': 'UCzybXLxv08IApdjdN0mJhEg',
1379 'playable_in_embed': True,
1381 'channel_follower_count': int
1385 'note': 'Age-gate video with embed allowed in public site',
1386 'url': 'https://youtube.com/watch?v=HsUATh_Nc2U',
1388 'id': 'HsUATh_Nc2U',
1390 'title': 'Godzilla 2 (Official Video)',
1391 'description': 'md5:bf77e03fcae5529475e500129b05668a',
1392 'upload_date': '20200408',
1393 'uploader_id': 'FlyingKitty900',
1394 'uploader': 'FlyingKitty',
1396 'availability': 'needs_auth',
1397 'channel_id': 'UCYQT13AtrJC0gsM1far_zJg',
1398 'uploader_url': 'http://www.youtube.com/user/FlyingKitty900',
1399 'channel': 'FlyingKitty',
1400 'channel_url': 'https://www.youtube.com/channel/UCYQT13AtrJC0gsM1far_zJg',
1402 'categories': ['Entertainment'],
1403 'live_status': 'not_live',
1404 'tags': ['Flyingkitty', 'godzilla 2'],
1405 'thumbnail': 'https://i.ytimg.com/vi/HsUATh_Nc2U/maxresdefault.jpg',
1408 'playable_in_embed': True,
1409 'channel_follower_count': int
1413 'note': 'Age-gate video embedable only with clientScreen=EMBED',
1414 'url': 'https://youtube.com/watch?v=Tq92D6wQ1mg',
1416 'id': 'Tq92D6wQ1mg',
1417 'title': '[MMD] Adios - EVERGLOW [+Motion DL]',
1419 'upload_date': '20191228',
1420 'uploader_id': 'UC1yoRdFoFJaCY-AGfD9W0wQ',
1421 'uploader': 'Projekt Melody',
1422 'description': 'md5:17eccca93a786d51bc67646756894066',
1425 'availability': 'needs_auth',
1426 'uploader_url': 'http://www.youtube.com/channel/UC1yoRdFoFJaCY-AGfD9W0wQ',
1427 'channel_id': 'UC1yoRdFoFJaCY-AGfD9W0wQ',
1429 'thumbnail': 'https://i.ytimg.com/vi_webp/Tq92D6wQ1mg/sddefault.webp',
1430 'channel': 'Projekt Melody',
1431 'live_status': 'not_live',
1432 'tags': ['mmd', 'dance', 'mikumikudance', 'kpop', 'vtuber'],
1433 'playable_in_embed': True,
1434 'categories': ['Entertainment'],
1436 'channel_url': 'https://www.youtube.com/channel/UC1yoRdFoFJaCY-AGfD9W0wQ',
1437 'comment_count': int,
1438 'channel_follower_count': int
1442 'note': 'Non-Agegated non-embeddable video',
1443 'url': 'https://youtube.com/watch?v=MeJVWBSsPAY',
1445 'id': 'MeJVWBSsPAY',
1447 'title': 'OOMPH! - Such Mich Find Mich (Lyrics)',
1448 'uploader': 'Herr Lurik',
1449 'uploader_id': 'st3in234',
1450 'description': 'Fan Video. Music & Lyrics by OOMPH!.',
1451 'upload_date': '20130730',
1452 'track': 'Such mich find mich',
1454 'tags': ['oomph', 'such mich find mich', 'lyrics', 'german industrial', 'musica industrial'],
1456 'playable_in_embed': False,
1457 'creator': 'OOMPH!',
1458 'thumbnail': 'https://i.ytimg.com/vi/MeJVWBSsPAY/sddefault.jpg',
1460 'alt_title': 'Such mich find mich',
1462 'channel': 'Herr Lurik',
1463 'channel_id': 'UCdR3RSDPqub28LjZx0v9-aA',
1464 'categories': ['Music'],
1465 'availability': 'public',
1466 'uploader_url': 'http://www.youtube.com/user/st3in234',
1467 'channel_url': 'https://www.youtube.com/channel/UCdR3RSDPqub28LjZx0v9-aA',
1468 'live_status': 'not_live',
1470 'channel_follower_count': int
1474 'note': 'Non-bypassable age-gated video',
1475 'url': 'https://youtube.com/watch?v=Cr381pDsSsA',
1476 'only_matching': True,
1478 # video_info is None (https://github.com/ytdl-org/youtube-dl/issues/4421)
1479 # YouTube Red ad is not captured for creator
1481 'url': '__2ABJjxzNo',
1483 'id': '__2ABJjxzNo',
1486 'upload_date': '20100430',
1487 'uploader_id': 'deadmau5',
1488 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/deadmau5',
1489 'creator': 'deadmau5',
1490 'description': 'md5:6cbcd3a92ce1bc676fc4d6ab4ace2336',
1491 'uploader': 'deadmau5',
1492 'title': 'Deadmau5 - Some Chords (HD)',
1493 'alt_title': 'Some Chords',
1494 'availability': 'public',
1496 'channel_id': 'UCYEK6xds6eo-3tr4xRdflmQ',
1498 'live_status': 'not_live',
1499 'channel': 'deadmau5',
1500 'thumbnail': 'https://i.ytimg.com/vi_webp/__2ABJjxzNo/maxresdefault.webp',
1502 'track': 'Some Chords',
1503 'artist': 'deadmau5',
1504 'playable_in_embed': True,
1506 'channel_url': 'https://www.youtube.com/channel/UCYEK6xds6eo-3tr4xRdflmQ',
1507 'categories': ['Music'],
1508 'album': 'Some Chords',
1509 'channel_follower_count': int
1511 'expected_warnings': [
1512 'DASH manifest missing',
1515 # Olympics (https://github.com/ytdl-org/youtube-dl/issues/4431)
1517 'url': 'lqQg6PlCWgI',
1519 'id': 'lqQg6PlCWgI',
1522 'upload_date': '20150827',
1523 'uploader_id': 'olympic',
1524 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/olympic',
1525 'description': 'md5:04bbbf3ccceb6795947572ca36f45904',
1526 'uploader': 'Olympics',
1527 'title': 'Hockey - Women - GER-AUS - London 2012 Olympic Games',
1529 'release_timestamp': 1343767800,
1530 'playable_in_embed': True,
1531 'categories': ['Sports'],
1532 'release_date': '20120731',
1533 'channel': 'Olympics',
1534 'tags': ['Hockey', '2012-07-31', '31 July 2012', 'Riverbank Arena', 'Session', 'Olympics', 'Olympic Games', 'London 2012', '2012 Summer Olympics', 'Summer Games'],
1535 'channel_id': 'UCTl3QQTvqHFjurroKxexy2Q',
1536 'thumbnail': 'https://i.ytimg.com/vi/lqQg6PlCWgI/maxresdefault.jpg',
1538 'availability': 'public',
1539 'live_status': 'was_live',
1541 'channel_url': 'https://www.youtube.com/channel/UCTl3QQTvqHFjurroKxexy2Q',
1542 'channel_follower_count': int
1545 'skip_download': 'requires avconv',
1550 'url': 'https://www.youtube.com/watch?v=_b-2C3KPAM0',
1552 'id': '_b-2C3KPAM0',
1554 'stretched_ratio': 16 / 9.,
1556 'upload_date': '20110310',
1557 'uploader_id': 'AllenMeow',
1558 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/AllenMeow',
1559 'description': 'made by Wacom from Korea | 字幕&加油添醋 by TY\'s Allen | 感謝heylisa00cavey1001同學熱情提供梗及翻譯',
1561 'title': '[A-made] 變態妍字幕版 太妍 我就是這樣的人',
1562 'playable_in_embed': True,
1566 'channel_url': 'https://www.youtube.com/channel/UCS-xxCmRaA6BFdmgDPA_BIw',
1567 'channel_id': 'UCS-xxCmRaA6BFdmgDPA_BIw',
1568 'thumbnail': 'https://i.ytimg.com/vi/_b-2C3KPAM0/maxresdefault.jpg',
1570 'categories': ['People & Blogs'],
1572 'live_status': 'not_live',
1573 'availability': 'unlisted',
1574 'comment_count': int,
1575 'channel_follower_count': int
1578 # url_encoded_fmt_stream_map is empty string
1580 'url': 'qEJwOuvDf7I',
1582 'id': 'qEJwOuvDf7I',
1584 'title': 'Обсуждение судебной практики по выборам 14 сентября 2014 года в Санкт-Петербурге',
1586 'upload_date': '20150404',
1587 'uploader_id': 'spbelect',
1588 'uploader': 'Наблюдатели Петербурга',
1591 'skip_download': 'requires avconv',
1593 'skip': 'This live event has ended.',
1595 # Extraction from multiple DASH manifests (https://github.com/ytdl-org/youtube-dl/pull/6097)
1597 'url': 'https://www.youtube.com/watch?v=FIl7x6_3R5Y',
1599 'id': 'FIl7x6_3R5Y',
1601 'title': 'md5:7b81415841e02ecd4313668cde88737a',
1602 'description': 'md5:116377fd2963b81ec4ce64b542173306',
1604 'upload_date': '20150625',
1605 'uploader_id': 'dorappi2000',
1606 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/dorappi2000',
1607 'uploader': 'dorappi2000',
1608 'formats': 'mincount:31',
1610 'skip': 'not actual anymore',
1612 # DASH manifest with segment_list
1614 'url': 'https://www.youtube.com/embed/CsmdDsKjzN8',
1615 'md5': '8ce563a1d667b599d21064e982ab9e31',
1617 'id': 'CsmdDsKjzN8',
1619 'upload_date': '20150501', # According to '<meta itemprop="datePublished"', but in other places it's 20150510
1620 'uploader': 'Airtek',
1621 'description': 'Retransmisión en directo de la XVIII media maratón de Zaragoza.',
1622 'uploader_id': 'UCzTzUmjXxxacNnL8I3m4LnQ',
1623 'title': 'Retransmisión XVIII Media maratón Zaragoza 2015',
1626 'youtube_include_dash_manifest': True,
1627 'format': '135', # bestvideo
1629 'skip': 'This live event has ended.',
1632 # Multifeed videos (multiple cameras), URL can be of any Camera
1633 'url': 'https://www.youtube.com/watch?v=zaPI8MvL8pg',
1635 'id': 'zaPI8MvL8pg',
1636 'title': 'Terraria 1.2 Live Stream | Let\'s Play - Part 04',
1637 'description': 'md5:563ccbc698b39298481ca3c571169519',
1641 'id': 'j5yGuxZ8lLU',
1643 'title': 'Terraria 1.2 Live Stream | Let\'s Play - Part 04 (Chris)',
1644 'uploader': 'WiiLikeToPlay',
1645 'description': 'md5:563ccbc698b39298481ca3c571169519',
1646 'uploader_url': 'http://www.youtube.com/user/WiiRikeToPray',
1648 'channel_follower_count': int,
1649 'channel_url': 'https://www.youtube.com/channel/UCN2XePorRokPB9TEgRZpddg',
1650 'availability': 'public',
1651 'playable_in_embed': True,
1652 'upload_date': '20131105',
1653 'uploader_id': 'WiiRikeToPray',
1654 'categories': ['Gaming'],
1655 'live_status': 'was_live',
1657 'release_timestamp': 1383701910,
1658 'thumbnail': 'https://i.ytimg.com/vi/j5yGuxZ8lLU/maxresdefault.jpg',
1659 'comment_count': int,
1662 'channel_id': 'UCN2XePorRokPB9TEgRZpddg',
1663 'channel': 'WiiLikeToPlay',
1665 'release_date': '20131106',
1669 'id': 'zaPI8MvL8pg',
1671 'title': 'Terraria 1.2 Live Stream | Let\'s Play - Part 04 (Tyson)',
1672 'uploader_id': 'WiiRikeToPray',
1673 'availability': 'public',
1674 'channel_url': 'https://www.youtube.com/channel/UCN2XePorRokPB9TEgRZpddg',
1675 'channel': 'WiiLikeToPlay',
1676 'uploader_url': 'http://www.youtube.com/user/WiiRikeToPray',
1677 'channel_follower_count': int,
1678 'description': 'md5:563ccbc698b39298481ca3c571169519',
1683 'channel_id': 'UCN2XePorRokPB9TEgRZpddg',
1684 'uploader': 'WiiLikeToPlay',
1685 'release_timestamp': 1383701915,
1686 'comment_count': int,
1687 'upload_date': '20131105',
1688 'thumbnail': 'https://i.ytimg.com/vi/zaPI8MvL8pg/maxresdefault.jpg',
1689 'release_date': '20131106',
1690 'playable_in_embed': True,
1691 'live_status': 'was_live',
1692 'categories': ['Gaming'],
1697 'id': 'R7r3vfO7Hao',
1699 'title': 'Terraria 1.2 Live Stream | Let\'s Play - Part 04 (Spencer)',
1700 'thumbnail': 'https://i.ytimg.com/vi/R7r3vfO7Hao/maxresdefault.jpg',
1701 'channel_id': 'UCN2XePorRokPB9TEgRZpddg',
1703 'availability': 'public',
1704 'playable_in_embed': True,
1705 'upload_date': '20131105',
1706 'description': 'md5:563ccbc698b39298481ca3c571169519',
1707 'uploader_id': 'WiiRikeToPray',
1708 'uploader_url': 'http://www.youtube.com/user/WiiRikeToPray',
1709 'channel_follower_count': int,
1711 'release_date': '20131106',
1712 'uploader': 'WiiLikeToPlay',
1713 'comment_count': int,
1714 'channel_url': 'https://www.youtube.com/channel/UCN2XePorRokPB9TEgRZpddg',
1715 'channel': 'WiiLikeToPlay',
1716 'categories': ['Gaming'],
1717 'release_timestamp': 1383701914,
1718 'live_status': 'was_live',
1724 'params': {'skip_download': True},
1727 # Multifeed video with comma in title (see https://github.com/ytdl-org/youtube-dl/issues/8536)
1728 'url': 'https://www.youtube.com/watch?v=gVfLd0zydlo',
1730 'id': 'gVfLd0zydlo',
1731 'title': 'DevConf.cz 2016 Day 2 Workshops 1 14:00 - 15:30',
1733 'playlist_count': 2,
1734 'skip': 'Not multifeed anymore',
1737 'url': 'https://vid.plus/FlRa-iH7PGw',
1738 'only_matching': True,
1741 'url': 'https://zwearz.com/watch/9lWxNJF-ufM/electra-woman-dyna-girl-official-trailer-grace-helbig.html',
1742 'only_matching': True,
1745 # Title with JS-like syntax "};" (see https://github.com/ytdl-org/youtube-dl/issues/7468)
1746 # Also tests cut-off URL expansion in video description (see
1747 # https://github.com/ytdl-org/youtube-dl/issues/1892,
1748 # https://github.com/ytdl-org/youtube-dl/issues/8164)
1749 'url': 'https://www.youtube.com/watch?v=lsguqyKfVQg',
1751 'id': 'lsguqyKfVQg',
1753 'title': '{dark walk}; Loki/AC/Dishonored; collab w/Elflover21',
1754 'alt_title': 'Dark Walk',
1755 'description': 'md5:8085699c11dc3f597ce0410b0dcbb34a',
1757 'upload_date': '20151119',
1758 'uploader_id': 'IronSoulElf',
1759 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/IronSoulElf',
1760 'uploader': 'IronSoulElf',
1761 'creator': 'Todd Haberman;\nDaniel Law Heath and Aaron Kaplan',
1762 'track': 'Dark Walk',
1763 'artist': 'Todd Haberman;\nDaniel Law Heath and Aaron Kaplan',
1764 'album': 'Position Music - Production Music Vol. 143 - Dark Walk',
1765 'thumbnail': 'https://i.ytimg.com/vi_webp/lsguqyKfVQg/maxresdefault.webp',
1766 'categories': ['Film & Animation'],
1768 'live_status': 'not_live',
1769 'channel_url': 'https://www.youtube.com/channel/UCTSRgz5jylBvFt_S7wnsqLQ',
1770 'channel_id': 'UCTSRgz5jylBvFt_S7wnsqLQ',
1772 'availability': 'public',
1773 'channel': 'IronSoulElf',
1774 'playable_in_embed': True,
1777 'channel_follower_count': int
1780 'skip_download': True,
1784 # Tags with '};' (see https://github.com/ytdl-org/youtube-dl/issues/7468)
1785 'url': 'https://www.youtube.com/watch?v=Ms7iBXnlUO8',
1786 'only_matching': True,
1789 # Video with yt:stretch=17:0
1790 'url': 'https://www.youtube.com/watch?v=Q39EVAstoRM',
1792 'id': 'Q39EVAstoRM',
1794 'title': 'Clash Of Clans#14 Dicas De Ataque Para CV 4',
1795 'description': 'md5:ee18a25c350637c8faff806845bddee9',
1796 'upload_date': '20151107',
1797 'uploader_id': 'UCCr7TALkRbo3EtFzETQF1LA',
1798 'uploader': 'CH GAMER DROID',
1801 'skip_download': True,
1803 'skip': 'This video does not exist.',
1806 # Video with incomplete 'yt:stretch=16:'
1807 'url': 'https://www.youtube.com/watch?v=FRhJzUSJbGI',
1808 'only_matching': True,
1811 # Video licensed under Creative Commons
1812 'url': 'https://www.youtube.com/watch?v=M4gD1WSo5mA',
1814 'id': 'M4gD1WSo5mA',
1816 'title': 'md5:e41008789470fc2533a3252216f1c1d1',
1817 'description': 'md5:a677553cf0840649b731a3024aeff4cc',
1819 'upload_date': '20150128',
1820 'uploader_id': 'BerkmanCenter',
1821 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/BerkmanCenter',
1822 'uploader': 'The Berkman Klein Center for Internet & Society',
1823 'license': 'Creative Commons Attribution license (reuse allowed)',
1824 'channel_id': 'UCuLGmD72gJDBwmLw06X58SA',
1825 'channel_url': 'https://www.youtube.com/channel/UCuLGmD72gJDBwmLw06X58SA',
1828 'tags': ['Copyright (Legal Subject)', 'Law (Industry)', 'William W. Fisher (Author)'],
1829 'channel': 'The Berkman Klein Center for Internet & Society',
1830 'availability': 'public',
1832 'categories': ['Education'],
1833 'thumbnail': 'https://i.ytimg.com/vi_webp/M4gD1WSo5mA/maxresdefault.webp',
1834 'live_status': 'not_live',
1835 'playable_in_embed': True,
1836 'comment_count': int,
1837 'channel_follower_count': int,
1841 'skip_download': True,
1845 # Channel-like uploader_url
1846 'url': 'https://www.youtube.com/watch?v=eQcmzGIKrzg',
1848 'id': 'eQcmzGIKrzg',
1850 'title': 'Democratic Socialism and Foreign Policy | Bernie Sanders',
1851 'description': 'md5:13a2503d7b5904ef4b223aa101628f39',
1853 'upload_date': '20151120',
1854 'uploader': 'Bernie Sanders',
1855 'uploader_id': 'UCH1dpzjCEiGAt8CXkryhkZg',
1856 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UCH1dpzjCEiGAt8CXkryhkZg',
1857 'license': 'Creative Commons Attribution license (reuse allowed)',
1858 'playable_in_embed': True,
1861 'channel_id': 'UCH1dpzjCEiGAt8CXkryhkZg',
1863 'availability': 'public',
1864 'categories': ['News & Politics'],
1865 'channel': 'Bernie Sanders',
1866 'thumbnail': 'https://i.ytimg.com/vi_webp/eQcmzGIKrzg/maxresdefault.webp',
1868 'live_status': 'not_live',
1869 'channel_url': 'https://www.youtube.com/channel/UCH1dpzjCEiGAt8CXkryhkZg',
1870 'comment_count': int,
1871 'channel_follower_count': int,
1875 'skip_download': True,
1879 'url': 'https://www.youtube.com/watch?feature=player_embedded&amp;v=V36LpHqtcDY',
1880 'only_matching': True,
1883 # YouTube Red paid video (https://github.com/ytdl-org/youtube-dl/issues/10059)
1884 'url': 'https://www.youtube.com/watch?v=i1Ko8UG-Tdo',
1885 'only_matching': True,
1888 # Rental video preview
1889 'url': 'https://www.youtube.com/watch?v=yYr8q0y5Jfg',
1891 'id': 'uGpuVWrhIzE',
1893 'title': 'Piku - Trailer',
1894 'description': 'md5:c36bd60c3fd6f1954086c083c72092eb',
1895 'upload_date': '20150811',
1896 'uploader': 'FlixMatrix',
1897 'uploader_id': 'FlixMatrixKaravan',
1898 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/FlixMatrixKaravan',
1899 'license': 'Standard YouTube License',
1902 'skip_download': True,
1904 'skip': 'This video is not available.',
1907 # YouTube Red video with episode data
1908 'url': 'https://www.youtube.com/watch?v=iqKdEhx-dD4',
1910 'id': 'iqKdEhx-dD4',
1912 'title': 'Isolation - Mind Field (Ep 1)',
1913 'description': 'md5:f540112edec5d09fc8cc752d3d4ba3cd',
1915 'upload_date': '20170118',
1916 'uploader': 'Vsauce',
1917 'uploader_id': 'Vsauce',
1918 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/Vsauce',
1919 'series': 'Mind Field',
1921 'episode_number': 1,
1922 'thumbnail': 'https://i.ytimg.com/vi_webp/iqKdEhx-dD4/maxresdefault.webp',
1925 'availability': 'public',
1927 'channel': 'Vsauce',
1928 'episode': 'Episode 1',
1929 'categories': ['Entertainment'],
1930 'season': 'Season 1',
1931 'channel_id': 'UC6nSFpj9HTCZ5t-N3Rm3-HA',
1932 'channel_url': 'https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA',
1934 'playable_in_embed': True,
1935 'live_status': 'not_live',
1936 'channel_follower_count': int
1939 'skip_download': True,
1941 'expected_warnings': [
1942 'Skipping DASH manifest',
1946 # The following content has been identified by the YouTube community
1947 # as inappropriate or offensive to some audiences.
1948 'url': 'https://www.youtube.com/watch?v=6SJNVb0GnPI',
1950 'id': '6SJNVb0GnPI',
1952 'title': 'Race Differences in Intelligence',
1953 'description': 'md5:5d161533167390427a1f8ee89a1fc6f1',
1955 'upload_date': '20140124',
1956 'uploader': 'New Century Foundation',
1957 'uploader_id': 'UCEJYpZGqgUob0zVVEaLhvVg',
1958 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UCEJYpZGqgUob0zVVEaLhvVg',
1961 'skip_download': True,
1963 'skip': 'This video has been removed for violating YouTube\'s policy on hate speech.',
1967 'url': '1t24XAntNCY',
1968 'only_matching': True,
1971 # geo restricted to JP
1972 'url': 'sJL6WA-aGkQ',
1973 'only_matching': True,
1976 'url': 'https://invidio.us/watch?v=BaW_jenozKc',
1977 'only_matching': True,
1980 'url': 'https://redirect.invidious.io/watch?v=BaW_jenozKc',
1981 'only_matching': True,
1984 # from https://nitter.pussthecat.org/YouTube/status/1360363141947944964#m
1985 'url': 'https://redirect.invidious.io/Yh0AhrY9GjA',
1986 'only_matching': True,
1990 'url': 'https://www.youtube.com/watch?v=s7_qI6_mIXc',
1991 'only_matching': True,
1994 # Video with unsupported adaptive stream type formats
1995 'url': 'https://www.youtube.com/watch?v=Z4Vy8R84T1U',
1997 'id': 'Z4Vy8R84T1U',
1999 'title': 'saman SMAN 53 Jakarta(Sancety) opening COFFEE4th at SMAN 53 Jakarta',
2000 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
2002 'upload_date': '20130923',
2003 'uploader': 'Amelia Putri Harwita',
2004 'uploader_id': 'UCpOxM49HJxmC1qCalXyB3_Q',
2005 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UCpOxM49HJxmC1qCalXyB3_Q',
2006 'formats': 'maxcount:10',
2009 'skip_download': True,
2010 'youtube_include_dash_manifest': False,
2012 'skip': 'not actual anymore',
2015 # Youtube Music Auto-generated description
2016 'url': 'https://music.youtube.com/watch?v=MgNrAu2pzNs',
2018 'id': 'MgNrAu2pzNs',
2020 'title': 'Voyeur Girl',
2021 'description': 'md5:7ae382a65843d6df2685993e90a8628f',
2022 'upload_date': '20190312',
2023 'uploader': 'Stephen - Topic',
2024 'uploader_id': 'UC-pWHpBjdGG69N9mM2auIAA',
2025 'artist': 'Stephen',
2026 'track': 'Voyeur Girl',
2027 'album': 'it\'s too much love to know my dear',
2028 'release_date': '20190313',
2029 'release_year': 2019,
2030 'alt_title': 'Voyeur Girl',
2032 'uploader_url': 'http://www.youtube.com/channel/UC-pWHpBjdGG69N9mM2auIAA',
2033 'playable_in_embed': True,
2035 'categories': ['Music'],
2036 'channel_url': 'https://www.youtube.com/channel/UC-pWHpBjdGG69N9mM2auIAA',
2037 'channel': 'Stephen',
2038 'availability': 'public',
2039 'creator': 'Stephen',
2041 'thumbnail': 'https://i.ytimg.com/vi_webp/MgNrAu2pzNs/maxresdefault.webp',
2043 'channel_id': 'UC-pWHpBjdGG69N9mM2auIAA',
2045 'live_status': 'not_live',
2046 'channel_follower_count': int
2049 'skip_download': True,
2053 'url': 'https://www.youtubekids.com/watch?v=3b8nCWDgZ6Q',
2054 'only_matching': True,
2057 # invalid -> valid video id redirection
2058 'url': 'DJztXj2GPfl',
2060 'id': 'DJztXj2GPfk',
2062 'title': 'Panjabi MC - Mundian To Bach Ke (The Dictator Soundtrack)',
2063 'description': 'md5:bf577a41da97918e94fa9798d9228825',
2064 'upload_date': '20090125',
2065 'uploader': 'Prochorowka',
2066 'uploader_id': 'Prochorowka',
2067 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/Prochorowka',
2068 'artist': 'Panjabi MC',
2069 'track': 'Beware of the Boys (Mundian to Bach Ke) - Motivo Hi-Lectro Remix',
2070 'album': 'Beware of the Boys (Mundian To Bach Ke)',
2073 'skip_download': True,
2075 'skip': 'Video unavailable',
2078 # empty description results in an empty string
2079 'url': 'https://www.youtube.com/watch?v=x41yOUIvK2k',
2081 'id': 'x41yOUIvK2k',
2083 'title': 'IMG 3456',
2085 'upload_date': '20170613',
2086 'uploader_id': 'ElevageOrVert',
2087 'uploader': 'ElevageOrVert',
2089 'thumbnail': 'https://i.ytimg.com/vi_webp/x41yOUIvK2k/maxresdefault.webp',
2090 'uploader_url': 'http://www.youtube.com/user/ElevageOrVert',
2092 'channel_id': 'UCo03ZQPBW5U4UC3regpt1nw',
2094 'channel_url': 'https://www.youtube.com/channel/UCo03ZQPBW5U4UC3regpt1nw',
2095 'availability': 'public',
2097 'categories': ['Pets & Animals'],
2099 'playable_in_embed': True,
2100 'live_status': 'not_live',
2101 'channel': 'ElevageOrVert',
2102 'channel_follower_count': int
2105 'skip_download': True,
2109 # with '};' inside yt initial data (see [1])
2110 # see [2] for an example with '};' inside ytInitialPlayerResponse
2111 # 1. https://github.com/ytdl-org/youtube-dl/issues/27093
2112 # 2. https://github.com/ytdl-org/youtube-dl/issues/27216
2113 'url': 'https://www.youtube.com/watch?v=CHqg6qOn4no',
2115 'id': 'CHqg6qOn4no',
2117 'title': 'Part 77 Sort a list of simple types in c#',
2118 'description': 'md5:b8746fa52e10cdbf47997903f13b20dc',
2119 'upload_date': '20130831',
2120 'uploader_id': 'kudvenkat',
2121 'uploader': 'kudvenkat',
2122 'channel_id': 'UCCTVrRB5KpIiK6V2GGVsR1Q',
2124 'uploader_url': 'http://www.youtube.com/user/kudvenkat',
2125 'channel_url': 'https://www.youtube.com/channel/UCCTVrRB5KpIiK6V2GGVsR1Q',
2126 'live_status': 'not_live',
2127 'categories': ['Education'],
2128 'availability': 'public',
2129 'thumbnail': 'https://i.ytimg.com/vi/CHqg6qOn4no/sddefault.jpg',
2131 'playable_in_embed': True,
2135 'channel': 'kudvenkat',
2136 'comment_count': int,
2137 'channel_follower_count': int,
2141 'skip_download': True,
2145 # another example of '};' in ytInitialData
2146 'url': 'https://www.youtube.com/watch?v=gVfgbahppCY',
2147 'only_matching': True,
2150 'url': 'https://www.youtube.com/watch_popup?v=63RmMXCd_bQ',
2151 'only_matching': True,
2154 # https://github.com/ytdl-org/youtube-dl/pull/28094
2155 'url': 'OtqTfy26tG0',
2157 'id': 'OtqTfy26tG0',
2159 'title': 'Burn Out',
2160 'description': 'md5:8d07b84dcbcbfb34bc12a56d968b6131',
2161 'upload_date': '20141120',
2162 'uploader': 'The Cinematic Orchestra - Topic',
2163 'uploader_id': 'UCIzsJBIyo8hhpFm1NK0uLgw',
2164 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UCIzsJBIyo8hhpFm1NK0uLgw',
2165 'artist': 'The Cinematic Orchestra',
2166 'track': 'Burn Out',
2167 'album': 'Every Day',
2169 'live_status': 'not_live',
2170 'alt_title': 'Burn Out',
2174 'channel_url': 'https://www.youtube.com/channel/UCIzsJBIyo8hhpFm1NK0uLgw',
2175 'creator': 'The Cinematic Orchestra',
2176 'channel': 'The Cinematic Orchestra',
2177 'tags': ['The Cinematic Orchestra', 'Every Day', 'Burn Out'],
2178 'channel_id': 'UCIzsJBIyo8hhpFm1NK0uLgw',
2179 'availability': 'public',
2180 'thumbnail': 'https://i.ytimg.com/vi/OtqTfy26tG0/maxresdefault.jpg',
2181 'categories': ['Music'],
2182 'playable_in_embed': True,
2183 'channel_follower_count': int
2186 'skip_download': True,
2190 # controversial video, only works with bpctr when authenticated with cookies
2191 'url': 'https://www.youtube.com/watch?v=nGC3D_FkCmg',
2192 'only_matching': True,
2195 # controversial video, requires bpctr/contentCheckOk
2196 'url': 'https://www.youtube.com/watch?v=SZJvDhaSDnc',
2198 'id': 'SZJvDhaSDnc',
2200 'title': 'San Diego teen commits suicide after bullying over embarrassing video',
2201 'channel_id': 'UC-SJ6nODDmufqBzPBwCvYvQ',
2202 'uploader': 'CBS Mornings',
2203 'uploader_id': 'CBSThisMorning',
2204 'upload_date': '20140716',
2205 'description': 'md5:acde3a73d3f133fc97e837a9f76b53b7',
2207 'categories': ['News & Politics'],
2208 'uploader_url': 'http://www.youtube.com/user/CBSThisMorning',
2210 'channel': 'CBS Mornings',
2211 'tags': ['suicide', 'bullying', 'video', 'cbs', 'news'],
2212 'thumbnail': 'https://i.ytimg.com/vi/SZJvDhaSDnc/hqdefault.jpg',
2214 'availability': 'needs_auth',
2215 'channel_url': 'https://www.youtube.com/channel/UC-SJ6nODDmufqBzPBwCvYvQ',
2217 'live_status': 'not_live',
2218 'playable_in_embed': True,
2219 'channel_follower_count': int
2223 # restricted location, https://github.com/ytdl-org/youtube-dl/issues/28685
2224 'url': 'cBvYw8_A0vQ',
2226 'id': 'cBvYw8_A0vQ',
2228 'title': '4K Ueno Okachimachi Street Scenes 上野御徒町歩き',
2229 'description': 'md5:ea770e474b7cd6722b4c95b833c03630',
2230 'upload_date': '20201120',
2231 'uploader': 'Walk around Japan',
2232 'uploader_id': 'UC3o_t8PzBmXf5S9b7GLx1Mw',
2233 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UC3o_t8PzBmXf5S9b7GLx1Mw',
2235 'categories': ['Travel & Events'],
2236 'channel_id': 'UC3o_t8PzBmXf5S9b7GLx1Mw',
2238 'channel': 'Walk around Japan',
2239 'tags': ['Ueno Tokyo', 'Okachimachi Tokyo', 'Ameyoko Street', 'Tokyo attraction', 'Travel in Tokyo'],
2240 'thumbnail': 'https://i.ytimg.com/vi_webp/cBvYw8_A0vQ/hqdefault.webp',
2242 'availability': 'public',
2243 'channel_url': 'https://www.youtube.com/channel/UC3o_t8PzBmXf5S9b7GLx1Mw',
2244 'live_status': 'not_live',
2245 'playable_in_embed': True,
2246 'channel_follower_count': int
2249 'skip_download': True,
2252 # Has multiple audio streams
2253 'url': 'WaOKSUlf4TM',
2254 'only_matching': True
2256 # Requires Premium: has format 141 when requested using YTM url
2257 'url': 'https://music.youtube.com/watch?v=XclachpHxis',
2258 'only_matching': True
2260 # multiple subtitles with same lang_code
2261 'url': 'https://www.youtube.com/watch?v=wsQiKKfKxug',
2262 'only_matching': True,
2264 # Force use android client fallback
2265 'url': 'https://www.youtube.com/watch?v=YOelRv7fMxY',
2267 'id': 'YOelRv7fMxY',
2268 'title': 'DIGGING A SECRET TUNNEL Part 1',
2270 'upload_date': '20210624',
2271 'channel_id': 'UCp68_FLety0O-n9QU6phsgw',
2272 'uploader': 'colinfurze',
2273 'uploader_id': 'colinfurze',
2274 'channel_url': r're:https?://(?:www\.)?youtube\.com/channel/UCp68_FLety0O-n9QU6phsgw',
2275 'description': 'md5:5d5991195d599b56cd0c4148907eec50',
2277 'categories': ['Entertainment'],
2278 'uploader_url': 'http://www.youtube.com/user/colinfurze',
2280 'channel': 'colinfurze',
2281 'tags': ['Colin', 'furze', 'Terry', 'tunnel', 'underground', 'bunker'],
2282 'thumbnail': 'https://i.ytimg.com/vi/YOelRv7fMxY/maxresdefault.jpg',
2284 'availability': 'public',
2286 'live_status': 'not_live',
2287 'playable_in_embed': True,
2288 'channel_follower_count': int,
2292 'format': '17', # 3gp format available on android
2293 'extractor_args': {'youtube': {'player_client': ['android']}},
2297 # Skip download of additional client configs (remix client config in this case)
2298 'url': 'https://music.youtube.com/watch?v=MgNrAu2pzNs',
2299 'only_matching': True,
2301 'extractor_args': {'youtube': {'player_skip': ['configs']}},
2305 'url': 'https://www.youtube.com/shorts/BGQWPY4IigY',
2306 'only_matching': True,
2308 'note': 'Storyboards',
2309 'url': 'https://www.youtube.com/watch?v=5KLPxDtMqe8',
2311 'id': '5KLPxDtMqe8',
2314 'title': 'Your Brain is Plastic',
2315 'uploader_id': 'scishow',
2316 'description': 'md5:89cd86034bdb5466cd87c6ba206cd2bc',
2317 'upload_date': '20140324',
2318 'uploader': 'SciShow',
2320 'channel_id': 'UCZYTClx2T1of7BRZ86-8fow',
2321 'channel_url': 'https://www.youtube.com/channel/UCZYTClx2T1of7BRZ86-8fow',
2323 'thumbnail': 'https://i.ytimg.com/vi/5KLPxDtMqe8/maxresdefault.jpg',
2324 'playable_in_embed': True,
2326 'uploader_url': 'http://www.youtube.com/user/scishow',
2327 'availability': 'public',
2328 'channel': 'SciShow',
2329 'live_status': 'not_live',
2331 'categories': ['Education'],
2333 'channel_follower_count': int,
2335 }, 'params': {'format': 'mhtml', 'skip_download': True}
2337 # Ensure video upload_date is in UTC timezone (video was uploaded 1641170939)
2338 'url': 'https://www.youtube.com/watch?v=2NUZ8W2llS4',
2340 'id': '2NUZ8W2llS4',
2342 'title': 'The NP that test your phone performance 🙂',
2343 'description': 'md5:144494b24d4f9dfacb97c1bbef5de84d',
2344 'uploader': 'Leon Nguyen',
2345 'uploader_id': 'VNSXIII',
2346 'uploader_url': 'http://www.youtube.com/user/VNSXIII',
2347 'channel_id': 'UCRqNBSOHgilHfAczlUmlWHA',
2348 'channel_url': 'https://www.youtube.com/channel/UCRqNBSOHgilHfAczlUmlWHA',
2352 'categories': ['Gaming'],
2354 'playable_in_embed': True,
2355 'live_status': 'not_live',
2356 'upload_date': '20220103',
2358 'availability': 'public',
2359 'channel': 'Leon Nguyen',
2360 'thumbnail': 'https://i.ytimg.com/vi_webp/2NUZ8W2llS4/maxresdefault.webp',
2361 'comment_count': int,
2362 'channel_follower_count': int
2365 # Same video as above, but with --compat-opt no-youtube-prefer-utc-upload-date
2366 'url': 'https://www.youtube.com/watch?v=2NUZ8W2llS4',
2368 'id': '2NUZ8W2llS4',
2370 'title': 'The NP that test your phone performance 🙂',
2371 'description': 'md5:144494b24d4f9dfacb97c1bbef5de84d',
2372 'uploader': 'Leon Nguyen',
2373 'uploader_id': 'VNSXIII',
2374 'uploader_url': 'http://www.youtube.com/user/VNSXIII',
2375 'channel_id': 'UCRqNBSOHgilHfAczlUmlWHA',
2376 'channel_url': 'https://www.youtube.com/channel/UCRqNBSOHgilHfAczlUmlWHA',
2380 'categories': ['Gaming'],
2382 'playable_in_embed': True,
2383 'live_status': 'not_live',
2384 'upload_date': '20220102',
2386 'availability': 'public',
2387 'channel': 'Leon Nguyen',
2388 'thumbnail': 'https://i.ytimg.com/vi_webp/2NUZ8W2llS4/maxresdefault.webp',
2389 'comment_count': int,
2390 'channel_follower_count': int
2392 'params': {'compat_opts': ['no-youtube-prefer-utc-upload-date']}
2394 # date text is premiered video, ensure upload date in UTC (published 1641172509)
2395 'url': 'https://www.youtube.com/watch?v=mzZzzBU6lrM',
2397 'id': 'mzZzzBU6lrM',
2399 'title': 'I Met GeorgeNotFound In Real Life...',
2400 'description': 'md5:cca98a355c7184e750f711f3a1b22c84',
2401 'uploader': 'Quackity',
2402 'uploader_id': 'QuackityHQ',
2403 'uploader_url': 'http://www.youtube.com/user/QuackityHQ',
2404 'channel_id': 'UC_8NknAFiyhOUaZqHR3lq3Q',
2405 'channel_url': 'https://www.youtube.com/channel/UC_8NknAFiyhOUaZqHR3lq3Q',
2409 'categories': ['Entertainment'],
2411 'playable_in_embed': True,
2412 'live_status': 'not_live',
2413 'release_timestamp': 1641172509,
2414 'release_date': '20220103',
2415 'upload_date': '20220103',
2417 'availability': 'public',
2418 'channel': 'Quackity',
2419 'thumbnail': 'https://i.ytimg.com/vi/mzZzzBU6lrM/maxresdefault.jpg',
2420 'channel_follower_count': int
2423 { # continuous livestream. Microformat upload date should be preferred.
2424 # Upload date was 2021-06-19 (not UTC), while stream start is 2021-11-27
2425 'url': 'https://www.youtube.com/watch?v=kgx4WGK0oNU',
2427 'id': 'kgx4WGK0oNU',
2428 'title': r're:jazz\/lofi hip hop radio🌱chill beats to relax\/study to \[LIVE 24\/7\] \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
2430 'channel_id': 'UC84whx2xxsiA1gXHXXqKGOA',
2431 'availability': 'public',
2433 'release_timestamp': 1637975704,
2434 'upload_date': '20210619',
2435 'channel_url': 'https://www.youtube.com/channel/UC84whx2xxsiA1gXHXXqKGOA',
2436 'live_status': 'is_live',
2437 'thumbnail': 'https://i.ytimg.com/vi/kgx4WGK0oNU/maxresdefault.jpg',
2438 'uploader': '阿鲍Abao',
2439 'uploader_url': 'http://www.youtube.com/channel/UC84whx2xxsiA1gXHXXqKGOA',
2440 'channel': 'Abao in Tokyo',
2441 'channel_follower_count': int,
2442 'release_date': '20211127',
2444 'categories': ['People & Blogs'],
2446 'uploader_id': 'UC84whx2xxsiA1gXHXXqKGOA',
2448 'playable_in_embed': True,
2449 'description': 'md5:2ef1d002cad520f65825346e2084e49d',
2450 'concurrent_view_count': int,
2452 'params': {'skip_download': True}
2454 # Story. Requires specific player params to work.
2455 'url': 'https://www.youtube.com/watch?v=vv8qTUWmulI',
2457 'id': 'vv8qTUWmulI',
2459 'availability': 'unlisted',
2461 'channel_id': 'UCzIZ8HrzDgc-pNQDUG6avBA',
2462 'upload_date': '20220526',
2463 'categories': ['Education'],
2465 'channel': 'IT\'S HISTORY',
2467 'uploader_id': 'BlastfromthePast',
2469 'uploader': 'IT\'S HISTORY',
2470 'playable_in_embed': True,
2472 'live_status': 'not_live',
2474 'thumbnail': 'https://i.ytimg.com/vi_webp/vv8qTUWmulI/maxresdefault.webp',
2475 'uploader_url': 'http://www.youtube.com/user/BlastfromthePast',
2476 'channel_url': 'https://www.youtube.com/channel/UCzIZ8HrzDgc-pNQDUG6avBA',
2478 'skip': 'stories get removed after some period of time',
2480 'url': 'https://www.youtube.com/watch?v=tjjjtzRLHvA',
2482 'id': 'tjjjtzRLHvA',
2484 'title': 'ハッシュタグ無し };if window.ytcsi',
2485 'upload_date': '20220323',
2487 'availability': 'unlisted',
2488 'channel': 'nao20010128nao',
2489 'thumbnail': 'https://i.ytimg.com/vi_webp/tjjjtzRLHvA/maxresdefault.webp',
2491 'uploader': 'nao20010128nao',
2492 'uploader_id': 'nao20010128nao',
2493 'categories': ['Music'],
2496 'channel_url': 'https://www.youtube.com/channel/UCdqltm_7iv1Vs6kp6Syke5A',
2497 'channel_id': 'UCdqltm_7iv1Vs6kp6Syke5A',
2498 'live_status': 'not_live',
2499 'playable_in_embed': True,
2500 'channel_follower_count': int,
2503 'uploader_url': 'http://www.youtube.com/user/nao20010128nao',
2506 # Prefer primary title+description language metadata by default
2507 # Do not prefer translated description if primary is empty
2508 'url': 'https://www.youtube.com/watch?v=el3E4MbxRqQ',
2510 'id': 'el3E4MbxRqQ',
2512 'title': 'dlp test video 2 - primary sv no desc',
2514 'channel': 'cole-dlp-test-acc',
2517 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
2519 'playable_in_embed': True,
2520 'availability': 'unlisted',
2521 'thumbnail': 'https://i.ytimg.com/vi_webp/el3E4MbxRqQ/maxresdefault.webp',
2524 'uploader_id': 'UCiu-3thuViMebBjw_5nWYrA',
2525 'uploader_url': 'http://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
2526 'live_status': 'not_live',
2527 'upload_date': '20220908',
2528 'categories': ['People & Blogs'],
2529 'uploader': 'cole-dlp-test-acc',
2530 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
2532 'params': {'skip_download': True}
2534 # Extractor argument: prefer translated title+description
2535 'url': 'https://www.youtube.com/watch?v=gHKT4uU8Zng',
2537 'id': 'gHKT4uU8Zng',
2539 'channel': 'cole-dlp-test-acc',
2542 'live_status': 'not_live',
2543 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
2544 'upload_date': '20220728',
2545 'uploader_id': 'UCiu-3thuViMebBjw_5nWYrA',
2547 'categories': ['People & Blogs'],
2548 'thumbnail': 'https://i.ytimg.com/vi_webp/gHKT4uU8Zng/maxresdefault.webp',
2549 'title': 'dlp test video title translated (fr)',
2550 'availability': 'public',
2551 'uploader': 'cole-dlp-test-acc',
2553 'description': 'dlp test video description translated (fr)',
2554 'playable_in_embed': True,
2555 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
2556 'uploader_url': 'http://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
2558 'params': {'skip_download': True, 'extractor_args': {'youtube': {'lang': ['fr']}}},
2559 'expected_warnings': [r'Preferring "fr" translated fields'],
2561 'note': '6 channel audio',
2562 'url': 'https://www.youtube.com/watch?v=zgdo7-RRjgo',
2563 'only_matching': True,
2565 'note': 'Multiple HLS formats with same itag',
2566 'url': 'https://www.youtube.com/watch?v=kX3nB4PpJko',
2568 'id': 'kX3nB4PpJko',
2570 'categories': ['Entertainment'],
2571 'description': 'md5:e8031ff6e426cdb6a77670c9b81f6fa6',
2572 'uploader_url': 'http://www.youtube.com/user/MrBeast6000',
2573 'live_status': 'not_live',
2575 'channel_follower_count': int,
2576 'thumbnail': 'https://i.ytimg.com/vi_webp/kX3nB4PpJko/maxresdefault.webp',
2577 'title': 'Last To Take Hand Off Jet, Keeps It!',
2578 'channel': 'MrBeast',
2579 'playable_in_embed': True,
2581 'upload_date': '20221112',
2582 'uploader': 'MrBeast',
2583 'uploader_id': 'MrBeast6000',
2584 'channel_url': 'https://www.youtube.com/channel/UCX6OQ3DkcsbYNE6H8uQQuVA',
2586 'availability': 'public',
2587 'channel_id': 'UCX6OQ3DkcsbYNE6H8uQQuVA',
2591 'params': {'extractor_args': {'youtube': {'player_client': ['ios']}}, 'format': '233-1'},
2593 'note': 'Audio formats with Dynamic Range Compression',
2594 'url': 'https://www.youtube.com/watch?v=Tq92D6wQ1mg',
2596 'id': 'Tq92D6wQ1mg',
2598 'title': '[MMD] Adios - EVERGLOW [+Motion DL]',
2599 'channel_url': 'https://www.youtube.com/channel/UC1yoRdFoFJaCY-AGfD9W0wQ',
2600 'channel_id': 'UC1yoRdFoFJaCY-AGfD9W0wQ',
2601 'channel_follower_count': int,
2602 'description': 'md5:17eccca93a786d51bc67646756894066',
2603 'upload_date': '20191228',
2604 'uploader_url': 'http://www.youtube.com/channel/UC1yoRdFoFJaCY-AGfD9W0wQ',
2605 'tags': ['mmd', 'dance', 'mikumikudance', 'kpop', 'vtuber'],
2606 'playable_in_embed': True,
2608 'categories': ['Entertainment'],
2609 'thumbnail': 'https://i.ytimg.com/vi/Tq92D6wQ1mg/sddefault.jpg',
2611 'channel': 'Projekt Melody',
2612 'uploader_id': 'UC1yoRdFoFJaCY-AGfD9W0wQ',
2614 'availability': 'needs_auth',
2615 'comment_count': int,
2616 'live_status': 'not_live',
2617 'uploader': 'Projekt Melody',
2620 'params': {'extractor_args': {'youtube': {'player_client': ['tv_embedded']}}, 'format': '251-drc'},
2623 'url': 'https://www.youtube.com/live/qVv6vCqciTM',
2625 'id': 'qVv6vCqciTM',
2628 'uploader_id': 'UCIdEIHpS0TdkqRkHL5OkLtA',
2629 'comment_count': int,
2630 'chapters': 'count:13',
2631 'upload_date': '20221223',
2632 'thumbnail': 'https://i.ytimg.com/vi/qVv6vCqciTM/maxresdefault.jpg',
2633 'channel_url': 'https://www.youtube.com/channel/UCIdEIHpS0TdkqRkHL5OkLtA',
2634 'uploader_url': 'http://www.youtube.com/channel/UCIdEIHpS0TdkqRkHL5OkLtA',
2636 'release_date': '20221223',
2637 'tags': ['Vtuber', '月ノ美兎', '名取さな', 'にじさんじ', 'クリスマス', '3D配信'],
2638 'title': '【 #インターネット女クリスマス 】3Dで歌ってはしゃぐインターネットの女たち【月ノ美兎/名取さな】',
2640 'playable_in_embed': True,
2642 'availability': 'public',
2643 'channel_follower_count': int,
2644 'channel_id': 'UCIdEIHpS0TdkqRkHL5OkLtA',
2645 'categories': ['Entertainment'],
2646 'live_status': 'was_live',
2647 'release_timestamp': 1671793345,
2648 'channel': 'さなちゃんねる',
2649 'description': 'md5:6aebf95cc4a1d731aebc01ad6cc9806d',
2650 'uploader': 'さなちゃんねる',
2656 # YouTube <object> embed
2658 'url': 'http://www.improbable.com/2017/04/03/untrained-modern-youths-and-ancient-masters-in-selfie-portraits/',
2659 'md5': '873c81d308b979f0e23ee7e620b312a3',
2661 'id': 'msN87y-iEx0',
2663 'title': 'Feynman: Mirrors FUN TO IMAGINE 6',
2664 'upload_date': '20080526',
2665 'description': 'md5:873c81d308b979f0e23ee7e620b312a3',
2666 'uploader': 'Christopher Sykes',
2667 'uploader_id': 'ChristopherJSykes',
2669 'tags': ['feynman', 'mirror', 'science', 'physics', 'imagination', 'fun', 'cool', 'puzzle'],
2670 'channel_id': 'UCCeo--lls1vna5YJABWAcVA',
2671 'playable_in_embed': True,
2672 'thumbnail': 'https://i.ytimg.com/vi/msN87y-iEx0/hqdefault.jpg',
2674 'comment_count': int,
2675 'channel': 'Christopher Sykes',
2676 'live_status': 'not_live',
2677 'channel_url': 'https://www.youtube.com/channel/UCCeo--lls1vna5YJABWAcVA',
2678 'availability': 'public',
2681 'categories': ['Science & Technology'],
2682 'channel_follower_count': int,
2683 'uploader_url': 'http://www.youtube.com/user/ChristopherJSykes',
2686 'skip_download': True,
2692 def suitable(cls, url):
2693 from ..utils import parse_qs
2696 if qs.get('list', [None])[0]:
2698 return super().suitable(url)
2700 def __init__(self, *args, **kwargs):
2701 super().__init__(*args, **kwargs)
2702 self._code_cache = {}
2703 self._player_cache = {}
2705 def _prepare_live_from_start_formats(self, formats, video_id, live_start_time, url, webpage_url, smuggled_data, is_live):
2706 lock = threading.Lock()
2707 start_time = time.time()
2708 formats = [f for f in formats if f.get('is_from_start')]
2710 def refetch_manifest(format_id, delay):
2711 nonlocal formats, start_time, is_live
2712 if time.time() <= start_time + delay:
2715 _, _, prs, player_url = self._download_player_responses(url, smuggled_data, video_id, webpage_url)
2716 video_details = traverse_obj(prs, (..., 'videoDetails'), expected_type=dict)
2717 microformats = traverse_obj(
2718 prs, (..., 'microformat', 'playerMicroformatRenderer'),
2720 _, live_status, _, formats, _ = self._list_formats(video_id, microformats, video_details, prs, player_url)
2721 is_live = live_status == 'is_live'
2722 start_time = time.time()
2724 def mpd_feed(format_id, delay):
2726 @returns (manifest_url, manifest_stream_number, is_live) or None
2728 for retry in self.RetryManager(fatal=False):
2730 refetch_manifest(format_id, delay)
2732 f = next((f for f in formats if f['format_id'] == format_id), None)
2735 retry.error = f'{video_id}: Video is no longer live'
2737 retry.error = f'Cannot find refreshed manifest for format {format_id}{bug_reports_message()}'
2739 return f['manifest_url'], f['manifest_stream_number'], is_live
2743 f['is_live'] = is_live
2744 gen = functools.partial(self._live_dash_fragments, video_id, f['format_id'],
2745 live_start_time, mpd_feed, not is_live and f.copy())
2747 f['fragments'] = gen
2748 f['protocol'] = 'http_dash_segments_generator'
2750 f['fragments'] = LazyList(gen({}))
2751 del f['is_from_start']
2753 def _live_dash_fragments(self, video_id, format_id, live_start_time, mpd_feed, manifestless_orig_fmt, ctx):
2754 FETCH_SPAN, MAX_DURATION = 5, 432000
2756 mpd_url, stream_number, is_live = None, None, True
2759 download_start_time = ctx.get('start') or time.time()
2761 lack_early_segments = download_start_time - (live_start_time or download_start_time) > MAX_DURATION
2762 if lack_early_segments:
2763 self.report_warning(bug_reports_message(
2764 'Starting download from the last 120 hours of the live stream since '
2765 'YouTube does not have data before that. If you think this is wrong,'), only_once=True)
2766 lack_early_segments = True
2768 known_idx, no_fragment_score, last_segment_url = begin_index, 0, None
2769 fragments, fragment_base_url = None, None
2771 def _extract_sequence_from_mpd(refresh_sequence, immediate):
2772 nonlocal mpd_url, stream_number, is_live, no_fragment_score, fragments, fragment_base_url
2773 # Obtain from MPD's maximum seq value
2774 old_mpd_url = mpd_url
2775 last_error = ctx.pop('last_error', None)
2776 expire_fast = immediate or last_error and isinstance(last_error, urllib.error.HTTPError) and last_error.code == 403
2777 mpd_url, stream_number, is_live = (mpd_feed(format_id, 5 if expire_fast else 18000)
2778 or (mpd_url, stream_number, False))
2779 if not refresh_sequence:
2780 if expire_fast and not is_live:
2781 return False, last_seq
2782 elif old_mpd_url == mpd_url:
2783 return True, last_seq
2784 if manifestless_orig_fmt:
2785 fmt_info = manifestless_orig_fmt
2788 fmts, _ = self._extract_mpd_formats_and_subtitles(
2789 mpd_url, None, note=False, errnote=False, fatal=False)
2790 except ExtractorError:
2793 no_fragment_score += 2
2794 return False, last_seq
2795 fmt_info = next(x for x in fmts if x['manifest_stream_number'] == stream_number)
2796 fragments = fmt_info['fragments']
2797 fragment_base_url = fmt_info['fragment_base_url']
2798 assert fragment_base_url
2800 _last_seq = int(re.search(r'(?:/|^)sq/(\d+)', fragments[-1]['path']).group(1))
2801 return True, _last_seq
2803 self.write_debug(f'[{video_id}] Generating fragments for format {format_id}')
2805 fetch_time = time.time()
2806 if no_fragment_score > 30:
2808 if last_segment_url:
2809 # Obtain from "X-Head-Seqnum" header value from each segment
2811 urlh = self._request_webpage(
2812 last_segment_url, None, note=False, errnote=False, fatal=False)
2813 except ExtractorError:
2815 last_seq = try_get(urlh, lambda x: int_or_none(x.headers['X-Head-Seqnum']))
2816 if last_seq is None:
2817 no_fragment_score += 2
2818 last_segment_url = None
2821 should_continue, last_seq = _extract_sequence_from_mpd(True, no_fragment_score > 15)
2822 no_fragment_score += 2
2823 if not should_continue:
2826 if known_idx > last_seq:
2827 last_segment_url = None
2832 if begin_index < 0 and known_idx < 0:
2833 # skip from the start when it's negative value
2834 known_idx = last_seq + begin_index
2835 if lack_early_segments:
2836 known_idx = max(known_idx, last_seq - int(MAX_DURATION // fragments[-1]['duration']))
2838 for idx in range(known_idx, last_seq):
2839 # do not update sequence here or you'll get skipped some part of it
2840 should_continue, _ = _extract_sequence_from_mpd(False, False)
2841 if not should_continue:
2843 raise ExtractorError('breaking out of outer loop')
2844 last_segment_url = urljoin(fragment_base_url, 'sq/%d' % idx)
2846 'url': last_segment_url,
2847 'fragment_count': last_seq,
2849 if known_idx == last_seq:
2850 no_fragment_score += 5
2852 no_fragment_score = 0
2853 known_idx = last_seq
2854 except ExtractorError:
2857 if manifestless_orig_fmt:
2858 # Stop at the first iteration if running for post-live manifestless;
2859 # fragment count no longer increase since it starts
2862 time.sleep(max(0, FETCH_SPAN + fetch_time - time.time()))
2864 def _extract_player_url(self, *ytcfgs, webpage=None):
2865 player_url = traverse_obj(
2866 ytcfgs, (..., 'PLAYER_JS_URL'), (..., 'WEB_PLAYER_CONTEXT_CONFIGS', ..., 'jsUrl'),
2867 get_all=False, expected_type=str)
2870 return urljoin('https://www.youtube.com', player_url)
2872 def _download_player_url(self, video_id, fatal=False):
2873 res = self._download_webpage(
2874 'https://www.youtube.com/iframe_api',
2875 note='Downloading iframe API JS', video_id=video_id, fatal=fatal)
2877 player_version = self._search_regex(
2878 r'player\\?/([0-9a-fA-F]{8})\\?/', res, 'player version', fatal=fatal)
2880 return f'https://www.youtube.com/s/player/{player_version}/player_ias.vflset/en_US/base.js'
2882 def _signature_cache_id(self, example_sig):
2883 """ Return a string representation of a signature """
2884 return '.'.join(str(len(part)) for part in example_sig.split('.'))
2887 def _extract_player_info(cls, player_url):
2888 for player_re in cls._PLAYER_INFO_RE:
2889 id_m = re.search(player_re, player_url)
2893 raise ExtractorError('Cannot identify player %r' % player_url)
2894 return id_m.group('id')
2896 def _load_player(self, video_id, player_url, fatal=True):
2897 player_id = self._extract_player_info(player_url)
2898 if player_id not in self._code_cache:
2899 code = self._download_webpage(
2900 player_url, video_id, fatal=fatal,
2901 note='Downloading player ' + player_id,
2902 errnote='Download of %s failed' % player_url)
2904 self._code_cache[player_id] = code
2905 return self._code_cache.get(player_id)
2907 def _extract_signature_function(self, video_id, player_url, example_sig):
2908 player_id = self._extract_player_info(player_url)
2910 # Read from filesystem cache
2911 func_id = f'js_{player_id}_{self._signature_cache_id(example_sig)}'
2912 assert os.path.basename(func_id) == func_id
2914 self.write_debug(f'Extracting signature function {func_id}')
2915 cache_spec, code = self.cache.load('youtube-sigfuncs', func_id), None
2918 code = self._load_player(video_id, player_url)
2920 res = self._parse_sig_js(code)
2921 test_string = ''.join(map(chr, range(len(example_sig))))
2922 cache_spec = [ord(c) for c in res(test_string)]
2923 self.cache.store('youtube-sigfuncs', func_id, cache_spec)
2925 return lambda s: ''.join(s[i] for i in cache_spec)
2927 def _print_sig_code(self, func, example_sig):
2928 if not self.get_param('youtube_print_sig_code'):
2931 def gen_sig_code(idxs):
2932 def _genslice(start, end, step):
2933 starts = '' if start == 0 else str(start)
2934 ends = (':%d' % (end + step)) if end + step >= 0 else ':'
2935 steps = '' if step == 1 else (':%d' % step)
2936 return f's[{starts}{ends}{steps}]'
2939 # Quelch pyflakes warnings - start will be set when step is set
2940 start = '(Never used)'
2941 for i, prev in zip(idxs[1:], idxs[:-1]):
2942 if step is not None:
2943 if i - prev == step:
2945 yield _genslice(start, prev, step)
2948 if i - prev in [-1, 1]:
2953 yield 's[%d]' % prev
2957 yield _genslice(start, i, step)
2959 test_string = ''.join(map(chr, range(len(example_sig))))
2960 cache_res = func(test_string)
2961 cache_spec = [ord(c) for c in cache_res]
2962 expr_code = ' + '.join(gen_sig_code(cache_spec))
2963 signature_id_tuple = '(%s)' % (
2964 ', '.join(str(len(p)) for p in example_sig.split('.')))
2965 code = ('if tuple(len(p) for p in s.split(\'.\')) == %s:\n'
2966 ' return %s\n') % (signature_id_tuple, expr_code)
2967 self.to_screen('Extracted signature function:\n' + code)
2969 def _parse_sig_js(self, jscode):
2970 funcname = self._search_regex(
2971 (r'\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2972 r'\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2973 r'\bm=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(h\.s\)\)',
2974 r'\bc&&\(c=(?P<sig>[a-zA-Z0-9$]{2,})\(decodeURIComponent\(c\)\)',
2975 r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\);[a-zA-Z0-9$]{2}\.[a-zA-Z0-9$]{2}\(a,\d+\)',
2976 r'(?:\b|[^a-zA-Z0-9$])(?P<sig>[a-zA-Z0-9$]{2,})\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
2977 r'(?P<sig>[a-zA-Z0-9$]+)\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)',
2979 r'(["\'])signature\1\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2980 r'\.sig\|\|(?P<sig>[a-zA-Z0-9$]+)\(',
2981 r'yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*(?:encodeURIComponent\s*\()?\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2982 r'\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2983 r'\b[a-zA-Z0-9]+\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2984 r'\bc\s*&&\s*a\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2985 r'\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\(',
2986 r'\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('),
2987 jscode, 'Initial JS player signature function name', group='sig')
2989 jsi = JSInterpreter(jscode)
2990 initial_function = jsi.extract_function(funcname)
2991 return lambda s: initial_function([s])
2993 def _cached(self, func, *cache_id):
2994 def inner(*args, **kwargs):
2995 if cache_id not in self._player_cache:
2997 self._player_cache[cache_id] = func(*args, **kwargs)
2998 except ExtractorError as e:
2999 self._player_cache[cache_id] = e
3000 except Exception as e:
3001 self._player_cache[cache_id] = ExtractorError(traceback.format_exc(), cause=e)
3003 ret = self._player_cache[cache_id]
3004 if isinstance(ret, Exception):
3009 def _decrypt_signature(self, s, video_id, player_url):
3010 """Turn the encrypted s field into a working signature"""
3011 extract_sig = self._cached(
3012 self._extract_signature_function, 'sig', player_url, self._signature_cache_id(s))
3013 func = extract_sig(video_id, player_url, s)
3014 self._print_sig_code(func, s)
3017 def _decrypt_nsig(self, s, video_id, player_url):
3018 """Turn the encrypted n field into a working signature"""
3019 if player_url is None:
3020 raise ExtractorError('Cannot decrypt nsig without player_url')
3021 player_url = urljoin('https://www.youtube.com', player_url)
3024 jsi, player_id, func_code = self._extract_n_function_code(video_id, player_url)
3025 except ExtractorError as e:
3026 raise ExtractorError('Unable to extract nsig function code', cause=e)
3027 if self.get_param('youtube_print_sig_code'):
3028 self.to_screen(f'Extracted nsig function from {player_id}:\n{func_code[1]}\n')
3031 extract_nsig = self._cached(self._extract_n_function_from_code, 'nsig func', player_url)
3032 ret = extract_nsig(jsi, func_code)(s)
3033 except JSInterpreter.Exception as e:
3035 jsi = PhantomJSwrapper(self, timeout=5000)
3036 except ExtractorError:
3038 self.report_warning(
3039 f'Native nsig extraction failed: Trying with PhantomJS\n'
3040 f' n = {s} ; player = {player_url}', video_id)
3041 self.write_debug(e, only_once=True)
3043 args, func_body = func_code
3045 f'console.log(function({", ".join(args)}) {{ {func_body} }}({s!r}));',
3046 video_id=video_id, note='Executing signature code').strip()
3048 self.write_debug(f'Decrypted nsig {s} => {ret}')
3051 def _extract_n_function_name(self, jscode):
3052 funcname, idx = self._search_regex(
3053 r'\.get\("n"\)\)&&\(b=(?P<nfunc>[a-zA-Z0-9$]+)(?:\[(?P<idx>\d+)\])?\([a-zA-Z0-9]\)',
3054 jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
3058 return json.loads(js_to_json(self._search_regex(
3059 rf'var {re.escape(funcname)}\s*=\s*(\[.+?\]);', jscode,
3060 f'Initial JS player n function list ({funcname}.{idx})')))[int(idx)]
3062 def _extract_n_function_code(self, video_id, player_url):
3063 player_id = self._extract_player_info(player_url)
3064 func_code = self.cache.load('youtube-nsig', player_id, min_ver='2022.09.1')
3065 jscode = func_code or self._load_player(video_id, player_url)
3066 jsi = JSInterpreter(jscode)
3069 return jsi, player_id, func_code
3071 func_name = self._extract_n_function_name(jscode)
3074 func_code = self._search_regex(
3075 r'''(?xs
)%s\s
*=\s
*function\s
*\
((?P
<var
>[\w$
]+)\
)\s
*
3076 # NB: The end of the regex is intentionally kept strict
3077 {(?P<code>.+?}\s
*return\
[\w$
]+.join\
(""\
))};''' % func_name,
3078 jscode, 'nsig function', group=('var', 'code'), default=None)
3080 func_code = ([func_code[0]], func_code[1])
3082 self.write_debug('Extracting nsig function with jsinterp')
3083 func_code = jsi.extract_function_code(func_name)
3085 self.cache.store('youtube-nsig', player_id, func_code)
3086 return jsi, player_id, func_code
3088 def _extract_n_function_from_code(self, jsi, func_code):
3089 func = jsi.extract_function_from_code(*func_code)
3091 def extract_nsig(s):
3094 except JSInterpreter.Exception:
3096 except Exception as e:
3097 raise JSInterpreter.Exception(traceback.format_exc(), cause=e)
3099 if ret.startswith('enhanced_except_'):
3100 raise JSInterpreter.Exception('Signature function returned an exception')
3105 def _extract_signature_timestamp(self, video_id, player_url, ytcfg=None, fatal=False):
3107 Extract signatureTimestamp (sts)
3108 Required to tell API what sig/player version is in use.
3111 if isinstance(ytcfg, dict):
3112 sts = int_or_none(ytcfg.get('STS'))
3115 # Attempt to extract from player
3116 if player_url is None:
3117 error_msg = 'Cannot extract signature timestamp without player_url.'
3119 raise ExtractorError(error_msg)
3120 self.report_warning(error_msg)
3122 code = self._load_player(video_id, player_url, fatal=fatal)
3124 sts = int_or_none(self._search_regex(
3125 r'(?:signatureTimestamp|sts)\s*:\s*(?P<sts>[0-9]{5})', code,
3126 'JS player signature timestamp', group='sts', fatal=fatal))
3129 def _mark_watched(self, video_id, player_responses):
3130 for is_full, key in enumerate(('videostatsPlaybackUrl', 'videostatsWatchtimeUrl')):
3131 label = 'fully ' if is_full else ''
3132 url = get_first(player_responses, ('playbackTracking', key, 'baseUrl'),
3133 expected_type=url_or_none)
3135 self.report_warning(f'Unable to mark {label}watched')
3137 parsed_url = urllib.parse.urlparse(url)
3138 qs = urllib.parse.parse_qs(parsed_url.query)
3140 # cpn generation algorithm is reverse engineered from base.js.
3141 # In fact it works even with dummy cpn.
3142 CPN_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
3143 cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16))
3145 # # more consistent results setting it to right before the end
3146 video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
3151 'cmt': video_length,
3152 'el': 'detailpage', # otherwise defaults to "shorts"
3156 # these seem to mark watchtime "history" in the real world
3157 # they're required, so send in a single value
3163 url = urllib.parse.urlunparse(
3164 parsed_url._replace(query=urllib.parse.urlencode(qs, True)))
3166 self._download_webpage(
3167 url, video_id, f'Marking {label}watched',
3168 'Unable to mark watched', fatal=False)
3171 def _extract_from_webpage(cls, url, webpage):
3172 # Invidious Instances
3173 # https://github.com/yt-dlp/yt-dlp/issues/195
3174 # https://github.com/iv-org/invidious/pull/1730
3176 r'<link rel="alternate" href="(?P<url>https://www\.youtube\.com/watch\?v=[0-9A-Za-z_-]{11})"',
3179 yield cls.url_result(mobj.group('url'), cls)
3180 raise cls.StopExtraction()
3182 yield from super()._extract_from_webpage(url, webpage)
3184 # lazyYT YouTube embed
3185 for id_ in re.findall(r'class="lazyYT" data-youtube-id="([^"]+)"', webpage):
3186 yield cls.url_result(unescapeHTML(id_), cls, id_)
3188 # Wordpress "YouTube Video Importer" plugin
3189 for m in re.findall(r'''(?x
)<div
[^
>]+
3190 class=(?P
<q1
>[\'"])[^\'"]*\byvii
_single
_video
_player
\b[^
\'"]*(?P=q1)[^>]+
3191 data-video_id=(?P<q2>[\'"])([^
\'"]+)(?P=q2)''', webpage):
3192 yield cls.url_result(m[-1], cls, m[-1])
3195 def extract_id(cls, url):
3196 video_id = cls.get_temp_id(url)
3198 raise ExtractorError(f'Invalid URL: {url}')
3201 def _extract_chapters_from_json(self, data, duration):
3202 chapter_list = traverse_obj(
3204 'playerOverlays', 'playerOverlayRenderer', 'decoratedPlayerBarRenderer',
3205 'decoratedPlayerBarRenderer', 'playerBar', 'chapteredPlayerBarRenderer', 'chapters'
3206 ), expected_type=list)
3208 return self._extract_chapters_helper(
3210 start_function=lambda chapter: float_or_none(
3211 traverse_obj(chapter, ('chapterRenderer', 'timeRangeStartMillis')), scale=1000),
3212 title_function=lambda chapter: traverse_obj(
3213 chapter, ('chapterRenderer', 'title', 'simpleText'), expected_type=str),
3216 def _extract_chapters_from_engagement_panel(self, data, duration):
3217 content_list = traverse_obj(
3219 ('engagementPanels', ..., 'engagementPanelSectionListRenderer', 'content', 'macroMarkersListRenderer', 'contents'),
3221 chapter_time = lambda chapter: parse_duration(self._get_text(chapter, 'timeDescription'))
3222 chapter_title = lambda chapter: self._get_text(chapter, 'title')
3224 return next(filter(None, (
3225 self._extract_chapters_helper(traverse_obj(contents, (..., 'macroMarkersListItemRenderer')),
3226 chapter_time, chapter_title, duration)
3227 for contents in content_list)), [])
3229 def _extract_comment(self, comment_renderer, parent=None):
3230 comment_id = comment_renderer.get('commentId')
3234 text = self._get_text(comment_renderer, 'contentText')
3236 # Timestamp is an estimate calculated from the current time and time_text
3237 time_text = self._get_text(comment_renderer, 'publishedTimeText') or ''
3238 timestamp = self._parse_time_text(time_text)
3240 author = self._get_text(comment_renderer, 'authorText')
3241 author_id = try_get(comment_renderer,
3242 lambda x: x['authorEndpoint']['browseEndpoint']['browseId'], str)
3244 votes = parse_count(try_get(comment_renderer, (lambda x: x['voteCount']['simpleText'],
3245 lambda x: x['likeCount']), str)) or 0
3246 author_thumbnail = try_get(comment_renderer,
3247 lambda x: x['authorThumbnail']['thumbnails'][-1]['url'], str)
3249 author_is_uploader = try_get(comment_renderer, lambda x: x['authorIsChannelOwner'], bool)
3250 is_favorited = 'creatorHeart' in (try_get(
3251 comment_renderer, lambda x: x['actionButtons']['commentActionButtonsRenderer'], dict) or {})
3255 'timestamp': timestamp,
3256 'time_text': time_text,
3257 'like_count': votes,
3258 'is_favorited': is_favorited,
3260 'author_id': author_id,
3261 'author_thumbnail': author_thumbnail,
3262 'author_is_uploader': author_is_uploader,
3263 'parent': parent or 'root'
3266 def _comment_entries(self, root_continuation_data, ytcfg, video_id, parent=None, tracker=None):
3268 get_single_config_arg = lambda c: self._configuration_arg(c, [''])[0]
3270 def extract_header(contents):
3271 _continuation = None
3272 for content in contents:
3273 comments_header_renderer = traverse_obj(content, 'commentsHeaderRenderer')
3274 expected_comment_count = self._get_count(
3275 comments_header_renderer, 'countText', 'commentsCount')
3277 if expected_comment_count:
3278 tracker['est_total'] = expected_comment_count
3279 self.to_screen(f'Downloading ~{expected_comment_count} comments')
3280 comment_sort_index = int(get_single_config_arg('comment_sort') != 'top') # 1 = new, 0 = top
3282 sort_menu_item = try_get(
3283 comments_header_renderer,
3284 lambda x: x['sortMenu']['sortFilterSubMenuRenderer']['subMenuItems'][comment_sort_index], dict) or {}
3285 sort_continuation_ep = sort_menu_item.get('serviceEndpoint') or {}
3287 _continuation = self._extract_continuation_ep_data(sort_continuation_ep) or self._extract_continuation(sort_menu_item)
3288 if not _continuation:
3291 sort_text = str_or_none(sort_menu_item.get('title'))
3293 sort_text = 'top comments' if comment_sort_index == 0 else 'newest first'
3294 self.to_screen('Sorting comments by %s' % sort_text.lower())
3296 return _continuation
3298 def extract_thread(contents):
3300 tracker['current_page_thread'] = 0
3301 for content in contents:
3302 if not parent and tracker['total_parent_comments'] >= max_parents:
3304 comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
3305 comment_renderer = get_first(
3306 (comment_thread_renderer, content), [['commentRenderer', ('comment', 'commentRenderer')]],
3307 expected_type=dict, default={})
3309 comment = self._extract_comment(comment_renderer, parent)
3312 # Sometimes YouTube may break and give us infinite looping comments.
3313 # See: https://github.com/yt-dlp/yt-dlp/issues/6290
3314 if comment['id'] in tracker['seen_comment_ids']:
3315 self.report_warning('Detected YouTube comments looping. Stopping comment extraction as we probably cannot get any more.')
3318 tracker['seen_comment_ids'].add(comment['id'])
3320 tracker['running_total'] += 1
3321 tracker['total_reply_comments' if parent else 'total_parent_comments'] += 1
3324 # Attempt to get the replies
3325 comment_replies_renderer = try_get(
3326 comment_thread_renderer, lambda x: x['replies']['commentRepliesRenderer'], dict)
3328 if comment_replies_renderer:
3329 tracker['current_page_thread'] += 1
3330 comment_entries_iter = self._comment_entries(
3331 comment_replies_renderer, ytcfg, video_id,
3332 parent=comment.get('id'), tracker=tracker)
3333 yield from itertools.islice(comment_entries_iter, min(
3334 max_replies_per_thread, max(0, max_replies - tracker['total_reply_comments'])))
3336 # Keeps track of counts across recursive calls
3341 current_page_thread=0,
3342 total_parent_comments=0,
3343 total_reply_comments=0,
3344 seen_comment_ids=set())
3347 # YouTube comments have a max depth of 2
3348 max_depth = int_or_none(get_single_config_arg('max_comment_depth'))
3350 self._downloader.deprecated_feature('[youtube] max_comment_depth extractor argument is deprecated. '
3351 'Set max replies in the max-comments extractor argument instead')
3352 if max_depth == 1 and parent:
3355 max_comments, max_parents, max_replies, max_replies_per_thread, *_ = map(
3356 lambda p: int_or_none(p, default=sys.maxsize), self._configuration_arg('max_comments', ) + [''] * 4)
3358 continuation = self._extract_continuation(root_continuation_data)
3361 is_forced_continuation = False
3362 is_first_continuation = parent is None
3363 if is_first_continuation and not continuation:
3364 # Sometimes you can get comments by generating the continuation yourself,
3365 # even if YouTube initially reports them being disabled - e.g. stories comments.
3366 # Note: if the comment section is actually disabled, YouTube may return a response with
3367 # required check_get_keys missing. So we will disable that check initially in this case.
3368 continuation = self._build_api_continuation_query(self._generate_comment_continuation(video_id))
3369 is_forced_continuation = True
3371 for page_num in itertools.count(0):
3372 if not continuation:
3374 headers = self.generate_api_headers(ytcfg=ytcfg, visitor_data=self._extract_visitor_data(response))
3375 comment_prog_str = f"({tracker['running_total']}
/{tracker['est_total']}
)"
3377 if is_first_continuation:
3378 note_prefix = 'Downloading comment section API JSON'
3380 note_prefix = ' Downloading comment API JSON reply thread %d %s' % (
3381 tracker['current_page_thread'], comment_prog_str)
3383 note_prefix = '%sDownloading comment%s API JSON page %d %s' % (
3384 ' ' if parent else '', ' replies' if parent else '',
3385 page_num, comment_prog_str)
3387 response = self._extract_response(
3388 item_id=None, query=continuation,
3389 ep='next', ytcfg=ytcfg, headers=headers, note=note_prefix,
3390 check_get_keys='onResponseReceivedEndpoints' if not is_forced_continuation else None)
3391 except ExtractorError as e:
3392 # Ignore incomplete data error for replies if retries didn't work.
3393 # This is to allow any other parent comments and comment threads to be downloaded.
3394 # See: https://github.com/yt-dlp/yt-dlp/issues/4669
3395 if 'incomplete data' in str(e).lower() and parent and self.get_param('ignoreerrors') is True:
3396 self.report_warning(
3397 'Received incomplete data for a comment reply thread and retrying did not help. '
3398 'Ignoring to let other comments be downloaded.')
3401 is_forced_continuation = False
3402 continuation_contents = traverse_obj(
3403 response, 'onResponseReceivedEndpoints', expected_type=list, default=[])
3406 for continuation_section in continuation_contents:
3407 continuation_items = traverse_obj(
3408 continuation_section,
3409 (('reloadContinuationItemsCommand', 'appendContinuationItemsAction'), 'continuationItems'),
3410 get_all=False, expected_type=list) or []
3411 if is_first_continuation:
3412 continuation = extract_header(continuation_items)
3413 is_first_continuation = False
3418 for entry in extract_thread(continuation_items):
3422 continuation = self._extract_continuation({'contents': continuation_items})
3426 message = self._get_text(root_continuation_data, ('contents', ..., 'messageRenderer', 'text'), max_runs=1)
3427 if message and not parent and tracker['running_total'] == 0:
3428 self.report_warning(f'Youtube said: {message}', video_id=video_id, only_once=True)
3429 raise self.CommentsDisabled
3432 def _generate_comment_continuation(video_id):
3434 Generates initial comment section continuation token from given video id
3436 token = f'\x12\r\x12\x0b{video_id}\x18\x062\'"\x11"\x0b{video_id}0\x00x\x020\x00B\x10comments-section'
3437 return base64.b64encode(token.encode()).decode()
3439 def _get_comments(self, ytcfg, video_id, contents, webpage):
3440 """Entry for comment extraction"""
3441 def _real_comment_extract(contents):
3443 item for item in traverse_obj(contents, (..., 'itemSectionRenderer'), default={})
3444 if item.get('sectionIdentifier') == 'comment-item-section'), None)
3445 yield from self._comment_entries(renderer, ytcfg, video_id)
3447 max_comments = int_or_none(self._configuration_arg('max_comments', [''])[0])
3448 return itertools.islice(_real_comment_extract(contents), 0, max_comments)
3451 def _get_checkok_params():
3452 return {'contentCheckOk': True, 'racyCheckOk': True}
3455 def _generate_player_context(cls, sts=None):
3457 'html5Preference': 'HTML5_PREF_WANTS',
3460 context['signatureTimestamp'] = sts
3462 'playbackContext': {
3463 'contentPlaybackContext': context
3465 **cls._get_checkok_params()
3469 def _is_agegated(player_response):
3470 if traverse_obj(player_response, ('playabilityStatus', 'desktopLegacyAgeGateReason')):
3473 reasons = traverse_obj(player_response, ('playabilityStatus', ('status', 'reason')))
3474 AGE_GATE_REASONS = (
3475 'confirm your age', 'age-restricted', 'inappropriate', # reason
3476 'age_verification_required', 'age_check_required', # status
3478 return any(expected in reason for expected in AGE_GATE_REASONS for reason in reasons)
3481 def _is_unplayable(player_response):
3482 return traverse_obj(player_response, ('playabilityStatus', 'status')) == 'UNPLAYABLE'
3484 _STORY_PLAYER_PARAMS = '8AEB'
3486 def _extract_player_response(self, client, video_id, master_ytcfg, player_ytcfg, player_url, initial_pr, smuggled_data):
3488 session_index = self._extract_session_index(player_ytcfg, master_ytcfg)
3489 syncid = self._extract_account_syncid(player_ytcfg, master_ytcfg, initial_pr)
3490 sts = self._extract_signature_timestamp(video_id, player_url, master_ytcfg, fatal=False) if player_url else None
3491 headers = self.generate_api_headers(
3492 ytcfg=player_ytcfg, account_syncid=syncid, session_index=session_index, default_client=client)
3495 'videoId': video_id,
3497 if smuggled_data.get('is_story') or _split_innertube_client(client)[0] == 'android':
3498 yt_query['params'] = self._STORY_PLAYER_PARAMS
3500 yt_query.update(self._generate_player_context(sts))
3501 return self._extract_response(
3502 item_id=video_id, ep='player', query=yt_query,
3503 ytcfg=player_ytcfg, headers=headers, fatal=True,
3504 default_client=client,
3505 note='Downloading %s player API JSON' % client.replace('_', ' ').strip()
3508 def _get_requested_clients(self, url, smuggled_data):
3509 requested_clients = []
3510 default = ['android', 'web']
3511 allowed_clients = sorted(
3512 (client for client in INNERTUBE_CLIENTS.keys() if client[:1] != '_'),
3513 key=lambda client: INNERTUBE_CLIENTS[client]['priority'], reverse=True)
3514 for client in self._configuration_arg('player_client'):
3515 if client in allowed_clients:
3516 requested_clients.append(client)
3517 elif client == 'default':
3518 requested_clients.extend(default)
3519 elif client == 'all':
3520 requested_clients.extend(allowed_clients)
3522 self.report_warning(f'Skipping unsupported client {client}')
3523 if not requested_clients:
3524 requested_clients = default
3526 if smuggled_data.get('is_music_url') or self.is_music_url(url):
3527 requested_clients.extend(
3528 f'{client}_music' for client in requested_clients if f'{client}_music' in INNERTUBE_CLIENTS)
3530 return orderedSet(requested_clients)
3532 def _extract_player_responses(self, clients, video_id, webpage, master_ytcfg, smuggled_data):
3535 initial_pr = self._search_json(
3536 self._YT_INITIAL_PLAYER_RESPONSE_RE, webpage, 'initial player response', video_id, fatal=False)
3538 all_clients = set(clients)
3539 clients = clients[::-1]
3542 def append_client(*client_names):
3543 """ Append the first client name that exists but not already used """
3544 for client_name in client_names:
3545 actual_client = _split_innertube_client(client_name)[0]
3546 if actual_client in INNERTUBE_CLIENTS:
3547 if actual_client not in all_clients:
3548 clients.append(client_name)
3549 all_clients.add(actual_client)
3552 # Android player_response does not have microFormats which are needed for
3553 # extraction of some data. So we return the initial_pr with formats
3554 # stripped out even if not requested by the user
3555 # See: https://github.com/yt-dlp/yt-dlp/issues/501
3557 pr = dict(initial_pr)
3558 pr['streamingData'] = None
3562 tried_iframe_fallback = False
3565 client, base_client, variant = _split_innertube_client(clients.pop())
3566 player_ytcfg = master_ytcfg if client == 'web' else {}
3567 if 'configs' not in self._configuration_arg('player_skip') and client != 'web':
3568 player_ytcfg = self._download_ytcfg(client, video_id) or player_ytcfg
3570 player_url = player_url or self._extract_player_url(master_ytcfg, player_ytcfg, webpage=webpage)
3571 require_js_player = self._get_default_ytcfg(client).get('REQUIRE_JS_PLAYER')
3572 if 'js' in self._configuration_arg('player_skip'):
3573 require_js_player = False
3576 if not player_url and not tried_iframe_fallback and require_js_player:
3577 player_url = self._download_player_url(video_id)
3578 tried_iframe_fallback = True
3581 pr = initial_pr if client == 'web' and initial_pr else self._extract_player_response(
3582 client, video_id, player_ytcfg or master_ytcfg, player_ytcfg, player_url if require_js_player else None, initial_pr, smuggled_data)
3583 except ExtractorError as e:
3585 self.report_warning(last_error)
3590 # YouTube may return a different video player response than expected.
3591 # See: https://github.com/TeamNewPipe/NewPipe/issues/8713
3592 pr_video_id = traverse_obj(pr, ('videoDetails', 'videoId'))
3593 if pr_video_id and pr_video_id != video_id:
3594 self.report_warning(
3595 f'Skipping player response from {client} client (got player response for video "{pr_video_id}
" instead of "{video_id}
")' + bug_reports_message())
3599 # creator clients can bypass AGE_VERIFICATION_REQUIRED if logged in
3600 if variant == 'embedded' and self._is_unplayable(pr) and self.is_authenticated:
3601 append_client(f'{base_client}_creator')
3602 elif self._is_agegated(pr):
3603 if variant == 'tv_embedded':
3604 append_client(f'{base_client}_embedded')
3606 append_client(f'tv_embedded.{base_client}', f'{base_client}_embedded')
3611 self.report_warning(last_error)
3612 return prs, player_url
3614 def _needs_live_processing(self, live_status, duration):
3615 if (live_status == 'is_live' and self.get_param('live_from_start')
3616 or live_status == 'post_live' and (duration or 0) > 4 * 3600):
3619 def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, live_status, duration):
3620 itags, stream_ids = collections.defaultdict(set), []
3621 itag_qualities, res_qualities = {}, {0: None}
3623 # Normally tiny is the smallest video-only formats. But
3624 # audio-only formats with unknown quality may get tagged as tiny
3626 'audio_quality_ultralow', 'audio_quality_low', 'audio_quality_medium', 'audio_quality_high', # Audio only formats
3627 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'
3629 streaming_formats = traverse_obj(streaming_data, (..., ('formats', 'adaptiveFormats'), ...))
3631 for fmt in streaming_formats:
3632 if fmt.get('targetDurationSec'):
3635 itag = str_or_none(fmt.get('itag'))
3636 audio_track = fmt.get('audioTrack') or {}
3637 stream_id = (itag, audio_track.get('id'), fmt.get('isDrc'))
3638 if stream_id in stream_ids:
3641 quality = fmt.get('quality')
3642 height = int_or_none(fmt.get('height'))
3643 if quality == 'tiny' or not quality:
3644 quality = fmt.get('audioQuality', '').lower() or quality
3645 # The 3gp format (17) in android client has a quality of "small
",
3646 # but is actually worse than other formats
3651 itag_qualities[itag] = quality
3653 res_qualities[height] = quality
3654 # FORMAT_STREAM_TYPE_OTF(otf=1) requires downloading the init fragment
3655 # (adding `&sq=0` to the URL) and parsing emsg box to determine the
3656 # number of fragment that would subsequently requested with (`&sq=N`)
3657 if fmt.get('type') == 'FORMAT_STREAM_TYPE_OTF':
3660 fmt_url = fmt.get('url')
3662 sc = urllib.parse.parse_qs(fmt.get('signatureCipher'))
3663 fmt_url = url_or_none(try_get(sc, lambda x: x['url'][0]))
3664 encrypted_sig = try_get(sc, lambda x: x['s'][0])
3665 if not all((sc, fmt_url, player_url, encrypted_sig)):
3668 fmt_url += '&%s=%s' % (
3669 traverse_obj(sc, ('sp', -1)) or 'signature',
3670 self._decrypt_signature(encrypted_sig, video_id, player_url)
3672 except ExtractorError as e:
3673 self.report_warning('Signature extraction failed: Some formats may be missing',
3674 video_id=video_id, only_once=True)
3675 self.write_debug(e, only_once=True)
3678 query = parse_qs(fmt_url)
3682 decrypt_nsig = self._cached(self._decrypt_nsig, 'nsig', query['n'][0])
3683 fmt_url = update_url_query(fmt_url, {
3684 'n': decrypt_nsig(query['n'][0], video_id, player_url)
3686 except ExtractorError as e:
3688 if isinstance(e, JSInterpreter.Exception):
3689 phantomjs_hint = (f' Install {self._downloader._format_err("PhantomJS", self._downloader.Styles.EMPHASIS)} '
3690 f'to workaround the issue. {PhantomJSwrapper.INSTALL_HINT}\n')
3692 self.report_warning(
3693 f'nsig extraction failed: You may experience throttling for some formats\n{phantomjs_hint}'
3694 f' n = {query["n"][0]} ; player = {player_url}', video_id=video_id, only_once=True)
3695 self.write_debug(e, only_once=True)
3697 self.report_warning(
3698 'Cannot decrypt nsig without player_url: You may experience throttling for some formats',
3699 video_id=video_id, only_once=True)
3702 tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1000)
3703 language_preference = (
3704 10 if audio_track.get('audioIsDefault') and 10
3705 else -10 if 'descriptive' in (audio_track.get('displayName') or '').lower() and -10
3707 # Some formats may have much smaller duration than others (possibly damaged during encoding)
3708 # E.g. 2-nOtRESiUc Ref: https://github.com/yt-dlp/yt-dlp/issues/2823
3709 # Make sure to avoid false positives with small duration differences.
3710 # E.g. __2ABJjxzNo, ySuUZEjARPY
3711 is_damaged = try_get(fmt, lambda x: float(x['approxDurationMs']) / duration < 500)
3713 self.report_warning(
3714 f'{video_id}: Some formats are possibly damaged. They will be deprioritized', only_once=True)
3716 'asr': int_or_none(fmt.get('audioSampleRate')),
3717 'filesize': int_or_none(fmt.get('contentLength')),
3718 'format_id': f'{itag}{"-drc" if fmt.get("isDrc") else ""}',
3719 'format_note': join_nonempty(
3720 '%s%s' % (audio_track.get('displayName') or '',
3721 ' (default)' if language_preference > 0 else ''),
3722 fmt.get('qualityLabel') or quality.replace('audio_quality_', ''),
3723 'DRC' if fmt.get('isDrc') else None,
3724 try_get(fmt, lambda x: x['projectionType'].replace('RECTANGULAR', '').lower()),
3725 try_get(fmt, lambda x: x['spatialAudioType'].replace('SPATIAL_AUDIO_TYPE_', '').lower()),
3726 throttled and 'THROTTLED', is_damaged and 'DAMAGED', delim=', '),
3727 # Format 22 is likely to be damaged. See https://github.com/yt-dlp/yt-dlp/issues/3372
3728 'source_preference': -10 if throttled else -5 if itag == '22' else -1,
3729 'fps': int_or_none(fmt.get('fps')) or None,
3730 'audio_channels': fmt.get('audioChannels'),
3732 'quality': q(quality) - bool(fmt.get('isDrc')) / 2,
3733 'has_drm': bool(fmt.get('drmFamilies')),
3736 'width': int_or_none(fmt.get('width')),
3737 'language': join_nonempty(audio_track.get('id', '').split('.')[0],
3738 'desc' if language_preference < -1 else '') or None,
3739 'language_preference': language_preference,
3740 # Strictly de-prioritize damaged and 3gp formats
3741 'preference': -10 if is_damaged else -2 if itag == '17' else None,
3743 mime_mobj = re.match(
3744 r'((?:[^/]+)/(?:[^;]+))(?:;\s*codecs="([^
"]+)")?
', fmt.get('mimeType
') or '')
3746 dct['ext
'] = mimetype2ext(mime_mobj.group(1))
3747 dct.update(parse_codecs(mime_mobj.group(2)))
3748 no_audio = dct.get('acodec
') == 'none
'
3749 no_video = dct.get('vcodec
') == 'none
'
3754 if no_audio or no_video:
3755 CHUNK_SIZE = 10 << 20
3757 'protocol
': 'http_dash_segments
',
3759 'url
': update_url_query(dct['url
'], {
3760 'range': f'{range_start}
-{min(range_start + CHUNK_SIZE - 1, dct["filesize"])}
'
3762 } for range_start in range(0, dct['filesize
'], CHUNK_SIZE)]
3763 } if dct['filesize
'] else {
3764 'downloader_options
': {'http_chunk_size': CHUNK_SIZE} # No longer useful?
3768 dct['container
'] = dct['ext
'] + '_dash
'
3771 itags[itag].add(('https
', dct.get('language
')))
3772 stream_ids.append(stream_id)
3775 needs_live_processing = self._needs_live_processing(live_status, duration)
3776 skip_bad_formats = not self._configuration_arg('include_incomplete_formats
')
3778 skip_manifests = set(self._configuration_arg('skip
'))
3779 if (not self.get_param('youtube_include_hls_manifest
', True)
3780 or needs_live_processing == 'is_live
' # These will be filtered out by YoutubeDL anyway
3781 or needs_live_processing and skip_bad_formats):
3782 skip_manifests.add('hls
')
3784 if not self.get_param('youtube_include_dash_manifest
', True):
3785 skip_manifests.add('dash
')
3786 if self._configuration_arg('include_live_dash
'):
3787 self._downloader.deprecated_feature('[youtube
] include_live_dash extractor argument
is deprecated
. '
3788 'Use include_incomplete_formats extractor argument instead
')
3789 elif skip_bad_formats and live_status == 'is_live
' and needs_live_processing != 'is_live
':
3790 skip_manifests.add('dash
')
3792 def process_manifest_format(f, proto, itag):
3793 key = (proto, f.get('language
'))
3794 if key in itags[itag]:
3796 itags[itag].add(key)
3798 if any(p != proto for p, _ in itags[itag]):
3799 f['format_id
'] = f'{itag}
-{proto}
'
3801 f['format_id
'] = itag
3803 f['quality
'] = q(itag_qualities.get(try_get(f, lambda f: f['format_id
'].split('-')[0]), -1))
3804 if f['quality
'] == -1 and f.get('height
'):
3805 f['quality
'] = q(res_qualities[min(res_qualities, key=lambda x: abs(x - f['height
']))])
3809 for sd in streaming_data:
3810 hls_manifest_url = 'hls
' not in skip_manifests and sd.get('hlsManifestUrl
')
3811 if hls_manifest_url:
3812 fmts, subs = self._extract_m3u8_formats_and_subtitles(
3813 hls_manifest_url, video_id, 'mp4
', fatal=False, live=live_status == 'is_live
')
3814 subtitles = self._merge_subtitles(subs, subtitles)
3816 if process_manifest_format(f, 'hls
', self._search_regex(
3817 r'/itag
/(\d
+)', f['url
'], 'itag
', default=None)):
3820 dash_manifest_url = 'dash
' not in skip_manifests and sd.get('dashManifestUrl
')
3821 if dash_manifest_url:
3822 formats, subs = self._extract_mpd_formats_and_subtitles(dash_manifest_url, video_id, fatal=False)
3823 subtitles = self._merge_subtitles(subs, subtitles) # Prioritize HLS subs over DASH
3825 if process_manifest_format(f, 'dash
', f['format_id
']):
3826 f['filesize
'] = int_or_none(self._search_regex(
3827 r'/clen
/(\d
+)', f.get('fragment_base_url
') or f['url
'], 'file size
', default=None))
3828 if needs_live_processing:
3829 f['is_from_start
'] = True
3834 def _extract_storyboard(self, player_responses, duration):
3836 player_responses, ('storyboards
', 'playerStoryboardSpecRenderer
', 'spec
'), default='').split('|
')[::-1]
3837 base_url = url_or_none(urljoin('https
://i
.ytimg
.com
/', spec.pop() or None))
3841 for i, args in enumerate(spec):
3842 args = args.split('#')
3843 counts
= list(map(int_or_none
, args
[:5]))
3844 if len(args
) != 8 or not all(counts
):
3845 self
.report_warning(f
'Malformed storyboard {i}: {"#".join(args)}{bug_reports_message()}')
3847 width
, height
, frame_count
, cols
, rows
= counts
3850 url
= base_url
.replace('$L', str(L
- i
)).replace('$N', N
) + f
'&sigh={sigh}'
3851 fragment_count
= frame_count
/ (cols
* rows
)
3852 fragment_duration
= duration
/ fragment_count
3854 'format_id': f
'sb{i}',
3855 'format_note': 'storyboard',
3857 'protocol': 'mhtml',
3863 'fps': frame_count
/ duration
,
3867 'url': url
.replace('$M', str(j
)),
3868 'duration': min(fragment_duration
, duration
- (j
* fragment_duration
)),
3869 } for j
in range(math
.ceil(fragment_count
))],
3872 def _download_player_responses(self
, url
, smuggled_data
, video_id
, webpage_url
):
3874 if 'webpage' not in self
._configuration
_arg
('player_skip'):
3875 query
= {'bpctr': '9999999999', 'has_verified': '1'}
3876 if smuggled_data
.get('is_story'):
3877 query
['pp'] = self
._STORY
_PLAYER
_PARAMS
3878 webpage
= self
._download
_webpage
(
3879 webpage_url
, video_id
, fatal
=False, query
=query
)
3881 master_ytcfg
= self
.extract_ytcfg(video_id
, webpage
) or self
._get
_default
_ytcfg
()
3883 player_responses
, player_url
= self
._extract
_player
_responses
(
3884 self
._get
_requested
_clients
(url
, smuggled_data
),
3885 video_id
, webpage
, master_ytcfg
, smuggled_data
)
3887 return webpage
, master_ytcfg
, player_responses
, player_url
3889 def _list_formats(self
, video_id
, microformats
, video_details
, player_responses
, player_url
, duration
=None):
3890 live_broadcast_details
= traverse_obj(microformats
, (..., 'liveBroadcastDetails'))
3891 is_live
= get_first(video_details
, 'isLive')
3893 is_live
= get_first(live_broadcast_details
, 'isLiveNow')
3894 live_content
= get_first(video_details
, 'isLiveContent')
3895 is_upcoming
= get_first(video_details
, 'isUpcoming')
3896 post_live
= get_first(video_details
, 'isPostLiveDvr')
3897 live_status
= ('post_live' if post_live
3898 else 'is_live' if is_live
3899 else 'is_upcoming' if is_upcoming
3900 else 'was_live' if live_content
3901 else 'not_live' if False in (is_live
, live_content
)
3903 streaming_data
= traverse_obj(player_responses
, (..., 'streamingData'))
3904 *formats
, subtitles
= self
._extract
_formats
_and
_subtitles
(streaming_data
, video_id
, player_url
, live_status
, duration
)
3906 return live_broadcast_details
, live_status
, streaming_data
, formats
, subtitles
3908 def _real_extract(self
, url
):
3909 url
, smuggled_data
= unsmuggle_url(url
, {})
3910 video_id
= self
._match
_id
(url
)
3912 base_url
= self
.http_scheme() + '//www.youtube.com/'
3913 webpage_url
= base_url
+ 'watch?v=' + video_id
3915 webpage
, master_ytcfg
, player_responses
, player_url
= self
._download
_player
_responses
(url
, smuggled_data
, video_id
, webpage_url
)
3917 playability_statuses
= traverse_obj(
3918 player_responses
, (..., 'playabilityStatus'), expected_type
=dict)
3920 trailer_video_id
= get_first(
3921 playability_statuses
,
3922 ('errorScreen', 'playerLegacyDesktopYpcTrailerRenderer', 'trailerVideoId'),
3924 if trailer_video_id
:
3925 return self
.url_result(
3926 trailer_video_id
, self
.ie_key(), trailer_video_id
)
3928 search_meta
= ((lambda x
: self
._html
_search
_meta
(x
, webpage
, default
=None))
3929 if webpage
else (lambda x
: None))
3931 video_details
= traverse_obj(player_responses
, (..., 'videoDetails'), expected_type
=dict)
3932 microformats
= traverse_obj(
3933 player_responses
, (..., 'microformat', 'playerMicroformatRenderer'),
3936 translated_title
= self
._get
_text
(microformats
, (..., 'title'))
3937 video_title
= (self
._preferred
_lang
and translated_title
3938 or get_first(video_details
, 'title') # primary
3940 or search_meta(['og:title', 'twitter:title', 'title']))
3941 translated_description
= self
._get
_text
(microformats
, (..., 'description'))
3942 original_description
= get_first(video_details
, 'shortDescription')
3943 video_description
= (
3944 self
._preferred
_lang
and translated_description
3945 # If original description is blank, it will be an empty string.
3946 # Do not prefer translated description in this case.
3947 or original_description
if original_description
is not None else translated_description
)
3949 multifeed_metadata_list
= get_first(
3951 ('multicamera', 'playerLegacyMulticameraRenderer', 'metadataList'),
3953 if multifeed_metadata_list
and not smuggled_data
.get('force_singlefeed'):
3954 if self
.get_param('noplaylist'):
3955 self
.to_screen('Downloading just video %s because of --no-playlist' % video_id
)
3959 for feed
in multifeed_metadata_list
.split(','):
3960 # Unquote should take place before split on comma (,) since textual
3961 # fields may contain comma as well (see
3962 # https://github.com/ytdl-org/youtube-dl/issues/8536)
3963 feed_data
= urllib
.parse
.parse_qs(
3964 urllib
.parse
.unquote_plus(feed
))
3966 def feed_entry(name
):
3968 feed_data
, lambda x
: x
[name
][0], str)
3970 feed_id
= feed_entry('id')
3973 feed_title
= feed_entry('title')
3976 title
+= ' (%s)' % feed_title
3978 '_type': 'url_transparent',
3979 'ie_key': 'Youtube',
3981 '%swatch?v=%s' % (base_url
, feed_data
['id'][0]),
3982 {'force_singlefeed': True}
),
3985 feed_ids
.append(feed_id
)
3987 'Downloading multifeed video (%s) - add --no-playlist to just download video %s'
3988 % (', '.join(feed_ids
), video_id
))
3989 return self
.playlist_result(
3990 entries
, video_id
, video_title
, video_description
)
3992 duration
= (int_or_none(get_first(video_details
, 'lengthSeconds'))
3993 or int_or_none(get_first(microformats
, 'lengthSeconds'))
3994 or parse_duration(search_meta('duration')) or None)
3996 live_broadcast_details
, live_status
, streaming_data
, formats
, automatic_captions
= \
3997 self
._list
_formats
(video_id
, microformats
, video_details
, player_responses
, player_url
, duration
)
3998 if live_status
== 'post_live':
3999 self
.write_debug(f
'{video_id}: Video is in Post-Live Manifestless mode')
4002 if not self
.get_param('allow_unplayable_formats') and traverse_obj(streaming_data
, (..., 'licenseInfos')):
4003 self
.report_drm(video_id
)
4005 playability_statuses
,
4006 ('errorScreen', 'playerErrorMessageRenderer'), expected_type
=dict) or {}
4007 reason
= self
._get
_text
(pemr
, 'reason') or get_first(playability_statuses
, 'reason')
4008 subreason
= clean_html(self
._get
_text
(pemr
, 'subreason') or '')
4010 if subreason
== 'The uploader has not made this video available in your country.':
4011 countries
= get_first(microformats
, 'availableCountries')
4013 regions_allowed
= search_meta('regionsAllowed')
4014 countries
= regions_allowed
.split(',') if regions_allowed
else None
4015 self
.raise_geo_restricted(subreason
, countries
, metadata_available
=True)
4016 reason
+= f
'. {subreason}'
4018 self
.raise_no_formats(reason
, expected
=True)
4020 keywords
= get_first(video_details
, 'keywords', expected_type
=list) or []
4021 if not keywords
and webpage
:
4023 unescapeHTML(m
.group('content'))
4024 for m
in re
.finditer(self
._meta
_regex
('og:video:tag'), webpage
)]
4025 for keyword
in keywords
:
4026 if keyword
.startswith('yt:stretch='):
4027 mobj
= re
.search(r
'(\d+)\s*:\s*(\d+)', keyword
)
4029 # NB: float is intentional for forcing float division
4030 w
, h
= (float(v
) for v
in mobj
.groups())
4034 if f
.get('vcodec') != 'none':
4035 f
['stretched_ratio'] = ratio
4037 thumbnails
= self
._extract
_thumbnails
((video_details
, microformats
), (..., ..., 'thumbnail'))
4038 thumbnail_url
= search_meta(['og:image', 'twitter:image'])
4041 'url': thumbnail_url
,
4043 original_thumbnails
= thumbnails
.copy()
4045 # The best resolution thumbnails sometimes does not appear in the webpage
4046 # See: https://github.com/yt-dlp/yt-dlp/issues/340
4047 # List of possible thumbnails - Ref: <https://stackoverflow.com/a/20542029>
4049 # While the *1,*2,*3 thumbnails are just below their corresponding "*default" variants
4050 # in resolution, these are not the custom thumbnail. So de-prioritize them
4051 'maxresdefault', 'hq720', 'sddefault', 'hqdefault', '0', 'mqdefault', 'default',
4052 'sd1', 'sd2', 'sd3', 'hq1', 'hq2', 'hq3', 'mq1', 'mq2', 'mq3', '1', '2', '3'
4054 n_thumbnail_names
= len(thumbnail_names
)
4056 'url': 'https://i.ytimg.com/vi{webp}/{video_id}/{name}{live}.{ext}'.format(
4057 video_id
=video_id
, name
=name
, ext
=ext
,
4058 webp
='_webp' if ext
== 'webp' else '', live
='_live' if live_status
== 'is_live' else ''),
4059 } for name
in thumbnail_names
for ext
in ('webp', 'jpg'))
4060 for thumb
in thumbnails
:
4061 i
= next((i
for i
, t
in enumerate(thumbnail_names
) if f
'/{video_id}/{t}' in thumb
['url']), n_thumbnail_names
)
4062 thumb
['preference'] = (0 if '.webp' in thumb
['url'] else -1) - (2 * i
)
4063 self
._remove
_duplicate
_formats
(thumbnails
)
4064 self
._downloader
._sort
_thumbnails
(original_thumbnails
)
4066 category
= get_first(microformats
, 'category') or search_meta('genre')
4067 channel_id
= str_or_none(
4068 get_first(video_details
, 'channelId')
4069 or get_first(microformats
, 'externalChannelId')
4070 or search_meta('channelId'))
4071 owner_profile_url
= get_first(microformats
, 'ownerProfileUrl')
4073 live_start_time
= parse_iso8601(get_first(live_broadcast_details
, 'startTimestamp'))
4074 live_end_time
= parse_iso8601(get_first(live_broadcast_details
, 'endTimestamp'))
4075 if not duration
and live_end_time
and live_start_time
:
4076 duration
= live_end_time
- live_start_time
4078 needs_live_processing
= self
._needs
_live
_processing
(live_status
, duration
)
4080 def is_bad_format(fmt
):
4081 if needs_live_processing
and not fmt
.get('is_from_start'):
4083 elif (live_status
== 'is_live' and needs_live_processing
!= 'is_live'
4084 and fmt
.get('protocol') == 'http_dash_segments'):
4087 for fmt
in filter(is_bad_format
, formats
):
4088 fmt
['preference'] = (fmt
.get('preference') or -1) - 10
4089 fmt
['format_note'] = join_nonempty(fmt
.get('format_note'), '(Last 4 hours)', delim
=' ')
4091 if needs_live_processing
:
4092 self
._prepare
_live
_from
_start
_formats
(
4093 formats
, video_id
, live_start_time
, url
, webpage_url
, smuggled_data
, live_status
== 'is_live')
4095 formats
.extend(self
._extract
_storyboard
(player_responses
, duration
))
4099 'title': video_title
,
4101 'thumbnails': thumbnails
,
4102 # The best thumbnail that we are sure exists. Prevents unnecessary
4103 # URL checking if user don't care about getting the best possible thumbnail
4104 'thumbnail': traverse_obj(original_thumbnails
, (-1, 'url')),
4105 'description': video_description
,
4106 'uploader': get_first(video_details
, 'author'),
4107 'uploader_id': self
._search
_regex
(r
'/(?:channel/|user/|(?=@))([^/?&#]+)', owner_profile_url
, 'uploader id', default
=None),
4108 'uploader_url': owner_profile_url
,
4109 'channel_id': channel_id
,
4110 'channel_url': format_field(channel_id
, None, 'https://www.youtube.com/channel/%s'),
4111 'duration': duration
,
4112 'view_count': int_or_none(
4113 get_first((video_details
, microformats
), (..., 'viewCount'))
4114 or search_meta('interactionCount')),
4115 'average_rating': float_or_none(get_first(video_details
, 'averageRating')),
4116 'age_limit': 18 if (
4117 get_first(microformats
, 'isFamilySafe') is False
4118 or search_meta('isFamilyFriendly') == 'false'
4119 or search_meta('og:restrictions:age') == '18+') else 0,
4120 'webpage_url': webpage_url
,
4121 'categories': [category
] if category
else None,
4123 'playable_in_embed': get_first(playability_statuses
, 'playableInEmbed'),
4124 'live_status': live_status
,
4125 'release_timestamp': live_start_time
,
4126 '_format_sort_fields': ( # source_preference is lower for throttled/potentially damaged formats
4127 'quality', 'res', 'fps', 'hdr:12', 'source', 'vcodec:vp9.2', 'channels', 'acodec', 'lang', 'proto')
4131 pctr
= traverse_obj(player_responses
, (..., 'captions', 'playerCaptionsTracklistRenderer'), expected_type
=dict)
4133 def get_lang_code(track
):
4134 return (remove_start(track
.get('vssId') or '', '.').replace('.', '-')
4135 or track
.get('languageCode'))
4137 # Converted into dicts to remove duplicates
4139 get_lang_code(sub
): sub
4140 for sub
in traverse_obj(pctr
, (..., 'captionTracks', ...))}
4141 translation_languages
= {
4142 lang
.get('languageCode'): self
._get
_text
(lang
.get('languageName'), max_runs
=1)
4143 for lang
in traverse_obj(pctr
, (..., 'translationLanguages', ...))}
4145 def process_language(container
, base_url
, lang_code
, sub_name
, query
):
4146 lang_subs
= container
.setdefault(lang_code
, [])
4147 for fmt
in self
._SUBTITLE
_FORMATS
:
4153 'url': urljoin('https://www.youtube.com', update_url_query(base_url
, query
)),
4157 # NB: Constructing the full subtitle dictionary is slow
4158 get_translated_subs
= 'translated_subs' not in self
._configuration
_arg
('skip') and (
4159 self
.get_param('writeautomaticsub', False) or self
.get_param('listsubtitles'))
4160 for lang_code
, caption_track
in captions
.items():
4161 base_url
= caption_track
.get('baseUrl')
4162 orig_lang
= parse_qs(base_url
).get('lang', [None])[-1]
4165 lang_name
= self
._get
_text
(caption_track
, 'name', max_runs
=1)
4166 if caption_track
.get('kind') != 'asr':
4170 subtitles
, base_url
, lang_code
, lang_name
, {})
4171 if not caption_track
.get('isTranslatable'):
4173 for trans_code
, trans_name
in translation_languages
.items():
4176 orig_trans_code
= trans_code
4177 if caption_track
.get('kind') != 'asr' and trans_code
!= 'und':
4178 if not get_translated_subs
:
4180 trans_code
+= f
'-{lang_code}'
4181 trans_name
+= format_field(lang_name
, None, ' from %s')
4182 # Add an "-orig" label to the original language so that it can be distinguished.
4183 # The subs are returned without "-orig" as well for compatibility
4184 if lang_code
== f
'a-{orig_trans_code}':
4186 automatic_captions
, base_url
, f
'{trans_code}-orig', f
'{trans_name} (Original)', {})
4187 # Setting tlang=lang returns damaged subtitles.
4188 process_language(automatic_captions
, base_url
, trans_code
, trans_name
,
4189 {} if orig_lang == orig_trans_code else {'tlang': trans_code}
)
4191 info
['automatic_captions'] = automatic_captions
4192 info
['subtitles'] = subtitles
4194 parsed_url
= urllib
.parse
.urlparse(url
)
4195 for component
in [parsed_url
.fragment
, parsed_url
.query
]:
4196 query
= urllib
.parse
.parse_qs(component
)
4197 for k
, v
in query
.items():
4198 for d_k
, s_ks
in [('start', ('start', 't')), ('end', ('end',))]:
4200 if d_k
not in info
and k
in s_ks
:
4201 info
[d_k
] = parse_duration(query
[k
][0])
4203 # Youtube Music Auto-generated description
4204 if video_description
:
4207 (?P<track>[^·\n]+)·(?P<artist>[^\n]+)\n+
4209 (?:.+?℗\s*(?P<release_year>\d{4})(?!\d))?
4210 (?:.+?Released on\s*:\s*(?P<release_date>\d{4}-\d{2}-\d{2}))?
4211 (.+?\nArtist\s*:\s*(?P<clean_artist>[^\n]+))?
4212 .+\nAuto-generated\ by\ YouTube\.\s*$
4213 ''', video_description
)
4215 release_year
= mobj
.group('release_year')
4216 release_date
= mobj
.group('release_date')
4218 release_date
= release_date
.replace('-', '')
4219 if not release_year
:
4220 release_year
= release_date
[:4]
4222 'album': mobj
.group('album'.strip()),
4223 'artist': mobj
.group('clean_artist') or ', '.join(a
.strip() for a
in mobj
.group('artist').split('·')),
4224 'track': mobj
.group('track').strip(),
4225 'release_date': release_date
,
4226 'release_year': int_or_none(release_year
),
4231 initial_data
= self
.extract_yt_initial_data(video_id
, webpage
, fatal
=False)
4232 if not initial_data
:
4233 query
= {'videoId': video_id}
4234 query
.update(self
._get
_checkok
_params
())
4235 initial_data
= self
._extract
_response
(
4236 item_id
=video_id
, ep
='next', fatal
=False,
4237 ytcfg
=master_ytcfg
, query
=query
,
4238 headers
=self
.generate_api_headers(ytcfg
=master_ytcfg
),
4239 note
='Downloading initial data API JSON')
4241 info
['comment_count'] = traverse_obj(initial_data
, (
4242 'contents', 'twoColumnWatchNextResults', 'results', 'results', 'contents', ..., 'itemSectionRenderer',
4243 'contents', ..., 'commentsEntryPointHeaderRenderer', 'commentCount', 'simpleText'
4245 'engagementPanels', lambda _
, v
: v
['engagementPanelSectionListRenderer']['panelIdentifier'] == 'comment-item-section',
4246 'engagementPanelSectionListRenderer', 'header', 'engagementPanelTitleHeaderRenderer', 'contextualInfo', 'runs', ..., 'text'
4247 ), expected_type
=int_or_none
, get_all
=False)
4249 try: # This will error if there is no livechat
4250 initial_data
['contents']['twoColumnWatchNextResults']['conversationBar']['liveChatRenderer']['continuations'][0]['reloadContinuationData']['continuation']
4251 except (KeyError, IndexError, TypeError):
4254 info
.setdefault('subtitles', {})['live_chat'] = [{
4255 # url is needed to set cookies
4256 'url': f
'https://www.youtube.com/watch?v={video_id}&bpctr=9999999999&has_verified=1',
4257 'video_id': video_id
,
4259 'protocol': ('youtube_live_chat' if live_status
in ('is_live', 'is_upcoming')
4260 else 'youtube_live_chat_replay'),
4264 info
['chapters'] = (
4265 self
._extract
_chapters
_from
_json
(initial_data
, duration
)
4266 or self
._extract
_chapters
_from
_engagement
_panel
(initial_data
, duration
)
4267 or self
._extract
_chapters
_from
_description
(video_description
, duration
)
4270 contents
= traverse_obj(
4271 initial_data
, ('contents', 'twoColumnWatchNextResults', 'results', 'results', 'contents'),
4272 expected_type
=list, default
=[])
4274 vpir
= get_first(contents
, 'videoPrimaryInfoRenderer')
4276 stl
= vpir
.get('superTitleLink')
4278 stl
= self
._get
_text
(stl
)
4281 lambda x
: x
['superTitleIcon']['iconType']) == 'LOCATION_PIN':
4282 info
['location'] = stl
4284 mobj
= re
.search(r
'(.+?)\s*S(\d+)\s*•?\s*E(\d+)', stl
)
4287 'series': mobj
.group(1),
4288 'season_number': int(mobj
.group(2)),
4289 'episode_number': int(mobj
.group(3)),
4291 for tlb
in (try_get(
4293 lambda x
: x
['videoActions']['menuRenderer']['topLevelButtons'],
4297 tlb
, ('toggleButtonRenderer', ...),
4298 ('segmentedLikeDislikeButtonRenderer', ..., 'toggleButtonRenderer')))
4300 for getter
, regex
in [(
4301 lambda x
: x
['defaultText']['accessibility']['accessibilityData'],
4302 r
'(?P<count>[\d,]+)\s*(?P<type>(?:dis)?like)'), ([
4303 lambda x
: x
['accessibility'],
4304 lambda x
: x
['accessibilityData']['accessibilityData'],
4305 ], r
'(?P<type>(?:dis)?like) this video along with (?P<count>[\d,]+) other people')]:
4306 label
= (try_get(tbr
, getter
, dict) or {}).get('label')
4308 mobj
= re
.match(regex
, label
)
4310 info
[mobj
.group('type') + '_count'] = str_to_int(mobj
.group('count'))
4312 sbr_tooltip
= try_get(
4313 vpir
, lambda x
: x
['sentimentBar']['sentimentBarRenderer']['tooltip'])
4315 like_count
, dislike_count
= sbr_tooltip
.split(' / ')
4317 'like_count': str_to_int(like_count
),
4318 'dislike_count': str_to_int(dislike_count
),
4320 vcr
= traverse_obj(vpir
, ('viewCount', 'videoViewCountRenderer'))
4322 vc
= self
._get
_count
(vcr
, 'viewCount')
4323 # Upcoming premieres with waiting count are treated as live here
4324 if vcr
.get('isLive'):
4325 info
['concurrent_view_count'] = vc
4326 elif info
.get('view_count') is None:
4327 info
['view_count'] = vc
4329 vsir
= get_first(contents
, 'videoSecondaryInfoRenderer')
4331 vor
= traverse_obj(vsir
, ('owner', 'videoOwnerRenderer'))
4333 'channel': self
._get
_text
(vor
, 'title'),
4334 'channel_follower_count': self
._get
_count
(vor
, 'subscriberCountText')})
4338 lambda x
: x
['metadataRowContainer']['metadataRowContainerRenderer']['rows'],
4340 multiple_songs
= False
4342 if try_get(row
, lambda x
: x
['metadataRowRenderer']['hasDividerLine']) is True:
4343 multiple_songs
= True
4346 mrr
= row
.get('metadataRowRenderer') or {}
4347 mrr_title
= mrr
.get('title')
4350 mrr_title
= self
._get
_text
(mrr
, 'title')
4351 mrr_contents_text
= self
._get
_text
(mrr
, ('contents', 0))
4352 if mrr_title
== 'License':
4353 info
['license'] = mrr_contents_text
4354 elif not multiple_songs
:
4355 if mrr_title
== 'Album':
4356 info
['album'] = mrr_contents_text
4357 elif mrr_title
== 'Artist':
4358 info
['artist'] = mrr_contents_text
4359 elif mrr_title
== 'Song':
4360 info
['track'] = mrr_contents_text
4363 'channel': 'uploader',
4364 'channel_id': 'uploader_id',
4365 'channel_url': 'uploader_url',
4368 # The upload date for scheduled, live and past live streams / premieres in microformats
4369 # may be different from the stream date. Although not in UTC, we will prefer it in this case.
4370 # See: https://github.com/yt-dlp/yt-dlp/pull/2223#issuecomment-1008485139
4372 unified_strdate(get_first(microformats
, 'uploadDate'))
4373 or unified_strdate(search_meta('uploadDate')))
4374 if not upload_date
or (
4375 live_status
in ('not_live', None)
4376 and 'no-youtube-prefer-utc-upload-date' not in self
.get_param('compat_opts', [])
4378 upload_date
= strftime_or_none(
4379 self
._parse
_time
_text
(self
._get
_text
(vpir
, 'dateText')), '%Y%m%d') or upload_date
4380 info
['upload_date'] = upload_date
4382 for to
, frm
in fallbacks
.items():
4383 if not info
.get(to
):
4384 info
[to
] = info
.get(frm
)
4386 for s_k
, d_k
in [('artist', 'creator'), ('track', 'alt_title')]:
4391 badges
= self
._extract
_badges
(traverse_obj(contents
, (..., 'videoPrimaryInfoRenderer'), get_all
=False))
4393 is_private
= (self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PRIVATE
)
4394 or get_first(video_details
, 'isPrivate', expected_type
=bool))
4396 info
['availability'] = (
4397 'public' if self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PUBLIC
)
4398 else self
._availability
(
4399 is_private
=is_private
,
4401 self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PREMIUM
)
4402 or False if initial_data
and is_private
is not None else None),
4403 needs_subscription
=(
4404 self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_SUBSCRIPTION
)
4405 or False if initial_data
and is_private
is not None else None),
4406 needs_auth
=info
['age_limit'] >= 18,
4407 is_unlisted
=None if is_private
is None else (
4408 self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_UNLISTED
)
4409 or get_first(microformats
, 'isUnlisted', expected_type
=bool))))
4411 info
['__post_extractor'] = self
.extract_comments(master_ytcfg
, video_id
, contents
, webpage
)
4413 self
.mark_watched(video_id
, player_responses
)
4418 class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor
):
4420 def passthrough_smuggled_data(func
):
4421 def _smuggle(info
, smuggled_data
):
4422 if info
.get('_type') not in ('url', 'url_transparent'):
4424 if smuggled_data
.get('is_music_url'):
4425 parsed_url
= urllib
.parse
.urlparse(info
['url'])
4426 if parsed_url
.netloc
in ('www.youtube.com', 'music.youtube.com'):
4427 smuggled_data
.pop('is_music_url')
4428 info
['url'] = urllib
.parse
.urlunparse(parsed_url
._replace
(netloc
='music.youtube.com'))
4430 info
['url'] = smuggle_url(info
['url'], smuggled_data
)
4433 @functools.wraps(func
)
4434 def wrapper(self
, url
):
4435 url
, smuggled_data
= unsmuggle_url(url
, {})
4436 if self
.is_music_url(url
):
4437 smuggled_data
['is_music_url'] = True
4438 info_dict
= func(self
, url
, smuggled_data
)
4440 _smuggle(info_dict
, smuggled_data
)
4441 if info_dict
.get('entries'):
4442 info_dict
['entries'] = (_smuggle(i
, smuggled_data
.copy()) for i
in info_dict
['entries'])
4447 def _extract_basic_item_renderer(item
):
4448 # Modified from _extract_grid_item_renderer
4449 known_basic_renderers
= (
4450 'playlistRenderer', 'videoRenderer', 'channelRenderer', 'showRenderer', 'reelItemRenderer'
4452 for key
, renderer
in item
.items():
4453 if not isinstance(renderer
, dict):
4455 elif key
in known_basic_renderers
:
4457 elif key
.startswith('grid') and key
.endswith('Renderer'):
4460 def _extract_channel_renderer(self
, renderer
):
4461 channel_id
= renderer
['channelId']
4462 title
= self
._get
_text
(renderer
, 'title')
4463 channel_url
= f
'https://www.youtube.com/channel/{channel_id}'
4468 'ie_key': YoutubeTabIE
.ie_key(),
4470 'channel_id': channel_id
,
4471 'channel_url': channel_url
,
4473 'channel_follower_count': self
._get
_count
(renderer
, 'subscriberCountText'),
4474 'thumbnails': self
._extract
_thumbnails
(renderer
, 'thumbnail'),
4475 'playlist_count': self
._get
_count
(renderer
, 'videoCountText'),
4476 'description': self
._get
_text
(renderer
, 'descriptionSnippet'),
4479 def _grid_entries(self
, grid_renderer
):
4480 for item
in grid_renderer
['items']:
4481 if not isinstance(item
, dict):
4483 renderer
= self
._extract
_basic
_item
_renderer
(item
)
4484 if not isinstance(renderer
, dict):
4486 title
= self
._get
_text
(renderer
, 'title')
4489 playlist_id
= renderer
.get('playlistId')
4491 yield self
.url_result(
4492 'https://www.youtube.com/playlist?list=%s' % playlist_id
,
4493 ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
,
4497 video_id
= renderer
.get('videoId')
4499 yield self
._extract
_video
(renderer
)
4502 channel_id
= renderer
.get('channelId')
4504 yield self
._extract
_channel
_renderer
(renderer
)
4506 # generic endpoint URL support
4507 ep_url
= urljoin('https://www.youtube.com/', try_get(
4508 renderer
, lambda x
: x
['navigationEndpoint']['commandMetadata']['webCommandMetadata']['url'],
4511 for ie
in (YoutubeTabIE
, YoutubePlaylistIE
, YoutubeIE
):
4512 if ie
.suitable(ep_url
):
4513 yield self
.url_result(
4514 ep_url
, ie
=ie
.ie_key(), video_id
=ie
._match
_id
(ep_url
), video_title
=title
)
4517 def _music_reponsive_list_entry(self
, renderer
):
4518 video_id
= traverse_obj(renderer
, ('playlistItemData', 'videoId'))
4520 return self
.url_result(f
'https://music.youtube.com/watch?v={video_id}',
4521 ie
=YoutubeIE
.ie_key(), video_id
=video_id
)
4522 playlist_id
= traverse_obj(renderer
, ('navigationEndpoint', 'watchEndpoint', 'playlistId'))
4524 video_id
= traverse_obj(renderer
, ('navigationEndpoint', 'watchEndpoint', 'videoId'))
4526 return self
.url_result(f
'https://music.youtube.com/watch?v={video_id}&list={playlist_id}',
4527 ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
)
4528 return self
.url_result(f
'https://music.youtube.com/playlist?list={playlist_id}',
4529 ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
)
4530 browse_id
= traverse_obj(renderer
, ('navigationEndpoint', 'browseEndpoint', 'browseId'))
4532 return self
.url_result(f
'https://music.youtube.com/browse/{browse_id}',
4533 ie
=YoutubeTabIE
.ie_key(), video_id
=browse_id
)
4535 def _shelf_entries_from_content(self
, shelf_renderer
):
4536 content
= shelf_renderer
.get('content')
4537 if not isinstance(content
, dict):
4539 renderer
= content
.get('gridRenderer') or content
.get('expandedShelfContentsRenderer')
4541 # TODO: add support for nested playlists so each shelf is processed
4542 # as separate playlist
4543 # TODO: this includes only first N items
4544 yield from self
._grid
_entries
(renderer
)
4545 renderer
= content
.get('horizontalListRenderer')
4550 def _shelf_entries(self
, shelf_renderer
, skip_channels
=False):
4552 shelf_renderer
, lambda x
: x
['endpoint']['commandMetadata']['webCommandMetadata']['url'],
4554 shelf_url
= urljoin('https://www.youtube.com', ep
)
4556 # Skipping links to another channels, note that checking for
4557 # endpoint.commandMetadata.webCommandMetadata.webPageTypwebPageType == WEB_PAGE_TYPE_CHANNEL
4559 if skip_channels
and '/channels?' in shelf_url
:
4561 title
= self
._get
_text
(shelf_renderer
, 'title')
4562 yield self
.url_result(shelf_url
, video_title
=title
)
4563 # Shelf may not contain shelf URL, fallback to extraction from content
4564 yield from self
._shelf
_entries
_from
_content
(shelf_renderer
)
4566 def _playlist_entries(self
, video_list_renderer
):
4567 for content
in video_list_renderer
['contents']:
4568 if not isinstance(content
, dict):
4570 renderer
= content
.get('playlistVideoRenderer') or content
.get('playlistPanelVideoRenderer')
4571 if not isinstance(renderer
, dict):
4573 video_id
= renderer
.get('videoId')
4576 yield self
._extract
_video
(renderer
)
4578 def _rich_entries(self
, rich_grid_renderer
):
4579 renderer
= traverse_obj(
4580 rich_grid_renderer
, ('content', ('videoRenderer', 'reelItemRenderer')), get_all
=False) or {}
4581 video_id
= renderer
.get('videoId')
4584 yield self
._extract
_video
(renderer
)
4586 def _video_entry(self
, video_renderer
):
4587 video_id
= video_renderer
.get('videoId')
4589 return self
._extract
_video
(video_renderer
)
4591 def _hashtag_tile_entry(self
, hashtag_tile_renderer
):
4592 url
= urljoin('https://youtube.com', traverse_obj(
4593 hashtag_tile_renderer
, ('onTapCommand', 'commandMetadata', 'webCommandMetadata', 'url')))
4595 return self
.url_result(
4596 url
, ie
=YoutubeTabIE
.ie_key(), title
=self
._get
_text
(hashtag_tile_renderer
, 'hashtag'))
4598 def _post_thread_entries(self
, post_thread_renderer
):
4599 post_renderer
= try_get(
4600 post_thread_renderer
, lambda x
: x
['post']['backstagePostRenderer'], dict)
4601 if not post_renderer
:
4604 video_renderer
= try_get(
4605 post_renderer
, lambda x
: x
['backstageAttachment']['videoRenderer'], dict) or {}
4606 video_id
= video_renderer
.get('videoId')
4608 entry
= self
._extract
_video
(video_renderer
)
4611 # playlist attachment
4612 playlist_id
= try_get(
4613 post_renderer
, lambda x
: x
['backstageAttachment']['playlistRenderer']['playlistId'], str)
4615 yield self
.url_result(
4616 'https://www.youtube.com/playlist?list=%s' % playlist_id
,
4617 ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
)
4618 # inline video links
4619 runs
= try_get(post_renderer
, lambda x
: x
['contentText']['runs'], list) or []
4621 if not isinstance(run
, dict):
4624 run
, lambda x
: x
['navigationEndpoint']['urlEndpoint']['url'], str)
4627 if not YoutubeIE
.suitable(ep_url
):
4629 ep_video_id
= YoutubeIE
._match
_id
(ep_url
)
4630 if video_id
== ep_video_id
:
4632 yield self
.url_result(ep_url
, ie
=YoutubeIE
.ie_key(), video_id
=ep_video_id
)
4634 def _post_thread_continuation_entries(self
, post_thread_continuation
):
4635 contents
= post_thread_continuation
.get('contents')
4636 if not isinstance(contents
, list):
4638 for content
in contents
:
4639 renderer
= content
.get('backstagePostThreadRenderer')
4640 if isinstance(renderer
, dict):
4641 yield from self
._post
_thread
_entries
(renderer
)
4643 renderer
= content
.get('videoRenderer')
4644 if isinstance(renderer
, dict):
4645 yield self
._video
_entry
(renderer
)
4648 def _rich_grid_entries(self, contents):
4649 for content in contents:
4650 video_renderer = try_get(content, lambda x: x['richItemRenderer']['content']['videoRenderer'], dict)
4652 entry = self._video_entry(video_renderer)
4657 def _report_history_entries(self
, renderer
):
4658 for url
in traverse_obj(renderer
, (
4659 'rows', ..., 'reportHistoryTableRowRenderer', 'cells', ...,
4660 'reportHistoryTableCellRenderer', 'cell', 'reportHistoryTableTextCellRenderer', 'text', 'runs', ...,
4661 'navigationEndpoint', 'commandMetadata', 'webCommandMetadata', 'url')):
4662 yield self
.url_result(urljoin('https://www.youtube.com', url
), YoutubeIE
)
4664 def _extract_entries(self
, parent_renderer
, continuation_list
):
4665 # continuation_list is modified in-place with continuation_list = [continuation_token]
4666 continuation_list
[:] = [None]
4667 contents
= try_get(parent_renderer
, lambda x
: x
['contents'], list) or []
4668 for content
in contents
:
4669 if not isinstance(content
, dict):
4671 is_renderer
= traverse_obj(
4672 content
, 'itemSectionRenderer', 'musicShelfRenderer', 'musicShelfContinuation',
4675 if content
.get('richItemRenderer'):
4676 for entry
in self
._rich
_entries
(content
['richItemRenderer']):
4678 continuation_list
[0] = self
._extract
_continuation
(parent_renderer
)
4679 elif content
.get('reportHistorySectionRenderer'): # https://www.youtube.com/reporthistory
4680 table
= traverse_obj(content
, ('reportHistorySectionRenderer', 'table', 'tableRenderer'))
4681 yield from self
._report
_history
_entries
(table
)
4682 continuation_list
[0] = self
._extract
_continuation
(table
)
4685 isr_contents
= try_get(is_renderer
, lambda x
: x
['contents'], list) or []
4686 for isr_content
in isr_contents
:
4687 if not isinstance(isr_content
, dict):
4691 'playlistVideoListRenderer': self
._playlist
_entries
,
4692 'gridRenderer': self
._grid
_entries
,
4693 'reelShelfRenderer': self
._grid
_entries
,
4694 'shelfRenderer': self
._shelf
_entries
,
4695 'musicResponsiveListItemRenderer': lambda x
: [self
._music
_reponsive
_list
_entry
(x
)],
4696 'backstagePostThreadRenderer': self
._post
_thread
_entries
,
4697 'videoRenderer': lambda x
: [self
._video
_entry
(x
)],
4698 'playlistRenderer': lambda x
: self
._grid
_entries
({'items': [{'playlistRenderer': x}
]}),
4699 'channelRenderer': lambda x
: self
._grid
_entries
({'items': [{'channelRenderer': x}
]}),
4700 'hashtagTileRenderer': lambda x
: [self
._hashtag
_tile
_entry
(x
)]
4702 for key
, renderer
in isr_content
.items():
4703 if key
not in known_renderers
:
4705 for entry
in known_renderers
[key
](renderer
):
4708 continuation_list
[0] = self
._extract
_continuation
(renderer
)
4711 if not continuation_list
[0]:
4712 continuation_list
[0] = self
._extract
_continuation
(is_renderer
)
4714 if not continuation_list
[0]:
4715 continuation_list
[0] = self
._extract
_continuation
(parent_renderer
)
4717 def _entries(self
, tab
, item_id
, ytcfg
, account_syncid
, visitor_data
):
4718 continuation_list
= [None]
4719 extract_entries
= lambda x
: self
._extract
_entries
(x
, continuation_list
)
4720 tab_content
= try_get(tab
, lambda x
: x
['content'], dict)
4724 try_get(tab_content
, lambda x
: x
['sectionListRenderer'], dict)
4725 or try_get(tab_content
, lambda x
: x
['richGridRenderer'], dict) or {})
4726 yield from extract_entries(parent_renderer
)
4727 continuation
= continuation_list
[0]
4729 for page_num
in itertools
.count(1):
4730 if not continuation
:
4732 headers
= self
.generate_api_headers(
4733 ytcfg
=ytcfg
, account_syncid
=account_syncid
, visitor_data
=visitor_data
)
4734 response
= self
._extract
_response
(
4735 item_id
=f
'{item_id} page {page_num}',
4736 query
=continuation
, headers
=headers
, ytcfg
=ytcfg
,
4737 check_get_keys
=('continuationContents', 'onResponseReceivedActions', 'onResponseReceivedEndpoints'))
4741 # Extracting updated visitor data is required to prevent an infinite extraction loop in some cases
4742 # See: https://github.com/ytdl-org/youtube-dl/issues/28702
4743 visitor_data
= self
._extract
_visitor
_data
(response
) or visitor_data
4746 'videoRenderer': (self
._grid
_entries
, 'items'), # for membership tab
4747 'gridPlaylistRenderer': (self
._grid
_entries
, 'items'),
4748 'gridVideoRenderer': (self
._grid
_entries
, 'items'),
4749 'gridChannelRenderer': (self
._grid
_entries
, 'items'),
4750 'playlistVideoRenderer': (self
._playlist
_entries
, 'contents'),
4751 'itemSectionRenderer': (extract_entries
, 'contents'), # for feeds
4752 'richItemRenderer': (extract_entries
, 'contents'), # for hashtag
4753 'backstagePostThreadRenderer': (self
._post
_thread
_continuation
_entries
, 'contents'),
4754 'reportHistoryTableRowRenderer': (self
._report
_history
_entries
, 'rows'),
4755 'playlistVideoListContinuation': (self
._playlist
_entries
, None),
4756 'gridContinuation': (self
._grid
_entries
, None),
4757 'itemSectionContinuation': (self
._post
_thread
_continuation
_entries
, None),
4758 'sectionListContinuation': (extract_entries
, None), # for feeds
4761 continuation_items
= traverse_obj(response
, (
4762 ('onResponseReceivedActions', 'onResponseReceivedEndpoints'), ...,
4763 'appendContinuationItemsAction', 'continuationItems'
4764 ), 'continuationContents', get_all
=False)
4765 continuation_item
= traverse_obj(continuation_items
, 0, None, expected_type
=dict, default
={})
4767 video_items_renderer
= None
4768 for key
in continuation_item
.keys():
4769 if key
not in known_renderers
:
4771 func
, parent_key
= known_renderers
[key
]
4772 video_items_renderer
= {parent_key: continuation_items}
if parent_key
else continuation_items
4773 continuation_list
= [None]
4774 yield from func(video_items_renderer
)
4775 continuation
= continuation_list
[0] or self
._extract
_continuation
(video_items_renderer
)
4777 if not video_items_renderer
:
4781 def _extract_selected_tab(tabs
, fatal
=True):
4782 for tab_renderer
in tabs
:
4783 if tab_renderer
.get('selected'):
4786 raise ExtractorError('Unable to find selected tab')
4789 def _extract_tab_renderers(response
):
4790 return traverse_obj(
4791 response
, ('contents', 'twoColumnBrowseResultsRenderer', 'tabs', ..., ('tabRenderer', 'expandableTabRenderer')), expected_type
=dict)
4793 def _extract_from_tabs(self
, item_id
, ytcfg
, data
, tabs
):
4794 metadata
= self
._extract
_metadata
_from
_tabs
(item_id
, data
)
4796 selected_tab
= self
._extract
_selected
_tab
(tabs
)
4797 metadata
['title'] += format_field(selected_tab
, 'title', ' - %s')
4798 metadata
['title'] += format_field(selected_tab
, 'expandedText', ' - %s')
4800 return self
.playlist_result(
4802 selected_tab
, metadata
['id'], ytcfg
,
4803 self
._extract
_account
_syncid
(ytcfg
, data
),
4804 self
._extract
_visitor
_data
(data
, ytcfg
)),
4807 def _extract_metadata_from_tabs(self
, item_id
, data
):
4808 info
= {'id': item_id}
4810 metadata_renderer
= traverse_obj(data
, ('metadata', 'channelMetadataRenderer'), expected_type
=dict)
4811 if metadata_renderer
:
4813 'uploader': metadata_renderer
.get('title'),
4814 'uploader_id': metadata_renderer
.get('externalId'),
4815 'uploader_url': metadata_renderer
.get('channelUrl'),
4817 if info
['uploader_id']:
4818 info
['id'] = info
['uploader_id']
4820 metadata_renderer
= traverse_obj(data
, ('metadata', 'playlistMetadataRenderer'), expected_type
=dict)
4822 # We can get the uncropped banner/avatar by replacing the crop params with '=s0'
4823 # See: https://github.com/yt-dlp/yt-dlp/issues/2237#issuecomment-1013694714
4824 def _get_uncropped(url
):
4825 return url_or_none((url
or '').split('=')[0] + '=s0')
4827 avatar_thumbnails
= self
._extract
_thumbnails
(metadata_renderer
, 'avatar')
4828 if avatar_thumbnails
:
4829 uncropped_avatar
= _get_uncropped(avatar_thumbnails
[0]['url'])
4830 if uncropped_avatar
:
4831 avatar_thumbnails
.append({
4832 'url': uncropped_avatar
,
4833 'id': 'avatar_uncropped',
4837 channel_banners
= self
._extract
_thumbnails
(
4838 data
, ('header', ..., ('banner', 'mobileBanner', 'tvBanner')))
4839 for banner
in channel_banners
:
4840 banner
['preference'] = -10
4843 uncropped_banner
= _get_uncropped(channel_banners
[0]['url'])
4844 if uncropped_banner
:
4845 channel_banners
.append({
4846 'url': uncropped_banner
,
4847 'id': 'banner_uncropped',
4851 # Deprecated - remove primary_sidebar_renderer when layout discontinued
4852 primary_sidebar_renderer
= self
._extract
_sidebar
_info
_renderer
(data
, 'playlistSidebarPrimaryInfoRenderer')
4853 playlist_header_renderer
= traverse_obj(data
, ('header', 'playlistHeaderRenderer'), expected_type
=dict)
4855 primary_thumbnails
= self
._extract
_thumbnails
(
4856 primary_sidebar_renderer
, ('thumbnailRenderer', ('playlistVideoThumbnailRenderer', 'playlistCustomThumbnailRenderer'), 'thumbnail'))
4857 playlist_thumbnails
= self
._extract
_thumbnails
(
4858 playlist_header_renderer
, ('playlistHeaderBanner', 'heroPlaylistThumbnailRenderer', 'thumbnail'))
4861 'title': (traverse_obj(metadata_renderer
, 'title')
4862 or self
._get
_text
(data
, ('header', 'hashtagHeaderRenderer', 'hashtag'))
4864 'availability': self
._extract
_availability
(data
),
4865 'channel_follower_count': self
._get
_count
(data
, ('header', ..., 'subscriberCountText')),
4866 'description': try_get(metadata_renderer
, lambda x
: x
.get('description', '')),
4867 'tags': try_get(metadata_renderer
or {}, lambda x
: x
.get('keywords', '').split()),
4868 'thumbnails': (primary_thumbnails
or playlist_thumbnails
) + avatar_thumbnails
+ channel_banners
,
4871 # Playlist stats is a text runs array containing [video count, view count, last updated].
4872 # last updated or (view count and last updated) may be missing.
4873 playlist_stats
= get_first(
4874 (primary_sidebar_renderer
, playlist_header_renderer
), (('stats', 'briefStats', 'numVideosText'), ))
4876 last_updated_unix
= self
._parse
_time
_text
(
4877 self
._get
_text
(playlist_stats
, 2) # deprecated, remove when old layout discontinued
4878 or self
._get
_text
(playlist_header_renderer
, ('byline', 1, 'playlistBylineRenderer', 'text')))
4879 info
['modified_date'] = strftime_or_none(last_updated_unix
, '%Y%m%d')
4881 info
['view_count'] = self
._get
_count
(playlist_stats
, 1)
4882 if info
['view_count'] is None: # 0 is allowed
4883 info
['view_count'] = self
._get
_count
(playlist_header_renderer
, 'viewCountText')
4884 if info
['view_count'] is None:
4885 info
['view_count'] = self
._get
_count
(data
, (
4886 'contents', 'twoColumnBrowseResultsRenderer', 'tabs', ..., 'tabRenderer', 'content', 'sectionListRenderer',
4887 'contents', ..., 'itemSectionRenderer', 'contents', ..., 'channelAboutFullMetadataRenderer', 'viewCountText'))
4889 info
['playlist_count'] = self
._get
_count
(playlist_stats
, 0)
4890 if info
['playlist_count'] is None: # 0 is allowed
4891 info
['playlist_count'] = self
._get
_count
(playlist_header_renderer
, ('byline', 0, 'playlistBylineRenderer', 'text'))
4893 if not info
.get('uploader_id'):
4894 owner
= traverse_obj(playlist_header_renderer
, 'ownerText')
4895 if not owner
: # Deprecated
4896 owner
= traverse_obj(
4897 self
._extract
_sidebar
_info
_renderer
(data
, 'playlistSidebarSecondaryInfoRenderer'),
4898 ('videoOwner', 'videoOwnerRenderer', 'title'))
4899 owner_text
= self
._get
_text
(owner
)
4900 browse_ep
= traverse_obj(owner
, ('runs', 0, 'navigationEndpoint', 'browseEndpoint')) or {}
4902 'uploader': self
._search
_regex
(r
'^by (.+) and \d+ others?$', owner_text
, 'uploader', default
=owner_text
),
4903 'uploader_id': browse_ep
.get('browseId'),
4904 'uploader_url': urljoin('https://www.youtube.com', browse_ep
.get('canonicalBaseUrl'))
4908 'channel': info
['uploader'],
4909 'channel_id': info
['uploader_id'],
4910 'channel_url': info
['uploader_url']
4914 def _extract_inline_playlist(self
, playlist
, playlist_id
, data
, ytcfg
):
4915 first_id
= last_id
= response
= None
4916 for page_num
in itertools
.count(1):
4917 videos
= list(self
._playlist
_entries
(playlist
))
4920 start
= next((i
for i
, v
in enumerate(videos
) if v
['id'] == last_id
), -1) + 1
4921 if start
>= len(videos
):
4923 yield from videos
[start
:]
4924 first_id
= first_id
or videos
[0]['id']
4925 last_id
= videos
[-1]['id']
4926 watch_endpoint
= try_get(
4927 playlist
, lambda x
: x
['contents'][-1]['playlistPanelVideoRenderer']['navigationEndpoint']['watchEndpoint'])
4928 headers
= self
.generate_api_headers(
4929 ytcfg
=ytcfg
, account_syncid
=self
._extract
_account
_syncid
(ytcfg
, data
),
4930 visitor_data
=self
._extract
_visitor
_data
(response
, data
, ytcfg
))
4932 'playlistId': playlist_id
,
4933 'videoId': watch_endpoint
.get('videoId') or last_id
,
4934 'index': watch_endpoint
.get('index') or len(videos
),
4935 'params': watch_endpoint
.get('params') or 'OAE%3D'
4937 response
= self
._extract
_response
(
4938 item_id
='%s page %d' % (playlist_id
, page_num
),
4939 query
=query
, ep
='next', headers
=headers
, ytcfg
=ytcfg
,
4940 check_get_keys
='contents'
4943 response
, lambda x
: x
['contents']['twoColumnWatchNextResults']['playlist']['playlist'], dict)
4945 def _extract_from_playlist(self
, item_id
, url
, data
, playlist
, ytcfg
):
4946 title
= playlist
.get('title') or try_get(
4947 data
, lambda x
: x
['titleText']['simpleText'], str)
4948 playlist_id
= playlist
.get('playlistId') or item_id
4950 # Delegating everything except mix playlists to regular tab-based playlist URL
4951 playlist_url
= urljoin(url
, try_get(
4952 playlist
, lambda x
: x
['endpoint']['commandMetadata']['webCommandMetadata']['url'],
4955 # Some playlists are unviewable but YouTube still provides a link to the (broken) playlist page [1]
4956 # [1] MLCT, RLTDwFCb4jeqaKWnciAYM-ZVHg
4957 is_known_unviewable
= re
.fullmatch(r
'MLCT|RLTD[\w-]{22}', playlist_id
)
4959 if playlist_url
and playlist_url
!= url
and not is_known_unviewable
:
4960 return self
.url_result(
4961 playlist_url
, ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
,
4964 return self
.playlist_result(
4965 self
._extract
_inline
_playlist
(playlist
, playlist_id
, data
, ytcfg
),
4966 playlist_id
=playlist_id
, playlist_title
=title
)
4968 def _extract_availability(self
, data
):
4970 Gets the availability of a given playlist/tab.
4971 Note: Unless YouTube tells us explicitly, we do not assume it is public
4972 @param data: response
4974 sidebar_renderer
= self
._extract
_sidebar
_info
_renderer
(data
, 'playlistSidebarPrimaryInfoRenderer') or {}
4975 playlist_header_renderer
= traverse_obj(data
, ('header', 'playlistHeaderRenderer')) or {}
4976 player_header_privacy
= playlist_header_renderer
.get('privacy')
4978 badges
= self
._extract
_badges
(sidebar_renderer
)
4980 # Personal playlists, when authenticated, have a dropdown visibility selector instead of a badge
4981 privacy_setting_icon
= get_first(
4982 (playlist_header_renderer
, sidebar_renderer
),
4983 ('privacyForm', 'dropdownFormFieldRenderer', 'dropdown', 'dropdownRenderer', 'entries',
4984 lambda _
, v
: v
['privacyDropdownItemRenderer']['isSelected'], 'privacyDropdownItemRenderer', 'icon', 'iconType'),
4987 microformats_is_unlisted
= traverse_obj(
4988 data
, ('microformat', 'microformatDataRenderer', 'unlisted'), expected_type
=bool)
4992 self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PUBLIC
)
4993 or player_header_privacy
== 'PUBLIC'
4994 or privacy_setting_icon
== 'PRIVACY_PUBLIC')
4995 else self
._availability
(
4997 self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PRIVATE
)
4998 or player_header_privacy
== 'PRIVATE' if player_header_privacy
is not None
4999 else privacy_setting_icon
== 'PRIVACY_PRIVATE' if privacy_setting_icon
is not None else None),
5001 self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_UNLISTED
)
5002 or player_header_privacy
== 'UNLISTED' if player_header_privacy
is not None
5003 else privacy_setting_icon
== 'PRIVACY_UNLISTED' if privacy_setting_icon
is not None
5004 else microformats_is_unlisted
if microformats_is_unlisted
is not None else None),
5005 needs_subscription
=self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_SUBSCRIPTION
) or None,
5006 needs_premium
=self
._has
_badge
(badges
, BadgeType
.AVAILABILITY_PREMIUM
) or None,
5010 def _extract_sidebar_info_renderer(data
, info_renderer
, expected_type
=dict):
5011 sidebar_renderer
= try_get(
5012 data
, lambda x
: x
['sidebar']['playlistSidebarRenderer']['items'], list) or []
5013 for item
in sidebar_renderer
:
5014 renderer
= try_get(item
, lambda x
: x
[info_renderer
], expected_type
)
5018 def _reload_with_unavailable_videos(self
, item_id
, data
, ytcfg
):
5020 Reload playlists with unavailable videos (e.g. private videos, region blocked, etc.)
5022 is_playlist
= bool(traverse_obj(
5023 data
, ('metadata', 'playlistMetadataRenderer'), ('header', 'playlistHeaderRenderer')))
5026 headers
= self
.generate_api_headers(
5027 ytcfg
=ytcfg
, account_syncid
=self
._extract
_account
_syncid
(ytcfg
, data
),
5028 visitor_data
=self
._extract
_visitor
_data
(data
, ytcfg
))
5030 'params': 'wgYCCAA=',
5031 'browseId': f
'VL{item_id}'
5033 return self
._extract
_response
(
5034 item_id
=item_id
, headers
=headers
, query
=query
,
5035 check_get_keys
='contents', fatal
=False, ytcfg
=ytcfg
,
5036 note
='Redownloading playlist API JSON with unavailable videos')
5038 @functools.cached_property
5039 def skip_webpage(self
):
5040 return 'webpage' in self
._configuration
_arg
('skip', ie_key
=YoutubeTabIE
.ie_key())
5042 def _extract_webpage(self
, url
, item_id
, fatal
=True):
5043 webpage
, data
= None, None
5044 for retry
in self
.RetryManager(fatal
=fatal
):
5046 webpage
= self
._download
_webpage
(url
, item_id
, note
='Downloading webpage')
5047 data
= self
.extract_yt_initial_data(item_id
, webpage
or '', fatal
=fatal
) or {}
5048 except ExtractorError
as e
:
5049 if isinstance(e
.cause
, network_exceptions
):
5050 if not isinstance(e
.cause
, urllib
.error
.HTTPError
) or e
.cause
.code
not in (403, 429):
5053 self
._error
_or
_warning
(e
, fatal
=fatal
)
5057 self
._extract
_and
_report
_alerts
(data
)
5058 except ExtractorError
as e
:
5059 self
._error
_or
_warning
(e
, fatal
=fatal
)
5062 # Sometimes youtube returns a webpage with incomplete ytInitialData
5063 # See: https://github.com/yt-dlp/yt-dlp/issues/116
5064 if not traverse_obj(data
, 'contents', 'currentVideoEndpoint', 'onResponseReceivedActions'):
5065 retry
.error
= ExtractorError('Incomplete yt initial data received')
5068 return webpage
, data
5070 def _report_playlist_authcheck(self
, ytcfg
, fatal
=True):
5071 """Use if failed to extract ytcfg (and data) from initial webpage"""
5072 if not ytcfg
and self
.is_authenticated
:
5073 msg
= 'Playlists that require authentication may not extract correctly without a successful webpage download'
5074 if 'authcheck' not in self
._configuration
_arg
('skip', ie_key
=YoutubeTabIE
.ie_key()) and fatal
:
5075 raise ExtractorError(
5076 f
'{msg}. If you are not downloading private content, or '
5077 'your cookies are only for the first account and channel,'
5078 ' pass "--extractor-args youtubetab:skip=authcheck" to skip this check',
5080 self
.report_warning(msg
, only_once
=True)
5082 def _extract_data(self
, url
, item_id
, ytcfg
=None, fatal
=True, webpage_fatal
=False, default_client
='web'):
5084 if not self
.skip_webpage
:
5085 webpage
, data
= self
._extract
_webpage
(url
, item_id
, fatal
=webpage_fatal
)
5086 ytcfg
= ytcfg
or self
.extract_ytcfg(item_id
, webpage
)
5087 # Reject webpage data if redirected to home page without explicitly requesting
5088 selected_tab
= self
._extract
_selected
_tab
(self
._extract
_tab
_renderers
(data
), fatal
=False) or {}
5089 if (url
!= 'https://www.youtube.com/feed/recommended'
5090 and selected_tab
.get('tabIdentifier') == 'FEwhat_to_watch' # Home page
5091 and 'no-youtube-channel-redirect' not in self
.get_param('compat_opts', [])):
5092 msg
= 'The channel/playlist does not exist and the URL redirected to youtube.com home page'
5094 raise ExtractorError(msg
, expected
=True)
5095 self
.report_warning(msg
, only_once
=True)
5097 self
._report
_playlist
_authcheck
(ytcfg
, fatal
=fatal
)
5098 data
= self
._extract
_tab
_endpoint
(url
, item_id
, ytcfg
, fatal
=fatal
, default_client
=default_client
)
5101 def _extract_tab_endpoint(self
, url
, item_id
, ytcfg
=None, fatal
=True, default_client
='web'):
5102 headers
= self
.generate_api_headers(ytcfg
=ytcfg
, default_client
=default_client
)
5103 resolve_response
= self
._extract
_response
(
5104 item_id
=item_id
, query
={'url': url}
, check_get_keys
='endpoint', headers
=headers
, ytcfg
=ytcfg
, fatal
=fatal
,
5105 ep
='navigation/resolve_url', note
='Downloading API parameters API JSON', default_client
=default_client
)
5106 endpoints
= {'browseEndpoint': 'browse', 'watchEndpoint': 'next'}
5107 for ep_key
, ep
in endpoints
.items():
5108 params
= try_get(resolve_response
, lambda x
: x
['endpoint'][ep_key
], dict)
5110 return self
._extract
_response
(
5111 item_id
=item_id
, query
=params
, ep
=ep
, headers
=headers
,
5112 ytcfg
=ytcfg
, fatal
=fatal
, default_client
=default_client
,
5113 check_get_keys
=('contents', 'currentVideoEndpoint', 'onResponseReceivedActions'))
5114 err_note
= 'Failed to resolve url (does the playlist exist?)'
5116 raise ExtractorError(err_note
, expected
=True)
5117 self
.report_warning(err_note
, item_id
)
5119 _SEARCH_PARAMS
= None
5121 def _search_results(self
, query
, params
=NO_DEFAULT
, default_client
='web'):
5122 data
= {'query': query}
5123 if params
is NO_DEFAULT
:
5124 params
= self
._SEARCH
_PARAMS
5126 data
['params'] = params
5129 ('contents', 'twoColumnSearchResultsRenderer', 'primaryContents', 'sectionListRenderer', 'contents'),
5130 ('onResponseReceivedCommands', 0, 'appendContinuationItemsAction', 'continuationItems'),
5132 ('contents', 'tabbedSearchResultsRenderer', 'tabs', 0, 'tabRenderer', 'content', 'sectionListRenderer', 'contents'),
5133 ('continuationContents', ),
5135 display_id
= f
'query "{query}"'
5136 check_get_keys
= tuple({keys[0] for keys in content_keys}
)
5137 ytcfg
= self
._download
_ytcfg
(default_client
, display_id
) if not self
.skip_webpage
else {}
5138 self
._report
_playlist
_authcheck
(ytcfg
, fatal
=False)
5140 continuation_list
= [None]
5142 for page_num
in itertools
.count(1):
5143 data
.update(continuation_list
[0] or {})
5144 headers
= self
.generate_api_headers(
5145 ytcfg
=ytcfg
, visitor_data
=self
._extract
_visitor
_data
(search
), default_client
=default_client
)
5146 search
= self
._extract
_response
(
5147 item_id
=f
'{display_id} page {page_num}', ep
='search', query
=data
,
5148 default_client
=default_client
, check_get_keys
=check_get_keys
, ytcfg
=ytcfg
, headers
=headers
)
5149 slr_contents
= traverse_obj(search
, *content_keys
)
5150 yield from self
._extract
_entries
({'contents': list(variadic(slr_contents))}
, continuation_list
)
5151 if not continuation_list
[0]:
5155 class YoutubeTabIE(YoutubeTabBaseInfoExtractor
):
5156 IE_DESC
= 'YouTube Tabs'
5157 _VALID_URL
= r
'''(?x:
5159 (?!consent\.)(?:\w+\.)?
5161 youtube(?:kids)?\.com|
5165 (?P<channel_type>channel|c|user|browse)/|
5168 (?:playlist|watch)\?.*?\blist=
5170 (?!(?:%(reserved_names)s)\b) # Direct URLs
5174 'reserved_names': YoutubeBaseInfoExtractor
._RESERVED
_NAMES
,
5175 'invidious': '|'.join(YoutubeBaseInfoExtractor
._INVIDIOUS
_SITES
),
5177 IE_NAME
= 'youtube:tab'
5180 'note': 'playlists, multipage',
5181 'url': 'https://www.youtube.com/c/ИгорьКлейнер/playlists?view=1&flow=grid',
5182 'playlist_mincount': 94,
5184 'id': 'UCqj7Cz7revf5maW9g5pgNcg',
5185 'title': 'Igor Kleiner - Playlists',
5186 'description': 'md5:be97ee0f14ee314f1f002cf187166ee2',
5187 'uploader': 'Igor Kleiner',
5188 'uploader_id': 'UCqj7Cz7revf5maW9g5pgNcg',
5189 'channel': 'Igor Kleiner',
5190 'channel_id': 'UCqj7Cz7revf5maW9g5pgNcg',
5191 'tags': ['"критическое', 'мышление"', '"наука', 'просто"', 'математика', '"анализ', 'данных"'],
5192 'channel_url': 'https://www.youtube.com/channel/UCqj7Cz7revf5maW9g5pgNcg',
5193 'uploader_url': 'https://www.youtube.com/channel/UCqj7Cz7revf5maW9g5pgNcg',
5194 'channel_follower_count': int
5197 'note': 'playlists, multipage, different order',
5198 'url': 'https://www.youtube.com/user/igorkle1/playlists?view=1&sort=dd',
5199 'playlist_mincount': 94,
5201 'id': 'UCqj7Cz7revf5maW9g5pgNcg',
5202 'title': 'Igor Kleiner - Playlists',
5203 'description': 'md5:be97ee0f14ee314f1f002cf187166ee2',
5204 'uploader_id': 'UCqj7Cz7revf5maW9g5pgNcg',
5205 'uploader': 'Igor Kleiner',
5206 'uploader_url': 'https://www.youtube.com/channel/UCqj7Cz7revf5maW9g5pgNcg',
5207 'tags': ['"критическое', 'мышление"', '"наука', 'просто"', 'математика', '"анализ', 'данных"'],
5208 'channel_id': 'UCqj7Cz7revf5maW9g5pgNcg',
5209 'channel': 'Igor Kleiner',
5210 'channel_url': 'https://www.youtube.com/channel/UCqj7Cz7revf5maW9g5pgNcg',
5211 'channel_follower_count': int
5214 'note': 'playlists, series',
5215 'url': 'https://www.youtube.com/c/3blue1brown/playlists?view=50&sort=dd&shelf_id=3',
5216 'playlist_mincount': 5,
5218 'id': 'UCYO_jab_esuFRV4b17AJtAw',
5219 'title': '3Blue1Brown - Playlists',
5220 'description': 'md5:e1384e8a133307dd10edee76e875d62f',
5221 'uploader_id': 'UCYO_jab_esuFRV4b17AJtAw',
5222 'uploader': '3Blue1Brown',
5223 'channel_url': 'https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw',
5224 'uploader_url': 'https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw',
5225 'channel': '3Blue1Brown',
5226 'channel_id': 'UCYO_jab_esuFRV4b17AJtAw',
5227 'tags': ['Mathematics'],
5228 'channel_follower_count': int
5231 'note': 'playlists, singlepage',
5232 'url': 'https://www.youtube.com/user/ThirstForScience/playlists',
5233 'playlist_mincount': 4,
5235 'id': 'UCAEtajcuhQ6an9WEzY9LEMQ',
5236 'title': 'ThirstForScience - Playlists',
5237 'description': 'md5:609399d937ea957b0f53cbffb747a14c',
5238 'uploader': 'ThirstForScience',
5239 'uploader_id': 'UCAEtajcuhQ6an9WEzY9LEMQ',
5240 'uploader_url': 'https://www.youtube.com/channel/UCAEtajcuhQ6an9WEzY9LEMQ',
5241 'channel_url': 'https://www.youtube.com/channel/UCAEtajcuhQ6an9WEzY9LEMQ',
5242 'channel_id': 'UCAEtajcuhQ6an9WEzY9LEMQ',
5244 'channel': 'ThirstForScience',
5245 'channel_follower_count': int
5248 'url': 'https://www.youtube.com/c/ChristophLaimer/playlists',
5249 'only_matching': True,
5251 'note': 'basic, single video playlist',
5252 'url': 'https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc',
5254 'uploader_id': 'UCmlqkdCBesrv2Lak1mF_MxA',
5255 'uploader': 'Sergey M.',
5256 'id': 'PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc',
5257 'title': 'youtube-dl public playlist',
5261 'modified_date': '20201130',
5262 'channel': 'Sergey M.',
5263 'channel_id': 'UCmlqkdCBesrv2Lak1mF_MxA',
5264 'uploader_url': 'https://www.youtube.com/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5265 'channel_url': 'https://www.youtube.com/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5266 'availability': 'public',
5268 'playlist_count': 1,
5270 'note': 'empty playlist',
5271 'url': 'https://www.youtube.com/playlist?list=PL4lCao7KL_QFodcLWhDpGCYnngnHtQ-Xf',
5273 'uploader_id': 'UCmlqkdCBesrv2Lak1mF_MxA',
5274 'uploader': 'Sergey M.',
5275 'id': 'PL4lCao7KL_QFodcLWhDpGCYnngnHtQ-Xf',
5276 'title': 'youtube-dl empty playlist',
5278 'channel': 'Sergey M.',
5280 'modified_date': '20160902',
5281 'channel_id': 'UCmlqkdCBesrv2Lak1mF_MxA',
5282 'channel_url': 'https://www.youtube.com/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5283 'uploader_url': 'https://www.youtube.com/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5284 'availability': 'public',
5286 'playlist_count': 0,
5289 'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/featured',
5291 'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5292 'title': 'lex will - Home',
5293 'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
5294 'uploader': 'lex will',
5295 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5296 'channel': 'lex will',
5297 'tags': ['bible', 'history', 'prophesy'],
5298 'uploader_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5299 'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5300 'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5301 'channel_follower_count': int
5303 'playlist_mincount': 2,
5305 'note': 'Videos tab',
5306 'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/videos',
5308 'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5309 'title': 'lex will - Videos',
5310 'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
5311 'uploader': 'lex will',
5312 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5313 'tags': ['bible', 'history', 'prophesy'],
5314 'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5315 'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5316 'uploader_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5317 'channel': 'lex will',
5318 'channel_follower_count': int
5320 'playlist_mincount': 975,
5322 'note': 'Videos tab, sorted by popular',
5323 'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/videos?view=0&sort=p&flow=grid',
5325 'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5326 'title': 'lex will - Videos',
5327 'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
5328 'uploader': 'lex will',
5329 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5330 'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5331 'uploader_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5332 'channel': 'lex will',
5333 'tags': ['bible', 'history', 'prophesy'],
5334 'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5335 'channel_follower_count': int
5337 'playlist_mincount': 199,
5339 'note': 'Playlists tab',
5340 'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/playlists',
5342 'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5343 'title': 'lex will - Playlists',
5344 'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
5345 'uploader': 'lex will',
5346 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5347 'uploader_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5348 'channel': 'lex will',
5349 'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5350 'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5351 'tags': ['bible', 'history', 'prophesy'],
5352 'channel_follower_count': int
5354 'playlist_mincount': 17,
5356 'note': 'Community tab',
5357 'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/community',
5359 'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5360 'title': 'lex will - Community',
5361 'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
5362 'uploader': 'lex will',
5363 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5364 'uploader_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5365 'channel': 'lex will',
5366 'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5367 'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5368 'tags': ['bible', 'history', 'prophesy'],
5369 'channel_follower_count': int
5371 'playlist_mincount': 18,
5373 'note': 'Channels tab',
5374 'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/channels',
5376 'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5377 'title': 'lex will - Channels',
5378 'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
5379 'uploader': 'lex will',
5380 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5381 'uploader_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5382 'channel': 'lex will',
5383 'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
5384 'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
5385 'tags': ['bible', 'history', 'prophesy'],
5386 'channel_follower_count': int
5388 'playlist_mincount': 12,
5390 'note': 'Search tab',
5391 'url': 'https://www.youtube.com/c/3blue1brown/search?query=linear%20algebra',
5392 'playlist_mincount': 40,
5394 'id': 'UCYO_jab_esuFRV4b17AJtAw',
5395 'title': '3Blue1Brown - Search - linear algebra',
5396 'description': 'md5:e1384e8a133307dd10edee76e875d62f',
5397 'uploader': '3Blue1Brown',
5398 'uploader_id': 'UCYO_jab_esuFRV4b17AJtAw',
5399 'channel_url': 'https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw',
5400 'uploader_url': 'https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw',
5401 'tags': ['Mathematics'],
5402 'channel': '3Blue1Brown',
5403 'channel_id': 'UCYO_jab_esuFRV4b17AJtAw',
5404 'channel_follower_count': int
5407 'url': 'https://invidio.us/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5408 'only_matching': True,
5410 'url': 'https://www.youtubekids.com/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5411 'only_matching': True,
5413 'url': 'https://music.youtube.com/channel/UCmlqkdCBesrv2Lak1mF_MxA',
5414 'only_matching': True,
5416 'note': 'Playlist with deleted videos (#651). As a bonus, the video #51 is also twice in this list.',
5417 'url': 'https://www.youtube.com/playlist?list=PLwP_SiAcdui0KVebT0mU9Apz359a4ubsC',
5419 'title': '29C3: Not my department',
5420 'id': 'PLwP_SiAcdui0KVebT0mU9Apz359a4ubsC',
5421 'uploader': 'Christiaan008',
5422 'uploader_id': 'UCEPzS1rYsrkqzSLNp76nrcg',
5423 'description': 'md5:a14dc1a8ef8307a9807fe136a0660268',
5425 'uploader_url': 'https://www.youtube.com/c/ChRiStIaAn008',
5427 'modified_date': '20150605',
5428 'channel_id': 'UCEPzS1rYsrkqzSLNp76nrcg',
5429 'channel_url': 'https://www.youtube.com/c/ChRiStIaAn008',
5430 'channel': 'Christiaan008',
5431 'availability': 'public',
5433 'playlist_count': 96,
5435 'note': 'Large playlist',
5436 'url': 'https://www.youtube.com/playlist?list=UUBABnxM4Ar9ten8Mdjj1j0Q',
5438 'title': 'Uploads from Cauchemar',
5439 'id': 'UUBABnxM4Ar9ten8Mdjj1j0Q',
5440 'uploader': 'Cauchemar',
5441 'uploader_id': 'UCBABnxM4Ar9ten8Mdjj1j0Q',
5442 'channel_url': 'https://www.youtube.com/c/Cauchemar89',
5444 'modified_date': r
're:\d{8}',
5445 'channel': 'Cauchemar',
5446 'uploader_url': 'https://www.youtube.com/c/Cauchemar89',
5449 'channel_id': 'UCBABnxM4Ar9ten8Mdjj1j0Q',
5450 'availability': 'public',
5452 'playlist_mincount': 1123,
5453 'expected_warnings': [r
'[Uu]navailable videos (are|will be) hidden'],
5455 'note': 'even larger playlist, 8832 videos',
5456 'url': 'http://www.youtube.com/user/NASAgovVideo/videos',
5457 'only_matching': True,
5459 'note': 'Buggy playlist: the webpage has a "Load more" button but it doesn\'t have more videos',
5460 'url': 'https://www.youtube.com/playlist?list=UUXw-G3eDE9trcvY2sBMM_aA',
5462 'title': 'Uploads from Interstellar Movie',
5463 'id': 'UUXw-G3eDE9trcvY2sBMM_aA',
5464 'uploader': 'Interstellar Movie',
5465 'uploader_id': 'UCXw-G3eDE9trcvY2sBMM_aA',
5466 'uploader_url': 'https://www.youtube.com/c/InterstellarMovie',
5469 'channel_id': 'UCXw-G3eDE9trcvY2sBMM_aA',
5470 'channel_url': 'https://www.youtube.com/c/InterstellarMovie',
5471 'channel': 'Interstellar Movie',
5473 'modified_date': r
're:\d{8}',
5474 'availability': 'public',
5476 'playlist_mincount': 21,
5478 'note': 'Playlist with "show unavailable videos" button',
5479 'url': 'https://www.youtube.com/playlist?list=UUTYLiWFZy8xtPwxFwX9rV7Q',
5481 'title': 'Uploads from Phim Siêu Nhân Nhật Bản',
5482 'id': 'UUTYLiWFZy8xtPwxFwX9rV7Q',
5483 'uploader': 'Phim Siêu Nhân Nhật Bản',
5484 'uploader_id': 'UCTYLiWFZy8xtPwxFwX9rV7Q',
5486 'channel': 'Phim Siêu Nhân Nhật Bản',
5488 'uploader_url': 'https://www.youtube.com/channel/UCTYLiWFZy8xtPwxFwX9rV7Q',
5490 'channel_url': 'https://www.youtube.com/channel/UCTYLiWFZy8xtPwxFwX9rV7Q',
5491 'channel_id': 'UCTYLiWFZy8xtPwxFwX9rV7Q',
5492 'modified_date': r
're:\d{8}',
5493 'availability': 'public',
5495 'playlist_mincount': 200,
5496 'expected_warnings': [r
'[Uu]navailable videos (are|will be) hidden'],
5498 'note': 'Playlist with unavailable videos in page 7',
5499 'url': 'https://www.youtube.com/playlist?list=UU8l9frL61Yl5KFOl87nIm2w',
5501 'title': 'Uploads from BlankTV',
5502 'id': 'UU8l9frL61Yl5KFOl87nIm2w',
5503 'uploader': 'BlankTV',
5504 'uploader_id': 'UC8l9frL61Yl5KFOl87nIm2w',
5505 'channel': 'BlankTV',
5506 'channel_url': 'https://www.youtube.com/c/blanktv',
5507 'channel_id': 'UC8l9frL61Yl5KFOl87nIm2w',
5510 'uploader_url': 'https://www.youtube.com/c/blanktv',
5511 'modified_date': r
're:\d{8}',
5513 'availability': 'public',
5515 'playlist_mincount': 1000,
5516 'expected_warnings': [r
'[Uu]navailable videos (are|will be) hidden'],
5518 'note': 'https://github.com/ytdl-org/youtube-dl/issues/21844',
5519 'url': 'https://www.youtube.com/playlist?list=PLzH6n4zXuckpfMu_4Ff8E7Z1behQks5ba',
5521 'title': 'Data Analysis with Dr Mike Pound',
5522 'id': 'PLzH6n4zXuckpfMu_4Ff8E7Z1behQks5ba',
5523 'uploader_id': 'UC9-y-6csu5WGm29I7JiwpnA',
5524 'uploader': 'Computerphile',
5525 'description': 'md5:7f567c574d13d3f8c0954d9ffee4e487',
5526 'uploader_url': 'https://www.youtube.com/user/Computerphile',
5529 'channel_id': 'UC9-y-6csu5WGm29I7JiwpnA',
5530 'channel_url': 'https://www.youtube.com/user/Computerphile',
5531 'channel': 'Computerphile',
5532 'availability': 'public',
5533 'modified_date': '20190712',
5535 'playlist_mincount': 11,
5537 'url': 'https://invidio.us/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc',
5538 'only_matching': True,
5540 'note': 'Playlist URL that does not actually serve a playlist',
5541 'url': 'https://www.youtube.com/watch?v=FqZTN594JQw&list=PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4',
5543 'id': 'FqZTN594JQw',
5545 'title': "Smiley's People 01 detective, Adventure Series, Action",
5546 'uploader': 'STREEM',
5547 'uploader_id': 'UCyPhqAZgwYWZfxElWVbVJng',
5548 'uploader_url': r
're:https?://(?:www\.)?youtube\.com/channel/UCyPhqAZgwYWZfxElWVbVJng',
5549 'upload_date': '20150526',
5550 'license': 'Standard YouTube License',
5551 'description': 'md5:507cdcb5a49ac0da37a920ece610be80',
5552 'categories': ['People & Blogs'],
5558 'skip_download': True,
5560 'skip': 'This video is not available.',
5561 'add_ie': [YoutubeIE
.ie_key()],
5563 'url': 'https://www.youtubekids.com/watch?v=Agk7R8I8o5U&list=PUZ6jURNr1WQZCNHF0ao-c0g',
5564 'only_matching': True,
5566 'url': 'https://www.youtube.com/watch?v=MuAGGZNfUkU&list=RDMM',
5567 'only_matching': True,
5569 'url': 'https://www.youtube.com/channel/UCoMdktPbSTixAyNGwb-UYkQ/live',
5571 'id': 'Wq15eF5vCbI', # This will keep changing
5574 'uploader': 'Sky News',
5575 'uploader_id': 'skynews',
5576 'uploader_url': r
're:https?://(?:www\.)?youtube\.com/user/skynews',
5577 'upload_date': r
're:\d{8}',
5579 'categories': ['News & Politics'],
5582 'release_timestamp': int,
5583 'channel': 'Sky News',
5584 'channel_id': 'UCoMdktPbSTixAyNGwb-UYkQ',
5587 'thumbnail': r
're:https?://i\.ytimg\.com/vi/[^/]+/maxresdefault(?:_live)?\.jpg',
5588 'playable_in_embed': True,
5589 'release_date': r
're:\d+',
5590 'availability': 'public',
5591 'live_status': 'is_live',
5592 'channel_url': 'https://www.youtube.com/channel/UCoMdktPbSTixAyNGwb-UYkQ',
5593 'channel_follower_count': int,
5594 'concurrent_view_count': int,
5597 'skip_download': True,
5599 'expected_warnings': ['Ignoring subtitle tracks found in '],
5601 'url': 'https://www.youtube.com/user/TheYoungTurks/live',
5603 'id': 'a48o2S1cPoo',
5605 'title': 'The Young Turks - Live Main Show',
5606 'uploader': 'The Young Turks',
5607 'uploader_id': 'TheYoungTurks',
5608 'uploader_url': r
're:https?://(?:www\.)?youtube\.com/user/TheYoungTurks',
5609 'upload_date': '20150715',
5610 'license': 'Standard YouTube License',
5611 'description': 'md5:438179573adcdff3c97ebb1ee632b891',
5612 'categories': ['News & Politics'],
5613 'tags': ['Cenk Uygur (TV Program Creator)', 'The Young Turks (Award-Winning Work)', 'Talk Show (TV Genre)'],
5617 'skip_download': True,
5619 'only_matching': True,
5621 'url': 'https://www.youtube.com/channel/UC1yBKRuGpC1tSM73A0ZjYjQ/live',
5622 'only_matching': True,
5624 'url': 'https://www.youtube.com/c/CommanderVideoHq/live',
5625 'only_matching': True,
5627 'note': 'A channel that is not live. Should raise error',
5628 'url': 'https://www.youtube.com/user/numberphile/live',
5629 'only_matching': True,
5631 'url': 'https://www.youtube.com/feed/trending',
5632 'only_matching': True,
5634 'url': 'https://www.youtube.com/feed/library',
5635 'only_matching': True,
5637 'url': 'https://www.youtube.com/feed/history',
5638 'only_matching': True,
5640 'url': 'https://www.youtube.com/feed/subscriptions',
5641 'only_matching': True,
5643 'url': 'https://www.youtube.com/feed/watch_later',
5644 'only_matching': True,
5646 'note': 'Recommended - redirects to home page.',
5647 'url': 'https://www.youtube.com/feed/recommended',
5648 'only_matching': True,
5650 'note': 'inline playlist with not always working continuations',
5651 'url': 'https://www.youtube.com/watch?v=UC6u0Tct-Fo&list=PL36D642111D65BE7C',
5652 'only_matching': True,
5654 'url': 'https://www.youtube.com/course',
5655 'only_matching': True,
5657 'url': 'https://www.youtube.com/zsecurity',
5658 'only_matching': True,
5660 'url': 'http://www.youtube.com/NASAgovVideo/videos',
5661 'only_matching': True,
5663 'url': 'https://www.youtube.com/TheYoungTurks/live',
5664 'only_matching': True,
5666 'url': 'https://www.youtube.com/hashtag/cctv9',
5672 'playlist_mincount': 300, # not consistent but should be over 300
5674 'url': 'https://www.youtube.com/watch?list=PLW4dVinRY435CBE_JD3t-0SRXKfnZHS1P&feature=youtu.be&v=M9cJMXmQ_ZU',
5675 'only_matching': True,
5677 'note': 'Requires Premium: should request additional YTM-info webpage (and have format 141) for videos in playlist',
5678 'url': 'https://music.youtube.com/playlist?list=PLRBp0Fe2GpgmgoscNFLxNyBVSFVdYmFkq',
5679 'only_matching': True
5681 'note': '/browse/ should redirect to /channel/',
5682 'url': 'https://music.youtube.com/browse/UC1a8OFewdjuLq6KlF8M_8Ng',
5683 'only_matching': True
5685 'note': 'VLPL, should redirect to playlist?list=PL...',
5686 'url': 'https://music.youtube.com/browse/VLPLRBp0Fe2GpgmgoscNFLxNyBVSFVdYmFkq',
5688 'id': 'PLRBp0Fe2GpgmgoscNFLxNyBVSFVdYmFkq',
5689 'uploader': 'NoCopyrightSounds',
5690 'description': 'Providing you with copyright free / safe music for gaming, live streaming, studying and more!',
5691 'uploader_id': 'UC_aEa8K-EOJ3D6gOs7HcyNg',
5692 'title': 'NCS : All Releases 💿',
5693 'uploader_url': 'https://www.youtube.com/c/NoCopyrightSounds',
5694 'channel_url': 'https://www.youtube.com/c/NoCopyrightSounds',
5695 'modified_date': r
're:\d{8}',
5697 'channel_id': 'UC_aEa8K-EOJ3D6gOs7HcyNg',
5699 'channel': 'NoCopyrightSounds',
5700 'availability': 'public',
5702 'playlist_mincount': 166,
5703 'expected_warnings': [r
'[Uu]navailable videos (are|will be) hidden'],
5705 'note': 'Topic, should redirect to playlist?list=UU...',
5706 'url': 'https://music.youtube.com/browse/UC9ALqqC4aIeG5iDs7i90Bfw',
5708 'id': 'UU9ALqqC4aIeG5iDs7i90Bfw',
5709 'uploader_id': 'UC9ALqqC4aIeG5iDs7i90Bfw',
5710 'title': 'Uploads from Royalty Free Music - Topic',
5711 'uploader': 'Royalty Free Music - Topic',
5713 'channel_id': 'UC9ALqqC4aIeG5iDs7i90Bfw',
5714 'channel': 'Royalty Free Music - Topic',
5716 'channel_url': 'https://www.youtube.com/channel/UC9ALqqC4aIeG5iDs7i90Bfw',
5717 'channel_url': 'https://www.youtube.com/channel/UC9ALqqC4aIeG5iDs7i90Bfw',
5718 'modified_date': r
're:\d{8}',
5719 'uploader_url': 'https://www.youtube.com/channel/UC9ALqqC4aIeG5iDs7i90Bfw',
5721 'availability': 'public',
5723 'playlist_mincount': 101,
5725 # Destination channel with only a hidden self tab (tab id is UCtFRv9O2AHqOZjjynzrv-xg)
5726 # Treat as a general feed
5727 'url': 'https://www.youtube.com/channel/UCtFRv9O2AHqOZjjynzrv-xg',
5729 'id': 'UCtFRv9O2AHqOZjjynzrv-xg',
5730 'title': 'UCtFRv9O2AHqOZjjynzrv-xg',
5733 'playlist_mincount': 9,
5735 'note': 'Youtube music Album',
5736 'url': 'https://music.youtube.com/browse/MPREb_gTAcphH99wE',
5738 'id': 'OLAK5uy_l1m0thk3g31NmIIz_vMIbWtyv7eZixlH0',
5739 'title': 'Album - Royalty Free Music Library V2 (50 Songs)',
5743 'availability': 'unlisted',
5744 'modified_date': r
're:\d{8}',
5746 'playlist_count': 50,
5748 'note': 'unlisted single video playlist',
5749 'url': 'https://www.youtube.com/playlist?list=PLwL24UFy54GrB3s2KMMfjZscDi1x5Dajf',
5751 'uploader_id': 'UC9zHu_mHU96r19o-wV5Qs1Q',
5752 'uploader': 'colethedj',
5753 'id': 'PLwL24UFy54GrB3s2KMMfjZscDi1x5Dajf',
5754 'title': 'yt-dlp unlisted playlist test',
5755 'availability': 'unlisted',
5757 'modified_date': '20220418',
5758 'channel': 'colethedj',
5761 'uploader_url': 'https://www.youtube.com/channel/UC9zHu_mHU96r19o-wV5Qs1Q',
5762 'channel_id': 'UC9zHu_mHU96r19o-wV5Qs1Q',
5763 'channel_url': 'https://www.youtube.com/channel/UC9zHu_mHU96r19o-wV5Qs1Q',
5765 'playlist_count': 1,
5767 'note': 'API Fallback: Recommended - redirects to home page. Requires visitorData',
5768 'url': 'https://www.youtube.com/feed/recommended',
5770 'id': 'recommended',
5771 'title': 'recommended',
5774 'playlist_mincount': 50,
5776 'skip_download': True,
5777 'extractor_args': {'youtubetab': {'skip': ['webpage']}
}
5780 'note': 'API Fallback: /videos tab, sorted by oldest first',
5781 'url': 'https://www.youtube.com/user/theCodyReeder/videos?view=0&sort=da&flow=grid',
5783 'id': 'UCu6mSoMNzHQiBIOCkHUa2Aw',
5784 'title': 'Cody\'sLab - Videos',
5785 'description': 'md5:d083b7c2f0c67ee7a6c74c3e9b4243fa',
5786 'uploader': 'Cody\'sLab',
5787 'uploader_id': 'UCu6mSoMNzHQiBIOCkHUa2Aw',
5788 'channel': 'Cody\'sLab',
5789 'channel_id': 'UCu6mSoMNzHQiBIOCkHUa2Aw',
5791 'channel_url': 'https://www.youtube.com/channel/UCu6mSoMNzHQiBIOCkHUa2Aw',
5792 'uploader_url': 'https://www.youtube.com/channel/UCu6mSoMNzHQiBIOCkHUa2Aw',
5793 'channel_follower_count': int
5795 'playlist_mincount': 650,
5797 'skip_download': True,
5798 'extractor_args': {'youtubetab': {'skip': ['webpage']}
}
5800 'skip': 'Query for sorting no longer works',
5802 'note': 'API Fallback: Topic, should redirect to playlist?list=UU...',
5803 'url': 'https://music.youtube.com/browse/UC9ALqqC4aIeG5iDs7i90Bfw',
5805 'id': 'UU9ALqqC4aIeG5iDs7i90Bfw',
5806 'uploader_id': 'UC9ALqqC4aIeG5iDs7i90Bfw',
5807 'title': 'Uploads from Royalty Free Music - Topic',
5808 'uploader': 'Royalty Free Music - Topic',
5809 'modified_date': r
're:\d{8}',
5810 'channel_id': 'UC9ALqqC4aIeG5iDs7i90Bfw',
5812 'channel_url': 'https://www.youtube.com/channel/UC9ALqqC4aIeG5iDs7i90Bfw',
5814 'channel': 'Royalty Free Music - Topic',
5816 'uploader_url': 'https://www.youtube.com/channel/UC9ALqqC4aIeG5iDs7i90Bfw',
5817 'availability': 'public',
5819 'playlist_mincount': 101,
5821 'skip_download': True,
5822 'extractor_args': {'youtubetab': {'skip': ['webpage']}
}
5825 'note': 'non-standard redirect to regional channel',
5826 'url': 'https://www.youtube.com/channel/UCwVVpHQ2Cs9iGJfpdFngePQ',
5827 'only_matching': True
5829 'note': 'collaborative playlist (uploader name in the form "by <uploader> and x other(s)")',
5830 'url': 'https://www.youtube.com/playlist?list=PLx-_-Kk4c89oOHEDQAojOXzEzemXxoqx6',
5832 'id': 'PLx-_-Kk4c89oOHEDQAojOXzEzemXxoqx6',
5833 'modified_date': '20220407',
5834 'channel_url': 'https://www.youtube.com/channel/UCKcqXmCcyqnhgpA5P0oHH_Q',
5836 'uploader_id': 'UCKcqXmCcyqnhgpA5P0oHH_Q',
5837 'uploader': 'pukkandan',
5838 'availability': 'unlisted',
5839 'channel_id': 'UCKcqXmCcyqnhgpA5P0oHH_Q',
5840 'channel': 'pukkandan',
5841 'description': 'Test for collaborative playlist',
5842 'title': 'yt-dlp test - collaborative playlist',
5844 'uploader_url': 'https://www.youtube.com/channel/UCKcqXmCcyqnhgpA5P0oHH_Q',
5846 'playlist_mincount': 2
5848 'note': 'translated tab name',
5849 'url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA/playlists',
5851 'id': 'UCiu-3thuViMebBjw_5nWYrA',
5853 'uploader_id': 'UCiu-3thuViMebBjw_5nWYrA',
5854 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
5855 'description': 'test description',
5856 'title': 'cole-dlp-test-acc - 再生リスト',
5857 'uploader_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
5858 'uploader': 'cole-dlp-test-acc',
5859 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
5860 'channel': 'cole-dlp-test-acc',
5862 'playlist_mincount': 1,
5863 'params': {'extractor_args': {'youtube': {'lang': ['ja']}
}},
5864 'expected_warnings': ['Preferring "ja"'],
5866 # XXX: this should really check flat playlist entries, but the test suite doesn't support that
5867 'note': 'preferred lang set with playlist with translated video titles',
5868 'url': 'https://www.youtube.com/playlist?list=PLt5yu3-wZAlQAaPZ5Z-rJoTdbT-45Q7c0',
5870 'id': 'PLt5yu3-wZAlQAaPZ5Z-rJoTdbT-45Q7c0',
5873 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
5874 'uploader': 'cole-dlp-test-acc',
5875 'uploader_id': 'UCiu-3thuViMebBjw_5nWYrA',
5876 'channel': 'cole-dlp-test-acc',
5877 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
5878 'description': 'test',
5879 'uploader_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
5880 'title': 'dlp test playlist',
5881 'availability': 'public',
5883 'playlist_mincount': 1,
5884 'params': {'extractor_args': {'youtube': {'lang': ['ja']}
}},
5885 'expected_warnings': ['Preferring "ja"'],
5887 # shorts audio pivot for 2GtVksBMYFM.
5888 'url': 'https://www.youtube.com/feed/sfv_audio_pivot?bp=8gUrCikSJwoLMkd0VmtzQk1ZRk0SCzJHdFZrc0JNWUZNGgsyR3RWa3NCTVlGTQ==',
5890 'id': 'sfv_audio_pivot',
5891 'title': 'sfv_audio_pivot',
5894 'playlist_mincount': 50,
5897 # Channel with a real live tab (not to be mistaken with streams tab)
5898 # Do not treat like it should redirect to live stream
5899 'url': 'https://www.youtube.com/channel/UCEH7P7kyJIkS_gJf93VYbmg/live',
5901 'id': 'UCEH7P7kyJIkS_gJf93VYbmg',
5902 'title': 'UCEH7P7kyJIkS_gJf93VYbmg - Live',
5905 'playlist_mincount': 20,
5907 # Tab name is not the same as tab id
5908 'url': 'https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg/letsplay',
5910 'id': 'UCQvWX73GQygcwXOTSf_VDVg',
5911 'title': 'UCQvWX73GQygcwXOTSf_VDVg - Let\'s play',
5914 'playlist_mincount': 8,
5916 # Home tab id is literally home. Not to get mistaken with featured
5917 'url': 'https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg/home',
5919 'id': 'UCQvWX73GQygcwXOTSf_VDVg',
5920 'title': 'UCQvWX73GQygcwXOTSf_VDVg - Home',
5923 'playlist_mincount': 8,
5925 # Should get three playlists for videos, shorts and streams tabs
5926 'url': 'https://www.youtube.com/channel/UCK9V2B22uJYu3N7eR_BT9QA',
5928 'id': 'UCK9V2B22uJYu3N7eR_BT9QA',
5929 'title': 'Polka Ch. 尾丸ポルカ',
5930 'channel_follower_count': int,
5931 'channel_id': 'UCK9V2B22uJYu3N7eR_BT9QA',
5932 'channel_url': 'https://www.youtube.com/channel/UCK9V2B22uJYu3N7eR_BT9QA',
5933 'uploader': 'Polka Ch. 尾丸ポルカ',
5934 'description': 'md5:3b8df1ac5af337aa206e37ee3d181ec9',
5935 'channel': 'Polka Ch. 尾丸ポルカ',
5937 'uploader_url': 'https://www.youtube.com/channel/UCK9V2B22uJYu3N7eR_BT9QA',
5938 'uploader_id': 'UCK9V2B22uJYu3N7eR_BT9QA',
5940 'playlist_count': 3,
5942 # Shorts tab with channel with handle
5943 'url': 'https://www.youtube.com/@NotJustBikes/shorts',
5945 'id': 'UC0intLFzLaudFG-xAvUEO-A',
5946 'title': 'Not Just Bikes - Shorts',
5948 'uploader': 'Not Just Bikes',
5949 'channel_url': 'https://www.youtube.com/channel/UC0intLFzLaudFG-xAvUEO-A',
5950 'description': 'md5:7513148b1f02b924783157d84c4ea555',
5951 'channel_follower_count': int,
5952 'uploader_id': 'UC0intLFzLaudFG-xAvUEO-A',
5953 'channel_id': 'UC0intLFzLaudFG-xAvUEO-A',
5954 'uploader_url': 'https://www.youtube.com/channel/UC0intLFzLaudFG-xAvUEO-A',
5955 'channel': 'Not Just Bikes',
5957 'playlist_mincount': 10,
5960 'url': 'https://www.youtube.com/channel/UC3eYAvjCVwNHgkaGbXX3sig/streams',
5962 'id': 'UC3eYAvjCVwNHgkaGbXX3sig',
5963 'title': '中村悠一 - Live',
5965 'channel_id': 'UC3eYAvjCVwNHgkaGbXX3sig',
5966 'channel_url': 'https://www.youtube.com/channel/UC3eYAvjCVwNHgkaGbXX3sig',
5967 'uploader_id': 'UC3eYAvjCVwNHgkaGbXX3sig',
5969 'uploader_url': 'https://www.youtube.com/channel/UC3eYAvjCVwNHgkaGbXX3sig',
5970 'channel_follower_count': int,
5972 'description': 'md5:e744f6c93dafa7a03c0c6deecb157300',
5974 'playlist_mincount': 60,
5976 # Channel with no uploads and hence no videos, streams, shorts tabs or uploads playlist. This should fail.
5977 # See test_youtube_lists
5978 'url': 'https://www.youtube.com/channel/UC2yXPzFejc422buOIzn_0CA',
5979 'only_matching': True,
5981 # No uploads and no UCID given. Should fail with no uploads error
5982 # See test_youtube_lists
5983 'url': 'https://www.youtube.com/news',
5984 'only_matching': True
5986 # No videos tab but has a shorts tab
5987 'url': 'https://www.youtube.com/c/TKFShorts',
5989 'id': 'UCgJ5_1F6yJhYLnyMszUdmUg',
5990 'title': 'Shorts Break - Shorts',
5992 'channel_id': 'UCgJ5_1F6yJhYLnyMszUdmUg',
5993 'channel': 'Shorts Break',
5994 'description': 'md5:a6c234cf3d50d878ef8721e34457cd11',
5995 'uploader': 'Shorts Break',
5996 'channel_follower_count': int,
5997 'uploader_id': 'UCgJ5_1F6yJhYLnyMszUdmUg',
5998 'uploader_url': 'https://www.youtube.com/channel/UCgJ5_1F6yJhYLnyMszUdmUg',
5999 'channel_url': 'https://www.youtube.com/channel/UCgJ5_1F6yJhYLnyMszUdmUg',
6001 'playlist_mincount': 30,
6003 # Trending Now Tab. tab id is empty
6004 'url': 'https://www.youtube.com/feed/trending',
6007 'title': 'trending - Now',
6010 'playlist_mincount': 30,
6012 # Trending Gaming Tab. tab id is empty
6013 'url': 'https://www.youtube.com/feed/trending?bp=4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D',
6016 'title': 'trending - Gaming',
6019 'playlist_mincount': 30,
6021 # Shorts url result in shorts tab
6022 'url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA/shorts',
6024 'id': 'UCiu-3thuViMebBjw_5nWYrA',
6025 'title': 'cole-dlp-test-acc - Shorts',
6026 'uploader_id': 'UCiu-3thuViMebBjw_5nWYrA',
6027 'channel': 'cole-dlp-test-acc',
6028 'description': 'test description',
6029 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
6030 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
6032 'uploader': 'cole-dlp-test-acc',
6033 'uploader_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
6039 'ie_key': 'Youtube',
6040 'url': 'https://www.youtube.com/shorts/sSM9J5YH_60',
6041 'id': 'sSM9J5YH_60',
6042 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
6043 'title': 'SHORT short',
6044 'channel': 'cole-dlp-test-acc',
6045 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
6050 'params': {'extract_flat': True}
,
6052 # Live video status should be extracted
6053 'url': 'https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg/live',
6055 'id': 'UCQvWX73GQygcwXOTSf_VDVg',
6056 'title': 'UCQvWX73GQygcwXOTSf_VDVg - Live', # TODO, should be Minecraft - Live or Minecraft - Topic - Live
6062 'ie_key': 'Youtube',
6063 'url': 'startswith:https://www.youtube.com/watch?v=',
6066 'live_status': 'is_live',
6069 'concurrent_view_count': int,
6073 'params': {'extract_flat': True, 'playlist_items': '1'}
,
6074 'playlist_mincount': 1
6076 # Channel renderer metadata. Contains number of videos on the channel
6077 'url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA/channels',
6079 'id': 'UCiu-3thuViMebBjw_5nWYrA',
6080 'title': 'cole-dlp-test-acc - Channels',
6081 'uploader_id': 'UCiu-3thuViMebBjw_5nWYrA',
6082 'channel': 'cole-dlp-test-acc',
6083 'description': 'test description',
6084 'channel_id': 'UCiu-3thuViMebBjw_5nWYrA',
6085 'channel_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
6087 'uploader': 'cole-dlp-test-acc',
6088 'uploader_url': 'https://www.youtube.com/channel/UCiu-3thuViMebBjw_5nWYrA',
6094 'ie_key': 'YoutubeTab',
6095 'url': 'https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw',
6096 'id': 'UC-lHJZR3Gqxm24_Vd_AJ5Yw',
6097 'channel_id': 'UC-lHJZR3Gqxm24_Vd_AJ5Yw',
6098 'title': 'PewDiePie',
6099 'channel': 'PewDiePie',
6100 'channel_url': 'https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw',
6102 'channel_follower_count': int,
6103 'playlist_count': int
6106 'params': {'extract_flat': True}
,
6108 'url': 'https://www.youtube.com/@3blue1brown/about',
6110 'id': 'UCYO_jab_esuFRV4b17AJtAw',
6111 'tags': ['Mathematics'],
6112 'title': '3Blue1Brown - About',
6113 'uploader_url': 'https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw',
6114 'channel_follower_count': int,
6115 'channel_id': 'UCYO_jab_esuFRV4b17AJtAw',
6116 'uploader_id': 'UCYO_jab_esuFRV4b17AJtAw',
6117 'channel': '3Blue1Brown',
6118 'uploader': '3Blue1Brown',
6120 'channel_url': 'https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw',
6121 'description': 'md5:e1384e8a133307dd10edee76e875d62f',
6123 'playlist_count': 0,
6127 def suitable(cls
, url
):
6128 return False if YoutubeIE
.suitable(url
) else super().suitable(url
)
6130 _URL_RE
= re
.compile(rf
'(?P<pre>{_VALID_URL})(?(not_channel)|(?P<tab>/[^?#/]+))?(?P<post>.*)$')
6132 def _get_url_mobj(self
, url
):
6133 mobj
= self
._URL
_RE
.match(url
).groupdict()
6134 mobj
.update((k
, '') for k
, v
in mobj
.items() if v
is None)
6137 def _extract_tab_id_and_name(self
, tab
, base_url
='https://www.youtube.com'):
6138 tab_name
= (tab
.get('title') or '').lower()
6139 tab_url
= urljoin(base_url
, traverse_obj(
6140 tab
, ('endpoint', 'commandMetadata', 'webCommandMetadata', 'url')))
6142 tab_id
= (tab_url
and self
._get
_url
_mobj
(tab_url
)['tab'][1:]
6143 or traverse_obj(tab
, 'tabIdentifier', expected_type
=str))
6146 'TAB_ID_SPONSORSHIPS': 'membership',
6147 }.get(tab_id
, tab_id
), tab_name
6149 # Fallback to tab name if we cannot get the tab id.
6150 # XXX: should we strip non-ascii letters? e.g. in case of 'let's play' tab example on special gaming channel
6151 # Note that in the case of translated tab name this may result in an empty string, which we don't want.
6153 self
.write_debug(f
'Falling back to selected tab name: {tab_name}')
6157 }.get(tab_name
, tab_name
), tab_name
6159 def _has_tab(self
, tabs
, tab_id
):
6160 return any(self
._extract
_tab
_id
_and
_name
(tab
)[0] == tab_id
for tab
in tabs
)
6162 @YoutubeTabBaseInfoExtractor.passthrough_smuggled_data
6163 def _real_extract(self
, url
, smuggled_data
):
6164 item_id
= self
._match
_id
(url
)
6165 url
= urllib
.parse
.urlunparse(
6166 urllib
.parse
.urlparse(url
)._replace
(netloc
='www.youtube.com'))
6167 compat_opts
= self
.get_param('compat_opts', [])
6169 mobj
= self
._get
_url
_mobj
(url
)
6170 pre
, tab
, post
, is_channel
= mobj
['pre'], mobj
['tab'], mobj
['post'], not mobj
['not_channel']
6171 if is_channel
and smuggled_data
.get('is_music_url'):
6172 if item_id
[:2] == 'VL': # Youtube music VL channels have an equivalent playlist
6173 return self
.url_result(
6174 f
'https://music.youtube.com/playlist?list={item_id[2:]}', YoutubeTabIE
, item_id
[2:])
6175 elif item_id
[:2] == 'MP': # Resolve albums (/[channel/browse]/MP...) to their equivalent playlist
6176 mdata
= self
._extract
_tab
_endpoint
(
6177 f
'https://music.youtube.com/channel/{item_id}', item_id
, default_client
='web_music')
6178 murl
= traverse_obj(mdata
, ('microformat', 'microformatDataRenderer', 'urlCanonical'),
6179 get_all
=False, expected_type
=str)
6181 raise ExtractorError('Failed to resolve album to playlist')
6182 return self
.url_result(murl
, YoutubeTabIE
)
6183 elif mobj
['channel_type'] == 'browse': # Youtube music /browse/ should be changed to /channel/
6184 return self
.url_result(
6185 f
'https://music.youtube.com/channel/{item_id}{tab}{post}', YoutubeTabIE
, item_id
)
6187 original_tab_id
, display_id
= tab
[1:], f
'{item_id}{tab}'
6188 if is_channel
and not tab
and 'no-youtube-channel-redirect' not in compat_opts
:
6189 url
= f
'{pre}/videos{post}'
6190 if smuggled_data
.get('is_music_url'):
6191 self
.report_warning(f
'YouTube Music is not directly supported. Redirecting to {url}')
6193 # Handle both video/playlist URLs
6195 video_id
, playlist_id
= [traverse_obj(qs
, (key
, 0)) for key
in ('v', 'list')]
6196 if not video_id
and mobj
['not_channel'].startswith('watch'):
6198 # If there is neither video or playlist ids, youtube redirects to home page, which is undesirable
6199 raise ExtractorError('A video URL was given without video ID', expected
=True)
6200 # Common mistake: https://www.youtube.com/watch?list=playlist_id
6201 self
.report_warning(f
'A video URL was given without video ID. Trying to download playlist {playlist_id}')
6202 return self
.url_result(
6203 f
'https://www.youtube.com/playlist?list={playlist_id}', YoutubeTabIE
, playlist_id
)
6205 if not self
._yes
_playlist
(playlist_id
, video_id
):
6206 return self
.url_result(
6207 f
'https://www.youtube.com/watch?v={video_id}', YoutubeIE
, video_id
)
6209 data
, ytcfg
= self
._extract
_data
(url
, display_id
)
6211 # YouTube may provide a non-standard redirect to the regional channel
6212 # See: https://github.com/yt-dlp/yt-dlp/issues/2694
6213 # https://support.google.com/youtube/answer/2976814#zippy=,conditional-redirects
6214 redirect_url
= traverse_obj(
6215 data
, ('onResponseReceivedActions', ..., 'navigateAction', 'endpoint', 'commandMetadata', 'webCommandMetadata', 'url'), get_all
=False)
6216 if redirect_url
and 'no-youtube-channel-redirect' not in compat_opts
:
6217 redirect_url
= ''.join((urljoin('https://www.youtube.com', redirect_url
), tab
, post
))
6218 self
.to_screen(f
'This playlist is likely not available in your region. Following conditional redirect to {redirect_url}')
6219 return self
.url_result(redirect_url
, YoutubeTabIE
)
6221 tabs
, extra_tabs
= self
._extract
_tab
_renderers
(data
), []
6222 if is_channel
and tabs
and 'no-youtube-channel-redirect' not in compat_opts
:
6223 selected_tab
= self
._extract
_selected
_tab
(tabs
)
6224 selected_tab_id
, selected_tab_name
= self
._extract
_tab
_id
_and
_name
(selected_tab
, url
) # NB: Name may be translated
6225 self
.write_debug(f
'Selected tab: {selected_tab_id!r} ({selected_tab_name}), Requested tab: {original_tab_id!r}')
6227 if not original_tab_id
and selected_tab_name
:
6228 self
.to_screen('Downloading all uploads of the channel. '
6229 'To download only the videos in a specific tab, pass the tab\'s URL')
6230 if self
._has
_tab
(tabs
, 'streams'):
6231 extra_tabs
.append(''.join((pre
, '/streams', post
)))
6232 if self
._has
_tab
(tabs
, 'shorts'):
6233 extra_tabs
.append(''.join((pre
, '/shorts', post
)))
6234 # XXX: Members-only tab should also be extracted
6236 if not extra_tabs
and selected_tab_id
!= 'videos':
6237 # Channel does not have streams, shorts or videos tabs
6238 if item_id
[:2] != 'UC':
6239 raise ExtractorError('This channel has no uploads', expected
=True)
6241 # Topic channels don't have /videos. Use the equivalent playlist instead
6242 pl_id
= f
'UU{item_id[2:]}'
6243 pl_url
= f
'https://www.youtube.com/playlist?list={pl_id}'
6245 data
, ytcfg
= self
._extract
_data
(pl_url
, pl_id
, ytcfg
=ytcfg
, fatal
=True, webpage_fatal
=True)
6246 except ExtractorError
:
6247 raise ExtractorError('This channel has no uploads', expected
=True)
6249 item_id
, url
= pl_id
, pl_url
6251 f
'The channel does not have a videos, shorts, or live tab. Redirecting to playlist {pl_id} instead')
6253 elif extra_tabs
and selected_tab_id
!= 'videos':
6254 # When there are shorts/live tabs but not videos tab
6255 url
, data
= f
'{pre}{post}', None
6257 elif (original_tab_id
or 'videos') != selected_tab_id
:
6258 if original_tab_id
== 'live':
6259 # Live tab should have redirected to the video
6260 # Except in the case the channel has an actual live tab
6261 # Example: https://www.youtube.com/channel/UCEH7P7kyJIkS_gJf93VYbmg/live
6262 raise UserNotLive(video_id
=item_id
)
6263 elif selected_tab_name
:
6264 raise ExtractorError(f
'This channel does not have a {original_tab_id} tab', expected
=True)
6266 # For channels such as https://www.youtube.com/channel/UCtFRv9O2AHqOZjjynzrv-xg
6267 url
= f
'{pre}{post}'
6269 # YouTube sometimes provides a button to reload playlist with unavailable videos.
6270 if 'no-youtube-unavailable-videos' not in compat_opts
:
6271 data
= self
._reload
_with
_unavailable
_videos
(display_id
, data
, ytcfg
) or data
6272 self
._extract
_and
_report
_alerts
(data
, only_once
=True)
6274 tabs
, entries
= self
._extract
_tab
_renderers
(data
), []
6276 entries
= [self
._extract
_from
_tabs
(item_id
, ytcfg
, data
, tabs
)]
6278 'extractor_key': YoutubeTabIE
.ie_key(),
6279 'extractor': YoutubeTabIE
.IE_NAME
,
6282 if self
.get_param('playlist_items') == '0':
6283 entries
.extend(self
.url_result(u
, YoutubeTabIE
) for u
in extra_tabs
)
6284 else: # Users expect to get all `video_id`s even with `--flat-playlist`. So don't return `url_result`
6285 entries
.extend(map(self
._real
_extract
, extra_tabs
))
6287 if len(entries
) == 1:
6290 metadata
= self
._extract
_metadata
_from
_tabs
(item_id
, data
)
6291 uploads_url
= 'the Uploads (UU) playlist URL'
6292 if try_get(metadata
, lambda x
: x
['channel_id'].startswith('UC')):
6293 uploads_url
= f
'https://www.youtube.com/playlist?list=UU{metadata["channel_id"][2:]}'
6295 'Downloading as multiple playlists, separated by tabs. '
6296 f
'To download as a single playlist instead, pass {uploads_url}')
6297 return self
.playlist_result(entries
, item_id
, **metadata
)
6300 playlist
= traverse_obj(
6301 data
, ('contents', 'twoColumnWatchNextResults', 'playlist', 'playlist'), expected_type
=dict)
6303 return self
._extract
_from
_playlist
(item_id
, url
, data
, playlist
, ytcfg
)
6305 video_id
= traverse_obj(
6306 data
, ('currentVideoEndpoint', 'watchEndpoint', 'videoId'), expected_type
=str) or video_id
6308 if tab
!= '/live': # live tab is expected to redirect to video
6309 self
.report_warning(f
'Unable to recognize playlist. Downloading just video {video_id}')
6310 return self
.url_result(f
'https://www.youtube.com/watch?v={video_id}', YoutubeIE
, video_id
)
6312 raise ExtractorError('Unable to recognize tab page')
6315 class YoutubePlaylistIE(InfoExtractor
):
6316 IE_DESC
= 'YouTube playlists'
6317 _VALID_URL
= r
'''(?x)(?:
6322 youtube(?:kids)?\.com|
6327 (?P<id>%(playlist_id)s)
6329 'playlist_id': YoutubeBaseInfoExtractor
._PLAYLIST
_ID
_RE
,
6330 'invidious': '|'.join(YoutubeBaseInfoExtractor
._INVIDIOUS
_SITES
),
6332 IE_NAME
= 'youtube:playlist'
6334 'note': 'issue #673',
6335 'url': 'PLBB231211A4F62143',
6337 'title': '[OLD]Team Fortress 2 (Class-based LP)',
6338 'id': 'PLBB231211A4F62143',
6339 'uploader': 'Wickman',
6340 'uploader_id': 'UCKSpbfbl5kRQpTdL7kMc-1Q',
6341 'description': 'md5:8fa6f52abb47a9552002fa3ddfc57fc2',
6343 'uploader_url': 'https://www.youtube.com/c/WickmanVT',
6344 'modified_date': r
're:\d{8}',
6345 'channel_id': 'UCKSpbfbl5kRQpTdL7kMc-1Q',
6346 'channel': 'Wickman',
6348 'channel_url': 'https://www.youtube.com/c/WickmanVT',
6349 'availability': 'public',
6351 'playlist_mincount': 29,
6353 'url': 'PLtPgu7CB4gbY9oDN3drwC3cMbJggS7dKl',
6355 'title': 'YDL_safe_search',
6356 'id': 'PLtPgu7CB4gbY9oDN3drwC3cMbJggS7dKl',
6358 'playlist_count': 2,
6359 'skip': 'This playlist is private',
6362 'url': 'https://www.youtube.com/embed/videoseries?list=PL6IaIsEjSbf96XFRuNccS_RuEXwNdsoEu',
6363 'playlist_count': 4,
6366 'id': 'PL6IaIsEjSbf96XFRuNccS_RuEXwNdsoEu',
6367 'uploader': 'milan',
6368 'uploader_id': 'UCEI1-PVPcYXjB73Hfelbmaw',
6370 'channel_url': 'https://www.youtube.com/channel/UCEI1-PVPcYXjB73Hfelbmaw',
6372 'modified_date': '20140919',
6375 'channel_id': 'UCEI1-PVPcYXjB73Hfelbmaw',
6376 'uploader_url': 'https://www.youtube.com/channel/UCEI1-PVPcYXjB73Hfelbmaw',
6377 'availability': 'public',
6379 'expected_warnings': [r
'[Uu]navailable videos? (is|are|will be) hidden'],
6381 'url': 'http://www.youtube.com/embed/_xDOZElKyNU?list=PLsyOSbh5bs16vubvKePAQ1x3PhKavfBIl',
6382 'playlist_mincount': 455,
6384 'title': '2018 Chinese New Singles (11/6 updated)',
6385 'id': 'PLsyOSbh5bs16vubvKePAQ1x3PhKavfBIl',
6387 'uploader_id': 'UC21nz3_MesPLqtDqwdvnoxA',
6388 'description': 'md5:da521864744d60a198e3a88af4db0d9d',
6391 'channel_url': 'https://www.youtube.com/c/愛低音的國王',
6393 'uploader_url': 'https://www.youtube.com/c/愛低音的國王',
6394 'channel_id': 'UC21nz3_MesPLqtDqwdvnoxA',
6395 'modified_date': r
're:\d{8}',
6396 'availability': 'public',
6398 'expected_warnings': [r
'[Uu]navailable videos (are|will be) hidden'],
6400 'url': 'TLGGrESM50VT6acwMjAyMjAxNw',
6401 'only_matching': True,
6403 # music album playlist
6404 'url': 'OLAK5uy_m4xAFdmMC5rX3Ji3g93pQe3hqLZw_9LhM',
6405 'only_matching': True,
6409 def suitable(cls
, url
):
6410 if YoutubeTabIE
.suitable(url
):
6412 from ..utils
import parse_qs
6414 if qs
.get('v', [None])[0]:
6416 return super().suitable(url
)
6418 def _real_extract(self
, url
):
6419 playlist_id
= self
._match
_id
(url
)
6420 is_music_url
= YoutubeBaseInfoExtractor
.is_music_url(url
)
6421 url
= update_url_query(
6422 'https://www.youtube.com/playlist',
6423 parse_qs(url
) or {'list': playlist_id}
)
6425 url
= smuggle_url(url
, {'is_music_url': True}
)
6426 return self
.url_result(url
, ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
)
6429 class YoutubeYtBeIE(InfoExtractor
):
6430 IE_DESC
= 'youtu.be'
6431 _VALID_URL
= r
'https?://youtu\.be/(?P<id>[0-9A-Za-z_-]{11})/*?.*?\blist=(?P<playlist_id>%(playlist_id)s)' % {'playlist_id': YoutubeBaseInfoExtractor._PLAYLIST_ID_RE}
6433 'url': 'https://youtu.be/yeWKywCrFtk?list=PL2qgrgXsNUG5ig9cat4ohreBjYLAPC0J5',
6435 'id': 'yeWKywCrFtk',
6437 'title': 'Small Scale Baler and Braiding Rugs',
6438 'uploader': 'Backus-Page House Museum',
6439 'uploader_id': 'backuspagemuseum',
6440 'uploader_url': r
're:https?://(?:www\.)?youtube\.com/user/backuspagemuseum',
6441 'upload_date': '20161008',
6442 'description': 'md5:800c0c78d5eb128500bffd4f0b4f2e8a',
6443 'categories': ['Nonprofits & Activism'],
6447 'playable_in_embed': True,
6448 'thumbnail': 'https://i.ytimg.com/vi_webp/yeWKywCrFtk/maxresdefault.webp',
6449 'channel': 'Backus-Page House Museum',
6450 'channel_id': 'UCEfMCQ9bs3tjvjy1s451zaw',
6451 'live_status': 'not_live',
6453 'channel_url': 'https://www.youtube.com/channel/UCEfMCQ9bs3tjvjy1s451zaw',
6454 'availability': 'public',
6456 'comment_count': int,
6457 'channel_follower_count': int
6461 'skip_download': True,
6464 'url': 'https://youtu.be/uWyaPkt-VOI?list=PL9D9FC436B881BA21',
6465 'only_matching': True,
6468 def _real_extract(self
, url
):
6469 mobj
= self
._match
_valid
_url
(url
)
6470 video_id
= mobj
.group('id')
6471 playlist_id
= mobj
.group('playlist_id')
6472 return self
.url_result(
6473 update_url_query('https://www.youtube.com/watch', {
6475 'list': playlist_id
,
6476 'feature': 'youtu.be',
6477 }), ie
=YoutubeTabIE
.ie_key(), video_id
=playlist_id
)
6480 class YoutubeLivestreamEmbedIE(InfoExtractor
):
6481 IE_DESC
= 'YouTube livestream embeds'
6482 _VALID_URL
= r
'https?://(?:\w+\.)?youtube\.com/embed/live_stream/?\?(?:[^#]+&)?channel=(?P<id>[^&#]+)'
6484 'url': 'https://www.youtube.com/embed/live_stream?channel=UC2_KI6RB__jGdlnK6dvFEZA',
6485 'only_matching': True,
6488 def _real_extract(self
, url
):
6489 channel_id
= self
._match
_id
(url
)
6490 return self
.url_result(
6491 f
'https://www.youtube.com/channel/{channel_id}/live',
6492 ie
=YoutubeTabIE
.ie_key(), video_id
=channel_id
)
6495 class YoutubeYtUserIE(InfoExtractor
):
6496 IE_DESC
= 'YouTube user videos; "ytuser:" prefix'
6497 IE_NAME
= 'youtube:user'
6498 _VALID_URL
= r
'ytuser:(?P<id>.+)'
6500 'url': 'ytuser:phihag',
6501 'only_matching': True,
6504 def _real_extract(self
, url
):
6505 user_id
= self
._match
_id
(url
)
6506 return self
.url_result(f
'https://www.youtube.com/user/{user_id}', YoutubeTabIE
, user_id
)
6509 class YoutubeFavouritesIE(YoutubeBaseInfoExtractor
):
6510 IE_NAME
= 'youtube:favorites'
6511 IE_DESC
= 'YouTube liked videos; ":ytfav" keyword (requires cookies)'
6512 _VALID_URL
= r
':ytfav(?:ou?rite)?s?'
6513 _LOGIN_REQUIRED
= True
6516 'only_matching': True,
6518 'url': ':ytfavorites',
6519 'only_matching': True,
6522 def _real_extract(self
, url
):
6523 return self
.url_result(
6524 'https://www.youtube.com/playlist?list=LL',
6525 ie
=YoutubeTabIE
.ie_key())
6528 class YoutubeNotificationsIE(YoutubeTabBaseInfoExtractor
):
6529 IE_NAME
= 'youtube:notif'
6530 IE_DESC
= 'YouTube notifications; ":ytnotif" keyword (requires cookies)'
6531 _VALID_URL
= r
':ytnotif(?:ication)?s?'
6532 _LOGIN_REQUIRED
= True
6535 'only_matching': True,
6537 'url': ':ytnotifications',
6538 'only_matching': True,
6541 def _extract_notification_menu(self
, response
, continuation_list
):
6542 notification_list
= traverse_obj(
6544 ('actions', 0, 'openPopupAction', 'popup', 'multiPageMenuRenderer', 'sections', 0, 'multiPageMenuNotificationSectionRenderer', 'items'),
6545 ('actions', 0, 'appendContinuationItemsAction', 'continuationItems'),
6546 expected_type
=list) or []
6547 continuation_list
[0] = None
6548 for item
in notification_list
:
6549 entry
= self
._extract
_notification
_renderer
(item
.get('notificationRenderer'))
6552 continuation
= item
.get('continuationItemRenderer')
6554 continuation_list
[0] = continuation
6556 def _extract_notification_renderer(self
, notification
):
6557 video_id
= traverse_obj(
6558 notification
, ('navigationEndpoint', 'watchEndpoint', 'videoId'), expected_type
=str)
6559 url
= f
'https://www.youtube.com/watch?v={video_id}'
6562 browse_ep
= traverse_obj(
6563 notification
, ('navigationEndpoint', 'browseEndpoint'), expected_type
=dict)
6564 channel_id
= traverse_obj(browse_ep
, 'browseId', expected_type
=str)
6565 post_id
= self
._search
_regex
(
6566 r
'/post/(.+)', traverse_obj(browse_ep
, 'canonicalBaseUrl', expected_type
=str),
6567 'post id', default
=None)
6568 if not channel_id
or not post_id
:
6570 # The direct /post url redirects to this in the browser
6571 url
= f
'https://www.youtube.com/channel/{channel_id}/community?lb={post_id}'
6573 channel
= traverse_obj(
6574 notification
, ('contextualMenu', 'menuRenderer', 'items', 1, 'menuServiceItemRenderer', 'text', 'runs', 1, 'text'),
6576 notification_title
= self
._get
_text
(notification
, 'shortMessage')
6577 if notification_title
:
6578 notification_title
= notification_title
.replace('\xad', '') # remove soft hyphens
6579 # TODO: handle recommended videos
6580 title
= self
._search
_regex
(
6581 rf
'{re.escape(channel or "")}[^:]+: (.+)', notification_title
,
6582 'video title', default
=None)
6583 timestamp
= (self
._parse
_time
_text
(self
._get
_text
(notification
, 'sentTimeText'))
6584 if self
._configuration
_arg
('approximate_date', ie_key
=YoutubeTabIE
)
6589 'ie_key': (YoutubeIE
if video_id
else YoutubeTabIE
).ie_key(),
6590 'video_id': video_id
,
6592 'channel_id': channel_id
,
6594 'thumbnails': self
._extract
_thumbnails
(notification
, 'videoThumbnail'),
6595 'timestamp': timestamp
,
6598 def _notification_menu_entries(self
, ytcfg
):
6599 continuation_list
= [None]
6601 for page
in itertools
.count(1):
6602 ctoken
= traverse_obj(
6603 continuation_list
, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type
=str)
6604 response
= self
._extract
_response
(
6605 item_id
=f
'page {page}', query
={'ctoken': ctoken}
if ctoken
else {}, ytcfg
=ytcfg
,
6606 ep
='notification/get_notification_menu', check_get_keys
='actions',
6607 headers
=self
.generate_api_headers(ytcfg
=ytcfg
, visitor_data
=self
._extract
_visitor
_data
(response
)))
6608 yield from self
._extract
_notification
_menu
(response
, continuation_list
)
6609 if not continuation_list
[0]:
6612 def _real_extract(self
, url
):
6613 display_id
= 'notifications'
6614 ytcfg
= self
._download
_ytcfg
('web', display_id
) if not self
.skip_webpage
else {}
6615 self
._report
_playlist
_authcheck
(ytcfg
)
6616 return self
.playlist_result(self
._notification
_menu
_entries
(ytcfg
), display_id
, display_id
)
6619 class YoutubeSearchIE(YoutubeTabBaseInfoExtractor
, SearchInfoExtractor
):
6620 IE_DESC
= 'YouTube search'
6621 IE_NAME
= 'youtube:search'
6622 _SEARCH_KEY
= 'ytsearch'
6623 _SEARCH_PARAMS
= 'EgIQAQ%3D%3D' # Videos only
6625 'url': 'ytsearch5:youtube-dl test video',
6626 'playlist_count': 5,
6628 'id': 'youtube-dl test video',
6629 'title': 'youtube-dl test video',
6634 class YoutubeSearchDateIE(YoutubeTabBaseInfoExtractor
, SearchInfoExtractor
):
6635 IE_NAME
= YoutubeSearchIE
.IE_NAME
+ ':date'
6636 _SEARCH_KEY
= 'ytsearchdate'
6637 IE_DESC
= 'YouTube search, newest videos first'
6638 _SEARCH_PARAMS
= 'CAISAhAB' # Videos only, sorted by date
6640 'url': 'ytsearchdate5:youtube-dl test video',
6641 'playlist_count': 5,
6643 'id': 'youtube-dl test video',
6644 'title': 'youtube-dl test video',
6649 class YoutubeSearchURLIE(YoutubeTabBaseInfoExtractor
):
6650 IE_DESC
= 'YouTube search URLs with sorting and filter support'
6651 IE_NAME
= YoutubeSearchIE
.IE_NAME
+ '_url'
6652 _VALID_URL
= r
'https?://(?:www\.)?youtube\.com/(?:results|search)\?([^#]+&)?(?:search_query|q)=(?:[^&]+)(?:[&#]|$)'
6654 'url': 'https://www.youtube.com/results?baz=bar&search_query=youtube-dl+test+video&filters=video&lclk=video',
6655 'playlist_mincount': 5,
6657 'id': 'youtube-dl test video',
6658 'title': 'youtube-dl test video',
6661 'url': 'https://www.youtube.com/results?search_query=python&sp=EgIQAg%253D%253D',
6662 'playlist_mincount': 5,
6668 'url': 'https://www.youtube.com/results?search_query=%23cats',
6669 'playlist_mincount': 1,
6673 # The test suite does not have support for nested playlists
6675 # 'url': r're:https://(www\.)?youtube\.com/hashtag/cats',
6681 'url': 'https://www.youtube.com/results?search_query=kurzgesagt&sp=EgIQAg%253D%253D',
6684 'title': 'kurzgesagt',
6689 'id': 'UCsXVk37bltHxD1rDPwtNM8Q',
6690 'url': 'https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q',
6691 'ie_key': 'YoutubeTab',
6692 'channel': 'Kurzgesagt – In a Nutshell',
6693 'description': 'md5:4ae48dfa9505ffc307dad26342d06bfc',
6694 'title': 'Kurzgesagt – In a Nutshell',
6695 'channel_id': 'UCsXVk37bltHxD1rDPwtNM8Q',
6696 'playlist_count': int, # XXX: should have a way of saying > 1
6697 'channel_url': 'https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q',
6701 'params': {'extract_flat': True, 'playlist_items': '1'}
,
6702 'playlist_mincount': 1,
6704 'url': 'https://www.youtube.com/results?q=test&sp=EgQIBBgB',
6705 'only_matching': True,
6708 def _real_extract(self
, url
):
6710 query
= (qs
.get('search_query') or qs
.get('q'))[0]
6711 return self
.playlist_result(self
._search
_results
(query
, qs
.get('sp', (None,))[0]), query
, query
)
6714 class YoutubeMusicSearchURLIE(YoutubeTabBaseInfoExtractor
):
6715 IE_DESC
= 'YouTube music search URLs with selectable sections, e.g. #songs'
6716 IE_NAME
= 'youtube:music:search_url'
6717 _VALID_URL
= r
'https?://music\.youtube\.com/search\?([^#]+&)?(?:search_query|q)=(?:[^&]+)(?:[&#]|$)'
6719 'url': 'https://music.youtube.com/search?q=royalty+free+music',
6720 'playlist_count': 16,
6722 'id': 'royalty free music',
6723 'title': 'royalty free music',
6726 'url': 'https://music.youtube.com/search?q=royalty+free+music&sp=EgWKAQIIAWoKEAoQAxAEEAkQBQ%3D%3D',
6727 'playlist_mincount': 30,
6729 'id': 'royalty free music - songs',
6730 'title': 'royalty free music - songs',
6732 'params': {'extract_flat': 'in_playlist'}
6734 'url': 'https://music.youtube.com/search?q=royalty+free+music#community+playlists',
6735 'playlist_mincount': 30,
6737 'id': 'royalty free music - community playlists',
6738 'title': 'royalty free music - community playlists',
6740 'params': {'extract_flat': 'in_playlist'}
6744 'albums': 'EgWKAQIYAWoKEAoQAxAEEAkQBQ==',
6745 'artists': 'EgWKAQIgAWoKEAoQAxAEEAkQBQ==',
6746 'community playlists': 'EgeKAQQoAEABagoQChADEAQQCRAF',
6747 'featured playlists': 'EgeKAQQoADgBagwQAxAJEAQQDhAKEAU==',
6748 'songs': 'EgWKAQIIAWoKEAoQAxAEEAkQBQ==',
6749 'videos': 'EgWKAQIQAWoKEAoQAxAEEAkQBQ==',
6752 def _real_extract(self
, url
):
6754 query
= (qs
.get('search_query') or qs
.get('q'))[0]
6755 params
= qs
.get('sp', (None,))[0]
6757 section
= next((k
for k
, v
in self
._SECTIONS
.items() if v
== params
), params
)
6759 section
= urllib
.parse
.unquote_plus((url
.split('#') + [''])[1]).lower()
6760 params
= self
._SECTIONS
.get(section
)
6763 title
= join_nonempty(query
, section
, delim
=' - ')
6764 return self
.playlist_result(self
._search
_results
(query
, params
, default_client
='web_music'), title
, title
)
6767 class YoutubeFeedsInfoExtractor(InfoExtractor
):
6769 Base class for feed extractors
6770 Subclasses must re-define the _FEED_NAME property.
6772 _LOGIN_REQUIRED
= True
6773 _FEED_NAME
= 'feeds'
6775 def _real_initialize(self
):
6776 YoutubeBaseInfoExtractor
._check
_login
_required
(self
)
6780 return f
'youtube:{self._FEED_NAME}'
6782 def _real_extract(self
, url
):
6783 return self
.url_result(
6784 f
'https://www.youtube.com/feed/{self._FEED_NAME}', ie
=YoutubeTabIE
.ie_key())
6787 class YoutubeWatchLaterIE(InfoExtractor
):
6788 IE_NAME
= 'youtube:watchlater'
6789 IE_DESC
= 'Youtube watch later list; ":ytwatchlater" keyword (requires cookies)'
6790 _VALID_URL
= r
':ytwatchlater'
6792 'url': ':ytwatchlater',
6793 'only_matching': True,
6796 def _real_extract(self
, url
):
6797 return self
.url_result(
6798 'https://www.youtube.com/playlist?list=WL', ie
=YoutubeTabIE
.ie_key())
6801 class YoutubeRecommendedIE(YoutubeFeedsInfoExtractor
):
6802 IE_DESC
= 'YouTube recommended videos; ":ytrec" keyword'
6803 _VALID_URL
= r
'https?://(?:www\.)?youtube\.com/?(?:[?#]|$)|:ytrec(?:ommended)?'
6804 _FEED_NAME
= 'recommended'
6805 _LOGIN_REQUIRED
= False
6808 'only_matching': True,
6810 'url': ':ytrecommended',
6811 'only_matching': True,
6813 'url': 'https://youtube.com',
6814 'only_matching': True,
6818 class YoutubeSubscriptionsIE(YoutubeFeedsInfoExtractor
):
6819 IE_DESC
= 'YouTube subscriptions feed; ":ytsubs" keyword (requires cookies)'
6820 _VALID_URL
= r
':ytsub(?:scription)?s?'
6821 _FEED_NAME
= 'subscriptions'
6824 'only_matching': True,
6826 'url': ':ytsubscriptions',
6827 'only_matching': True,
6831 class YoutubeHistoryIE(YoutubeFeedsInfoExtractor
):
6832 IE_DESC
= 'Youtube watch history; ":ythis" keyword (requires cookies)'
6833 _VALID_URL
= r
':ythis(?:tory)?'
6834 _FEED_NAME
= 'history'
6836 'url': ':ythistory',
6837 'only_matching': True,
6841 class YoutubeStoriesIE(InfoExtractor
):
6842 IE_DESC
= 'YouTube channel stories; "ytstories:" prefix'
6843 IE_NAME
= 'youtube:stories'
6844 _VALID_URL
= r
'ytstories:UC(?P<id>[A-Za-z0-9_-]{21}[AQgw])$'
6846 'url': 'ytstories:UCwFCb4jeqaKWnciAYM-ZVHg',
6847 'only_matching': True,
6850 def _real_extract(self
, url
):
6851 playlist_id
= f
'RLTD{self._match_id(url)}'
6852 return self
.url_result(
6853 smuggle_url(f
'https://www.youtube.com/playlist?list={playlist_id}&playnext=1', {'is_story': True}
),
6854 ie
=YoutubeTabIE
, video_id
=playlist_id
)
6857 class YoutubeShortsAudioPivotIE(InfoExtractor
):
6858 IE_DESC
= 'YouTube Shorts audio pivot (Shorts using audio of a given video)'
6859 IE_NAME
= 'youtube:shorts:pivot:audio'
6860 _VALID_URL
= r
'https?://(?:www\.)?youtube\.com/source/(?P<id>[\w-]{11})/shorts'
6862 'url': 'https://www.youtube.com/source/Lyj-MZSAA9o/shorts',
6863 'only_matching': True,
6867 def _generate_audio_pivot_params(video_id
):
6869 Generates sfv_audio_pivot browse params for this video id
6871 pb_params
= b
'\xf2\x05+\n)\x12\'\n\x0b%b\x12\x0b%b\x1a\x0b%b' % ((video_id
.encode(),) * 3)
6872 return urllib
.parse
.quote(base64
.b64encode(pb_params
).decode())
6874 def _real_extract(self
, url
):
6875 video_id
= self
._match
_id
(url
)
6876 return self
.url_result(
6877 f
'https://www.youtube.com/feed/sfv_audio_pivot?bp={self._generate_audio_pivot_params(video_id)}',
6881 class YoutubeTruncatedURLIE(InfoExtractor
):
6882 IE_NAME
= 'youtube:truncated_url'
6883 IE_DESC
= False # Do not list
6884 _VALID_URL
= r
'''(?x)
6886 (?:\w+\.)?[yY][oO][uU][tT][uU][bB][eE](?:-nocookie)?\.com/
6889 annotation_id=annotation_[^&]+|
6895 attribution_link\?a=[^&]+
6901 'url': 'https://www.youtube.com/watch?annotation_id=annotation_3951667041',
6902 'only_matching': True,
6904 'url': 'https://www.youtube.com/watch?',
6905 'only_matching': True,
6907 'url': 'https://www.youtube.com/watch?x-yt-cl=84503534',
6908 'only_matching': True,
6910 'url': 'https://www.youtube.com/watch?feature=foo',
6911 'only_matching': True,
6913 'url': 'https://www.youtube.com/watch?hl=en-GB',
6914 'only_matching': True,
6916 'url': 'https://www.youtube.com/watch?t=2372',
6917 'only_matching': True,
6920 def _real_extract(self
, url
):
6921 raise ExtractorError(
6922 'Did you forget to quote the URL? Remember that & is a meta '
6923 'character in most shells, so you want to put the URL in quotes, '
6925 '"https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc" '
6926 ' or simply youtube-dl BaW_jenozKc .',
6930 class YoutubeClipIE(YoutubeTabBaseInfoExtractor
):
6931 IE_NAME
= 'youtube:clip'
6932 _VALID_URL
= r
'https?://(?:www\.)?youtube\.com/clip/(?P<id>[^/?#]+)'
6934 # FIXME: Other metadata should be extracted from the clip, not from the base video
6935 'url': 'https://www.youtube.com/clip/UgytZKpehg-hEMBSn3F4AaABCQ',
6937 'id': 'UgytZKpehg-hEMBSn3F4AaABCQ',
6939 'section_start': 29.0,
6940 'section_end': 39.7,
6943 'availability': 'public',
6944 'categories': ['Gaming'],
6945 'channel': 'Scott The Woz',
6946 'channel_id': 'UC4rqhyiTs7XyuODcECvuiiQ',
6947 'channel_url': 'https://www.youtube.com/channel/UC4rqhyiTs7XyuODcECvuiiQ',
6948 'description': 'md5:7a4517a17ea9b4bd98996399d8bb36e7',
6950 'playable_in_embed': True,
6952 'thumbnail': 'https://i.ytimg.com/vi_webp/ScPX26pdQik/maxresdefault.webp',
6953 'title': 'Mobile Games on Console - Scott The Woz',
6954 'upload_date': '20210920',
6955 'uploader': 'Scott The Woz',
6956 'uploader_id': 'scottthewoz',
6957 'uploader_url': 'http://www.youtube.com/user/scottthewoz',
6959 'live_status': 'not_live',
6960 'channel_follower_count': int
6964 def _real_extract(self
, url
):
6965 clip_id
= self
._match
_id
(url
)
6966 _
, data
= self
._extract
_webpage
(url
, clip_id
)
6968 video_id
= traverse_obj(data
, ('currentVideoEndpoint', 'watchEndpoint', 'videoId'))
6970 raise ExtractorError('Unable to find video ID')
6972 clip_data
= traverse_obj(data
, (
6973 'engagementPanels', ..., 'engagementPanelSectionListRenderer', 'content', 'clipSectionRenderer',
6974 'contents', ..., 'clipAttributionRenderer', 'onScrubExit', 'commandExecutorCommand', 'commands', ...,
6975 'openPopupAction', 'popup', 'notificationActionRenderer', 'actionButton', 'buttonRenderer', 'command',
6976 'commandExecutorCommand', 'commands', ..., 'loopCommand'), get_all
=False)
6979 '_type': 'url_transparent',
6980 'url': f
'https://www.youtube.com/watch?v={video_id}',
6981 'ie_key': YoutubeIE
.ie_key(),
6983 'section_start': int(clip_data
['startTimeMs']) / 1000,
6984 'section_end': int(clip_data
['endTimeMs']) / 1000,
6988 class YoutubeConsentRedirectIE(YoutubeBaseInfoExtractor
):
6989 IE_NAME
= 'youtube:consent'
6990 IE_DESC
= False # Do not list
6991 _VALID_URL
= r
'https?://consent\.youtube\.com/m\?'
6993 'url': 'https://consent.youtube.com/m?continue=https%3A%2F%2Fwww.youtube.com%2Flive%2FqVv6vCqciTM%3Fcbrd%3D1&gl=NL&m=0&pc=yt&hl=en&src=1',
6995 'id': 'qVv6vCqciTM',
6998 'uploader_id': 'UCIdEIHpS0TdkqRkHL5OkLtA',
6999 'comment_count': int,
7000 'chapters': 'count:13',
7001 'upload_date': '20221223',
7002 'thumbnail': 'https://i.ytimg.com/vi/qVv6vCqciTM/maxresdefault.jpg',
7003 'channel_url': 'https://www.youtube.com/channel/UCIdEIHpS0TdkqRkHL5OkLtA',
7004 'uploader_url': 'http://www.youtube.com/channel/UCIdEIHpS0TdkqRkHL5OkLtA',
7006 'release_date': '20221223',
7007 'tags': ['Vtuber', '月ノ美兎', '名取さな', 'にじさんじ', 'クリスマス', '3D配信'],
7008 'title': '【 #インターネット女クリスマス 】3Dで歌ってはしゃぐインターネットの女たち【月ノ美兎/名取さな】',
7010 'playable_in_embed': True,
7012 'availability': 'public',
7013 'channel_follower_count': int,
7014 'channel_id': 'UCIdEIHpS0TdkqRkHL5OkLtA',
7015 'categories': ['Entertainment'],
7016 'live_status': 'was_live',
7017 'release_timestamp': 1671793345,
7018 'channel': 'さなちゃんねる',
7019 'description': 'md5:6aebf95cc4a1d731aebc01ad6cc9806d',
7020 'uploader': 'さなちゃんねる',
7022 'add_ie': ['Youtube'],
7023 'params': {'skip_download': 'Youtube'}
,
7026 def _real_extract(self
, url
):
7027 redirect_url
= url_or_none(parse_qs(url
).get('continue', [None])[-1])
7028 if not redirect_url
:
7029 raise ExtractorError('Invalid cookie consent redirect URL', expected
=True)
7030 return self
.url_result(redirect_url
)
7033 class YoutubeTruncatedIDIE(InfoExtractor
):
7034 IE_NAME
= 'youtube:truncated_id'
7035 IE_DESC
= False # Do not list
7036 _VALID_URL
= r
'https?://(?:www\.)?youtube\.com/watch\?v=(?P<id>[0-9A-Za-z_-]{1,10})$'
7039 'url': 'https://www.youtube.com/watch?v=N_708QY7Ob',
7040 'only_matching': True,
7043 def _real_extract(self
, url
):
7044 video_id
= self
._match
_id
(url
)
7045 raise ExtractorError(
7046 f
'Incomplete YouTube ID {video_id}. URL {url} looks truncated.',