diff --git a/brozzler/ydl.py b/brozzler/ydl.py index 09593f1..68fe133 100644 --- a/brozzler/ydl.py +++ b/brozzler/ydl.py @@ -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