Fixed missing segment errors

This commit is contained in:
2025-09-27 19:53:23 +02:00
parent 09eda16882
commit 8ea3b5b26c

View File

@@ -91,6 +91,11 @@ def download(
try:
stream = session.get(url, stream=True, **kwargs)
if stream.status_code == 404:
# Skip missing segments gracefully
yield dict(downloaded=f"[yellow]Segment missing (404 skipped)")
break
stream.raise_for_status()
if not segmented:
@@ -139,6 +144,11 @@ def download(
DOWNLOAD_SIZES.clear()
break
except Exception as e:
if isinstance(e, requests.HTTPError) and e.response.status_code == 404:
# Safe skip, dont bubble up
yield dict(downloaded=f"[yellow]Skipped missing segment: {url}")
break
save_path.unlink(missing_ok=True)
if DOWNLOAD_CANCELLED.is_set() or attempts == MAX_ATTEMPTS:
raise e