mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Don't print errors messages when retrying
Only die if all retries fail.
This commit is contained in:
parent
e29d42e9ef
commit
6a8da3b01b
@ -6,6 +6,7 @@ from requests.exceptions import RequestException
|
||||
|
||||
CHUNK_SIZE = 1024
|
||||
CONNECT_TIMEOUT = 5
|
||||
RETRY_COUNT = 5
|
||||
|
||||
|
||||
class DownloadFailed(Exception):
|
||||
@ -25,14 +26,14 @@ def _download(url, path):
|
||||
return size
|
||||
|
||||
|
||||
def download_file(url, path, retries=3):
|
||||
def download_file(url, path, retries=RETRY_COUNT):
|
||||
if os.path.exists(path):
|
||||
return 0
|
||||
|
||||
for _ in range(retries):
|
||||
try:
|
||||
return _download(url, path)
|
||||
except RequestException as e:
|
||||
print("Download failed: {}".format(e))
|
||||
except RequestException:
|
||||
pass
|
||||
|
||||
raise DownloadFailed(":(")
|
||||
|
Loading…
Reference in New Issue
Block a user