Skip to content

Commit

Permalink
Merge pull request #308 from galgeek/retry_only_proxied
Browse files Browse the repository at this point in the history
retry only proxied urls
  • Loading branch information
galgeek authored Dec 12, 2024
2 parents 73a9c9f + 5f82b88 commit 135f623
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions brozzler/ydl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@

thread_local = threading.local()


YTDLP_PROXY = ""
MAX_YTDLP_ATTEMPTS = 4
PROXY_ATTEMPTS = 4
YTDLP_WAIT = 10


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 135f623

Please sign in to comment.