local var max_attempts

This commit is contained in:
Barbara Miller 2024-12-09 20:38:23 -08:00
parent 36d6a1e5ab
commit 8747bf9fd8

View File

@ -37,7 +37,6 @@ thread_local = threading.local()
YTDLP_PROXY = ""
YTDLP_TMP = "/tmp"
YTDLP_WAIT = 10
MAX_YTDLP_ATTEMPTS = 4 if YTDLP_PROXY else 1
def should_ytdlp(site, page, page_status, skip_av_seeds):
@ -327,8 +326,9 @@ def _remember_videos(page, pushed_videos=None):
def _try_youtube_dl(worker, ydl, site, page):
max_attempts = 4 if YTDLP_PROXY 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
@ -366,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 attempts. Error: %s", max_attempts, e
)
raise brozzler.VideoExtractorError(
"yt-dlp hit error extracting info for %s" % ydl.url