mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
[youtube] Improve extraction in 429 error conditions (closes #24283)
This commit is contained in:
parent
0ec9d4e565
commit
f93abcf1da
1 changed files with 17 additions and 6 deletions
|
@ -1790,11 +1790,19 @@ def extract_player_response(player_response, video_id):
|
||||||
query['el'] = el
|
query['el'] = el
|
||||||
if sts:
|
if sts:
|
||||||
query['sts'] = sts
|
query['sts'] = sts
|
||||||
video_info_webpage = self._download_webpage(
|
try:
|
||||||
'%s://www.youtube.com/get_video_info' % proto,
|
video_info_webpage = self._download_webpage(
|
||||||
video_id, note=False,
|
'%s://www.youtube.com/get_video_info' % proto,
|
||||||
errnote='unable to download video info webpage',
|
video_id, note=False,
|
||||||
fatal=False, query=query)
|
errnote='unable to download video info webpage',
|
||||||
|
query=query)
|
||||||
|
except ExtractorError as e:
|
||||||
|
# Skip further retries if we get 429 since solving
|
||||||
|
# captcha only unblocks access to website but
|
||||||
|
# not get_video_info end point
|
||||||
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 429:
|
||||||
|
break
|
||||||
|
continue
|
||||||
if not video_info_webpage:
|
if not video_info_webpage:
|
||||||
continue
|
continue
|
||||||
get_video_info = compat_parse_qs(video_info_webpage)
|
get_video_info = compat_parse_qs(video_info_webpage)
|
||||||
|
@ -1833,13 +1841,16 @@ def extract_unavailable_message():
|
||||||
if messages:
|
if messages:
|
||||||
return '\n'.join(messages)
|
return '\n'.join(messages)
|
||||||
|
|
||||||
if not video_info:
|
if not video_info and not player_response:
|
||||||
unavailable_message = extract_unavailable_message()
|
unavailable_message = extract_unavailable_message()
|
||||||
if not unavailable_message:
|
if not unavailable_message:
|
||||||
unavailable_message = 'Unable to extract video data'
|
unavailable_message = 'Unable to extract video data'
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'YouTube said: %s' % unavailable_message, expected=True, video_id=video_id)
|
'YouTube said: %s' % unavailable_message, expected=True, video_id=video_id)
|
||||||
|
|
||||||
|
if not isinstance(video_info, dict):
|
||||||
|
video_info = {}
|
||||||
|
|
||||||
video_details = try_get(
|
video_details = try_get(
|
||||||
player_response, lambda x: x['videoDetails'], dict) or {}
|
player_response, lambda x: x['videoDetails'], dict) or {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue