Skip to content

Commit

Permalink
[youtube] Make get_video_info processing more robust (closes #29333)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Jun 20, 2021
1 parent 03ab027 commit 47f2f2f
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,22 +1504,25 @@ def _real_extract(self, url):

playability_status = player_response.get('playabilityStatus') or {}
if playability_status.get('reason') == 'Sign in to confirm your age':
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,
# See https://github.com/ytdl-org/youtube-dl/issues/29333#issuecomment-864049544
'c': 'TVHTML5',
'cver': '6.20180913',
}, fatal=False)),
lambda x: x['player_response'][0],
compat_str) or '{}', video_id)
if pr:
player_response = pr
video_info = 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,
# See https://github.com/ytdl-org/youtube-dl/issues/29333#issuecomment-864049544
'c': 'TVHTML5',
'cver': '6.20180913',
}, fatal=False)
if video_info:
pr = self._parse_json(
try_get(
compat_parse_qs(video_info),
lambda x: x['player_response'][0], compat_str) or '{}',
video_id, fatal=False)
if pr and isinstance(pr, dict):
player_response = pr

trailer_video_id = try_get(
playability_status,
Expand Down

0 comments on commit 47f2f2f

Please sign in to comment.