Dead links (gofile notFound/404, 0807 404/410) fail immediately without retry
This commit is contained in:
@@ -29,6 +29,10 @@ class Zero807Error(Exception):
|
||||
"""Base error for 0807 downloads."""
|
||||
|
||||
|
||||
class Zero807NotFound(Zero807Error):
|
||||
"""The file no longer exists (HTTP 404/410). Not retryable."""
|
||||
|
||||
|
||||
def target_name(url: str) -> str:
|
||||
"""Derive the filename from the URL path (e.g. /6saCNie.zip -> 6saCNie.zip)."""
|
||||
name = Path(urlparse(url).path).name
|
||||
@@ -71,7 +75,11 @@ def download(
|
||||
proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
if proc.returncode != 0:
|
||||
tail = [line for line in proc.stderr.strip().splitlines() if line][-3:]
|
||||
raise Zero807Error(f"curl exit code {proc.returncode}: {' | '.join(tail)}")
|
||||
stderr = " | ".join(tail)
|
||||
# -f makes curl exit 22 on any HTTP error; dead links fail for good
|
||||
if "404" in stderr or "410" in stderr:
|
||||
raise Zero807NotFound(f"dead link (HTTP 404/410): {stderr}")
|
||||
raise Zero807Error(f"curl exit code {proc.returncode}: {stderr}")
|
||||
|
||||
size = tmp.stat().st_size if tmp.exists() else 0
|
||||
if size == 0:
|
||||
|
||||
Reference in New Issue
Block a user