1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-16 14:34:31 +01:00

[youtube] Improve age-gated videos extraction in 429 error conditions (refs #24283)

This commit is contained in:
Sergey M․ 2020-03-08 05:37:47 +07:00
parent f93abcf1da
commit d332ec725d
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -1726,6 +1726,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
embed_webpage = None embed_webpage = None
if re.search(r'player-age-gate-content">', video_webpage) is not None: if re.search(r'player-age-gate-content">', video_webpage) is not None:
age_gate = True age_gate = True
video_info = None
# We simulate the access to the video from www.youtube.com/v/{video_id} # We simulate the access to the video from www.youtube.com/v/{video_id}
# this can be viewed without login into Youtube # this can be viewed without login into Youtube
url = proto + '://www.youtube.com/embed/%s' % video_id url = proto + '://www.youtube.com/embed/%s' % video_id
@ -1737,10 +1738,14 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
r'"sts"\s*:\s*(\d+)', embed_webpage, 'sts', default=''), r'"sts"\s*:\s*(\d+)', embed_webpage, 'sts', default=''),
}) })
video_info_url = proto + '://www.youtube.com/get_video_info?' + data video_info_url = proto + '://www.youtube.com/get_video_info?' + data
try:
video_info_webpage = self._download_webpage( video_info_webpage = self._download_webpage(
video_info_url, video_id, video_info_url, video_id,
note='Refetching age-gated info webpage', note='Refetching age-gated info webpage',
errnote='unable to download video info webpage') errnote='unable to download video info webpage')
except ExtractorError:
video_info_webpage = None
if video_info_webpage:
video_info = compat_parse_qs(video_info_webpage) video_info = compat_parse_qs(video_info_webpage)
pl_response = video_info.get('player_response', [None])[0] pl_response = video_info.get('player_response', [None])[0]
player_response = extract_player_response(pl_response, video_id) player_response = extract_player_response(pl_response, video_id)