A feature-rich command-line audio/video downloader
[ie/youtube] Add age-gate workaround for some embeddable videos (#11821)
bashonly09a6c687126f
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.pyindex e12f728ea3..0d3963116e 100644--- a/yt_dlp/extractor/youtube.py+++ b/yt_dlp/extractor/youtube.py@@ -1496,7 +1496,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):},# Age-gate videos. See https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-888837000{- 'note': 'Embed allowed age-gate video',+ 'note': 'Embed allowed age-gate video; works with web_embedded','url': 'https://youtube.com/watch?v=HtVdAasjOgU','info_dict': {'id': 'HtVdAasjOgU',@@ -1526,7 +1526,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor):'heatmap': 'count:100','timestamp': 1401991663,},- 'skip': 'Age-restricted; requires authentication',},{'note': 'Age-gate video with embed allowed in public site',@@ -4013,10 +4012,20 @@ 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._login_hint()}', only_once=True)+''' This code is pointless while web_creator is in _DEFAULT_AUTHED_CLIENTS# 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)