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() self.create_path()
chunk_size = 1024 chunk_size = 1024
total_size = int(r.headers.get('content-length')) 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: try:
""" """
https://en.wikipedia.org/wiki/Kilobyte https://en.wikipedia.org/wiki/Kilobyte
> The internationally recommended unit symbol for the kilobyte is kB. > 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:
size = f.write(chunk) for chunk in r.iter_content(chunk_size=chunk_size):
size = f.write(chunk)
t.update(size)
except requests.exceptions.Timeout: except requests.exceptions.Timeout:
shared.DOWNLOAD_LOGGER.error("Stream timed out.") shared.DOWNLOAD_LOGGER.error("Stream timed out.")