diff --git a/yt_dlp/extractor/youtube/_base.py b/yt_dlp/extractor/youtube/_base.py index 17e942465d..133b069f22 100644 --- a/yt_dlp/extractor/youtube/_base.py +++ b/yt_dlp/extractor/youtube/_base.py @@ -380,10 +380,13 @@ def short_client_name(client_name): return join_nonempty(main[:4], ''.join(x[0] for x in parts)).upper() -def build_innertube_clients(): - THIRD_PARTY = { +def _fix_embedded_ytcfg(ytcfg): + ytcfg['INNERTUBE_CONTEXT'].setdefault('thirdParty', {}).update({ 'embedUrl': 'https://www.youtube.com/', # Can be any valid URL - } + }) + + +def build_innertube_clients(): BASE_CLIENTS = ('ios', 'web', 'tv', 'mweb', 'android') priority = qualities(BASE_CLIENTS[::-1]) @@ -405,7 +408,7 @@ def build_innertube_clients(): ytcfg['priority'] = 10 * priority(base_client) if variant == 'embedded': - ytcfg['INNERTUBE_CONTEXT']['thirdParty'] = THIRD_PARTY + _fix_embedded_ytcfg(ytcfg) ytcfg['priority'] -= 2 elif variant: ytcfg['priority'] -= 3 @@ -991,6 +994,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor): ytcfg = self.extract_ytcfg(video_id, webpage) or {} + # See https://github.com/yt-dlp/yt-dlp/issues/14826 + if _split_innertube_client(client)[2] == 'embedded': + _fix_embedded_ytcfg(ytcfg) + # Workaround for https://github.com/yt-dlp/yt-dlp/issues/12563 # But it's not effective when logged-in if client == 'tv' and not self.is_authenticated: