mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-28 14:04:49 -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)
|
raise NonStreamable(url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with std_out_err_redirect_tqdm() as orig_stdout:
|
with open(filepath, "wb") as file, tqdm(
|
||||||
with open(filepath, "wb") as file, tqdm(
|
total=total,
|
||||||
file=orig_stdout,
|
unit="iB",
|
||||||
total=total,
|
unit_scale=True,
|
||||||
unit="iB",
|
unit_divisor=1024,
|
||||||
unit_scale=True,
|
desc=desc,
|
||||||
unit_divisor=1024,
|
dynamic_ncols=True,
|
||||||
desc=desc,
|
# leave=False,
|
||||||
dynamic_ncols=True,
|
) as bar:
|
||||||
) as bar:
|
for data in r.iter_content(chunk_size=1024):
|
||||||
for data in r.iter_content(chunk_size=1024):
|
size = file.write(data)
|
||||||
size = file.write(data)
|
bar.update(size)
|
||||||
bar.update(size)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
os.remove(filepath)
|
os.remove(filepath)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue