From 4e6767b5f2e2523ebd3dd1240584ead53e8c8905 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 18 Jun 2021 20:32:52 +0530 Subject: [PATCH] [youtube] Temporary fix for age-gate Related: https://stackoverflow.com/a/67629882 https://github.com/yt-dlp/yt-dlp/issues/319 https://github.com/ytdl-org/youtube-dl/issues/29333 https://github.com/ytdl-org/youtube-dl/issues/29086 --- yt_dlp/extractor/youtube.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 14514940d..375fc1909 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -1876,6 +1876,16 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'comment_count': len(comments), } + @staticmethod + def _get_video_info_params(video_id): + return { + 'video_id': video_id, + 'eurl': 'https://youtube.googleapis.com/v/' + video_id, + 'html5': '1', + 'c': 'TVHTML5', + 'cver': '6.20180913', + } + def _real_extract(self, url): url, smuggled_data = unsmuggle_url(url, {}) video_id = self._match_id(url) @@ -1908,13 +1918,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor): base_url + 'get_video_info', video_id, 'Fetching youtube music info webpage', 'unable to download youtube music info webpage', query={ - 'video_id': video_id, - 'eurl': 'https://youtube.googleapis.com/v/' + video_id, + **self._get_video_info_params(video_id), 'el': 'detailpage', 'c': 'WEB_REMIX', 'cver': '0.1', 'cplayer': 'UNIPLAYER', - 'html5': '1', }, fatal=False)), lambda x: x['player_response'][0], compat_str) or '{}', video_id) @@ -1936,12 +1944,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor): pr = self._parse_json(try_get(compat_parse_qs( self._download_webpage( base_url + 'get_video_info', video_id, - 'Refetching age-gated info webpage', - 'unable to download video info webpage', query={ - 'video_id': video_id, - 'eurl': 'https://youtube.googleapis.com/v/' + video_id, - 'html5': '1', - }, fatal=False)), + 'Refetching age-gated info webpage', 'unable to download video info webpage', + query=self._get_video_info_params(video_id), fatal=False)), lambda x: x['player_response'][0], compat_str) or '{}', video_id) if pr: