Skip to content

Bulk asynchronous downloader for multiple file hosts

Update downloader.py

Jules-WinnfieldXeca0652e9ec7
diff --git a/downloader.py b/downloader.py
index 5b1e5ecca..e4f068ff4 100644
--- a/downloader.py
+++ b/downloader.py
@@ -43,19 +43,21 @@ def download(passed_from_main):
response = requests.get(_url, stream=True)
with open(_path+str(filename), "wb") as out_file:
- for chunk in response.iter_content(chunk_size=None):
+ for chunk in response.iter_content(chunk_size=50000):
if chunk:
out_file.write(chunk)
del response
if out_file:
break
except Exception as e:
- track = traceback.format_exc()
- log(track, Fore.RED)
+ log(e, Fore.RED)
os.remove(_path + str(filename))
log("Failed attempt " + str(j) + " for " + filename + "\n", Fore.RED)
- log("Retrying "+ filename + "...", Fore.YELLOW)
- j += 1
+ if i<6:
+ log("Retrying "+ filename + "...", Fore.YELLOW)
+ j += 1
+ else:
+ break
except Exception as e:
print(e)