mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Don't stop downloading if one download fails
This commit is contained in:
parent
7184feacee
commit
936c6a9da1
@ -75,9 +75,12 @@ def _download_clips(generator: Generator[Clip, None, None]):
|
||||
if target.exists():
|
||||
click.echo(f"Already downloaded: {green(target)}")
|
||||
else:
|
||||
url = get_clip_authenticated_url(clip["slug"], "source")
|
||||
click.echo(f"Downloading: {yellow(target)}")
|
||||
download_file(url, target)
|
||||
try:
|
||||
url = get_clip_authenticated_url(clip["slug"], "source")
|
||||
click.echo(f"Downloading: {yellow(target)}")
|
||||
download_file(url, target)
|
||||
except Exception as ex:
|
||||
click.secho(ex, err=True, fg="red")
|
||||
|
||||
|
||||
def _print_all(
|
||||
|
@ -152,13 +152,16 @@ def download_file(url: str, target: Path, retries: int = RETRY_COUNT) -> Tuple[i
|
||||
return os.path.getsize(target), from_disk
|
||||
|
||||
from_disk = False
|
||||
error_message = ""
|
||||
for _ in range(retries):
|
||||
try:
|
||||
return _do_download_file(url, target), from_disk
|
||||
except httpx.RequestError:
|
||||
pass
|
||||
except httpx.HTTPStatusError as ex:
|
||||
error_message = f"Server responded with HTTP {ex.response.status_code}"
|
||||
except httpx.RequestError as ex:
|
||||
error_message = str(ex)
|
||||
|
||||
raise ConsoleError(f"Failed downloading after {retries} attempts: {url}")
|
||||
raise ConsoleError(f"Failed downloading after {retries} attempts: {error_message}")
|
||||
|
||||
|
||||
def _do_download_file(url: str, target: Path):
|
||||
|
Loading…
Reference in New Issue
Block a user