improved progressbar

This commit is contained in:
Hellow 2023-04-04 17:54:05 +02:00
parent 5f735c25de
commit afc3c859b0

View File

@ -70,19 +70,19 @@ class Target(DatabaseObject):
self.create_path()
chunk_size = 1024
total_size = int(r.headers.get('content-length'))
print(total_size)
initial_pos = 0
with open(self.file_path,'wb') as f:
with open(self.file_path, 'wb') as f:
try:
"""
https://en.wikipedia.org/wiki/Kilobyte
> The internationally recommended unit symbol for the kilobyte is kB.
"""
for chunk in tqdm(r.iter_content(chunk_size=chunk_size), unit_scale=True, unit="B", total=total_size):
with tqdm(total=total_size, unit='B', unit_scale=True, unit_divisor=1024) as t:
for chunk in r.iter_content(chunk_size=chunk_size):
size = f.write(chunk)
t.update(size)
except requests.exceptions.Timeout:
shared.DOWNLOAD_LOGGER.error("Stream timed out.")