mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[youtube:api] Do not use seek when reading HTTPError response
Authored-by: coletdjnz
This commit is contained in:
parent
e600a5c908
commit
87e8e8a7d0
1 changed files with 9 additions and 7 deletions
|
@ -760,13 +760,15 @@ def _extract_response(self, item_id, query, note='Downloading API JSON', headers
|
||||||
note='%s%s' % (note, ' (retry #%d)' % count if count else ''))
|
note='%s%s' % (note, ' (retry #%d)' % count if count else ''))
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, network_exceptions):
|
if isinstance(e.cause, network_exceptions):
|
||||||
if isinstance(e.cause, compat_HTTPError) and not is_html(e.cause.read(512)):
|
if isinstance(e.cause, compat_HTTPError):
|
||||||
e.cause.seek(0)
|
first_bytes = e.cause.read(512)
|
||||||
yt_error = try_get(
|
if not is_html(first_bytes):
|
||||||
self._parse_json(e.cause.read().decode(), item_id, fatal=False),
|
yt_error = try_get(
|
||||||
lambda x: x['error']['message'], compat_str)
|
self._parse_json(
|
||||||
if yt_error:
|
self._webpage_read_content(e.cause, None, item_id, prefix=first_bytes) or '{}', item_id, fatal=False),
|
||||||
self._report_alerts([('ERROR', yt_error)], fatal=False)
|
lambda x: x['error']['message'], compat_str)
|
||||||
|
if yt_error:
|
||||||
|
self._report_alerts([('ERROR', yt_error)], fatal=False)
|
||||||
# Downloading page may result in intermittent 5xx HTTP error
|
# Downloading page may result in intermittent 5xx HTTP error
|
||||||
# Sometimes a 404 is also recieved. See: https://github.com/ytdl-org/youtube-dl/issues/28289
|
# Sometimes a 404 is also recieved. See: https://github.com/ytdl-org/youtube-dl/issues/28289
|
||||||
# We also want to catch all other network exceptions since errors in later pages can be troublesome
|
# We also want to catch all other network exceptions since errors in later pages can be troublesome
|
||||||
|
|
Loading…
Reference in a new issue