Merge pull request #308 from galgeek/retry_only_proxied

retry only proxied urls
This commit is contained in:
Barbara Miller 2024-12-12 13:59:09 -08:00 committed by GitHub
commit 135f623fda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,8 +33,9 @@ import time
thread_local = threading.local()
YTDLP_PROXY = ""
MAX_YTDLP_ATTEMPTS = 4
PROXY_ATTEMPTS = 4
YTDLP_WAIT = 10
@ -325,8 +326,9 @@ def _remember_videos(page, pushed_videos=None):
def _try_youtube_dl(worker, ydl, site, page):
max_attempts = PROXY_ATTEMPTS if ydl.is_youtube_host else 1
attempt = 0
while attempt < MAX_YTDLP_ATTEMPTS:
while attempt < max_attempts:
try:
logging.info("trying yt-dlp on %s", ydl.url)
# should_download_vid = not ydl.is_youtube_host
@ -364,9 +366,9 @@ def _try_youtube_dl(worker, ydl, site, page):
# OSError('Tunnel connection failed: 464 Host Not Allowed') (caused by ProxyError...)
# and others...
attempt += 1
if attempt == MAX_YTDLP_ATTEMPTS:
if attempt == max_attempts:
logging.warning(
"Failed after %s attempts. Error: %s", MAX_YTDLP_ATTEMPTS, e
"Failed after %s attempt(s). Error: %s", max_attempts, e
)
raise brozzler.VideoExtractorError(
"yt-dlp hit error extracting info for %s" % ydl.url