mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-29 06:25:34 -04:00
Make progress bars slightly smoother
This commit is contained in:
parent
44dc29d7e5
commit
208bae7b35
1 changed files with 12 additions and 13 deletions
|
@ -135,19 +135,18 @@ def tqdm_download(url: str, filepath: str, params: dict = None, desc: str = None
|
|||
raise NonStreamable(url)
|
||||
|
||||
try:
|
||||
with std_out_err_redirect_tqdm() as orig_stdout:
|
||||
with open(filepath, "wb") as file, tqdm(
|
||||
file=orig_stdout,
|
||||
total=total,
|
||||
unit="iB",
|
||||
unit_scale=True,
|
||||
unit_divisor=1024,
|
||||
desc=desc,
|
||||
dynamic_ncols=True,
|
||||
) as bar:
|
||||
for data in r.iter_content(chunk_size=1024):
|
||||
size = file.write(data)
|
||||
bar.update(size)
|
||||
with open(filepath, "wb") as file, tqdm(
|
||||
total=total,
|
||||
unit="iB",
|
||||
unit_scale=True,
|
||||
unit_divisor=1024,
|
||||
desc=desc,
|
||||
dynamic_ncols=True,
|
||||
# leave=False,
|
||||
) as bar:
|
||||
for data in r.iter_content(chunk_size=1024):
|
||||
size = file.write(data)
|
||||
bar.update(size)
|
||||
except Exception:
|
||||
try:
|
||||
os.remove(filepath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue