mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-08-27 17:52:02 +02:00
[youtube:entrylistbase] Retry on 5xx HTTP errors (#20965)
This commit is contained in:
parent
876fed6bf3
commit
f8c55c6664
@ -16,6 +16,7 @@
|
|||||||
from ..swfinterp import SWFInterpreter
|
from ..swfinterp import SWFInterpreter
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_chr,
|
compat_chr,
|
||||||
|
compat_HTTPError,
|
||||||
compat_kwargs,
|
compat_kwargs,
|
||||||
compat_parse_qs,
|
compat_parse_qs,
|
||||||
compat_urllib_parse_unquote,
|
compat_urllib_parse_unquote,
|
||||||
@ -288,10 +289,25 @@ def _entries(self, page, playlist_id):
|
|||||||
if not mobj:
|
if not mobj:
|
||||||
break
|
break
|
||||||
|
|
||||||
more = self._download_json(
|
count = 0
|
||||||
'https://youtube.com/%s' % mobj.group('more'), playlist_id,
|
retries = 3
|
||||||
'Downloading page #%s' % page_num,
|
while count <= retries:
|
||||||
transform_source=uppercase_escape)
|
try:
|
||||||
|
# Downloading page may result in intermittent 5xx HTTP error
|
||||||
|
# that is usually worked around with a retry
|
||||||
|
more = self._download_json(
|
||||||
|
'https://youtube.com/%s' % mobj.group('more'), playlist_id,
|
||||||
|
'Downloading page #%s%s'
|
||||||
|
% (page_num, ' (retry #%d)' % count if count else ''),
|
||||||
|
transform_source=uppercase_escape)
|
||||||
|
break
|
||||||
|
except ExtractorError as e:
|
||||||
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code in (500, 503):
|
||||||
|
count += 1
|
||||||
|
if count <= retries:
|
||||||
|
continue
|
||||||
|
raise
|
||||||
|
|
||||||
content_html = more['content_html']
|
content_html = more['content_html']
|
||||||
if not content_html.strip():
|
if not content_html.strip():
|
||||||
# Some webpages show a "Load more" button but they don't
|
# Some webpages show a "Load more" button but they don't
|
||||||
|
Loading…
Reference in New Issue
Block a user