skip caps for non-constants

This commit is contained in:
Barbara Miller 2024-12-09 17:25:39 -08:00
parent f7938fe4bc
commit b04fe476f7

View File

@ -33,10 +33,11 @@ import time
thread_local = threading.local()
YTDLP_PROXY = ""
MAX_YTDLP_ATTEMPTS = 1
YTDLP_WAIT = 10
ytdlp_proxy = ""
ytdlp_tmp = "/tmp"
ytdlp_wait = 10
max_ytdlp_attempts = 1
def should_ytdlp(site, page, page_status, skip_av_seeds):
# called only after we've passed needs_browsing() check
@ -284,12 +285,12 @@ def _build_youtube_dl(worker, destdir, site, page):
ytdlp_url = page.redirect_url if page.redirect_url else page.url
is_youtube_host = isyoutubehost(ytdlp_url)
if is_youtube_host and YTDLP_PROXY:
MAX_YTDLP_ATTEMPTS = 4
ydl_opts["proxy"] = YTDLP_PROXY
if is_youtube_host and ytdlp_proxy:
max_ytdlp_attempts = 4
ydl_opts["proxy"] = ytdlp_proxy
# don't log proxy value secrets
ytdlp_proxy_for_logs = (
YTDLP_PROXY.split("@")[1] if "@" in YTDLP_PROXY else "@@@"
ytdlp_proxy.split("@")[1] if "@" in ytdlp_proxy else "@@@"
)
logging.info("using yt-dlp proxy ... %s", ytdlp_proxy_for_logs)
@ -327,7 +328,7 @@ def _remember_videos(page, pushed_videos=None):
def _try_youtube_dl(worker, ydl, site, page):
attempt = 0
while attempt < MAX_YTDLP_ATTEMPTS:
while attempt < max_ytdlp_attempts:
try:
logging.info("trying yt-dlp on %s", ydl.url)
# should_download_vid = not ydl.is_youtube_host
@ -365,15 +366,15 @@ 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_ytdlp_attempts:
logging.warning(
"Failed after %s attempts. Error: %s", MAX_YTDLP_ATTEMPTS, e
"Failed after %s attempts. Error: %s", max_ytdlp_attempts, e
)
raise brozzler.VideoExtractorError(
"yt-dlp hit error extracting info for %s" % ydl.url
)
else:
retry_wait = min(60, YTDLP_WAIT * (1.5 ** (attempt - 1)))
retry_wait = min(60, ytdlp_wait * (1.5 ** (attempt - 1)))
logging.info(
"Attempt %s failed. Retrying in %s seconds...",
attempt,