Fixed missing segment error for curl_impersonate downloader
This commit is contained in:
@@ -7,6 +7,8 @@ from pathlib import Path
|
||||
from typing import Any, Generator, MutableMapping, Optional, Union
|
||||
|
||||
from curl_cffi.requests import Session
|
||||
from curl_cffi.requests.exceptions import HTTPError
|
||||
|
||||
from rich import filesize
|
||||
|
||||
from devine.core.config import config
|
||||
@@ -80,6 +82,10 @@ def download(
|
||||
|
||||
try:
|
||||
stream = session.get(url, stream=True, **kwargs)
|
||||
if stream.status_code == 404:
|
||||
yield dict(downloaded=f"[yellow]Skipped missing segment (404): {url}")
|
||||
break
|
||||
|
||||
stream.raise_for_status()
|
||||
|
||||
try:
|
||||
@@ -118,6 +124,11 @@ def download(
|
||||
)
|
||||
break
|
||||
except Exception as e:
|
||||
if isinstance(e, requests.HTTPError) and e.response.status_code == 404:
|
||||
# Safe skip, don’t 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
|
||||
|
||||
Reference in New Issue
Block a user