1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-11-09 11:05:13 +00:00

[ie/youtube] Add web_embedded client for age-restricted videos (#13089)

Authored by: bashonly
This commit is contained in:
bashonly
2025-05-03 15:11:40 -05:00
committed by GitHub
parent 1d0f6539c4
commit 0feec6dc13
2 changed files with 12 additions and 2 deletions

View File

@@ -3115,9 +3115,19 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
else:
prs.append(pr)
# web_embedded can work around age-gate and age-verification for some embeddable videos
if self._is_agegated(pr) and variant != 'web_embedded':
append_client(f'web_embedded.{base_client}')
# Unauthenticated users will only get web_embedded client formats if age-gated
if self._is_agegated(pr) and not self.is_authenticated:
self.to_screen(
f'{video_id}: This video is age-restricted; some formats may be missing '
f'without authentication. {self._youtube_login_hint}', only_once=True)
# EU countries require age-verification for accounts to access age-restricted videos
# If account is not age-verified, _is_agegated() will be truthy for non-embedded clients
if self.is_authenticated and self._is_agegated(pr):
embedding_is_disabled = variant == 'web_embedded' and self._is_unplayable(pr)
if self.is_authenticated and (self._is_agegated(pr) or embedding_is_disabled):
self.to_screen(
f'{video_id}: This video is age-restricted and YouTube is requiring '
'account age-verification; some formats may be missing', only_once=True)