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():
|
if target.exists():
|
||||||
click.echo(f"Already downloaded: {green(target)}")
|
click.echo(f"Already downloaded: {green(target)}")
|
||||||
else:
|
else:
|
||||||
url = get_clip_authenticated_url(clip["slug"], "source")
|
try:
|
||||||
click.echo(f"Downloading: {yellow(target)}")
|
url = get_clip_authenticated_url(clip["slug"], "source")
|
||||||
download_file(url, target)
|
click.echo(f"Downloading: {yellow(target)}")
|
||||||
|
download_file(url, target)
|
||||||
|
except Exception as ex:
|
||||||
|
click.secho(ex, err=True, fg="red")
|
||||||
|
|
||||||
|
|
||||||
def _print_all(
|
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
|
return os.path.getsize(target), from_disk
|
||||||
|
|
||||||
from_disk = False
|
from_disk = False
|
||||||
|
error_message = ""
|
||||||
for _ in range(retries):
|
for _ in range(retries):
|
||||||
try:
|
try:
|
||||||
return _do_download_file(url, target), from_disk
|
return _do_download_file(url, target), from_disk
|
||||||
except httpx.RequestError:
|
except httpx.HTTPStatusError as ex:
|
||||||
pass
|
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):
|
def _do_download_file(url: str, target: Path):
|
||||||
|
Loading…
Reference in New Issue
Block a user