Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Progress Bar to download_extract_zip #314

Open
andrewbolster opened this issue May 19, 2022 · 1 comment
Open

Add Progress Bar to download_extract_zip #314

andrewbolster opened this issue May 19, 2022 · 1 comment

Comments

@andrewbolster
Copy link
Owner

No description provided.

@andrewbolster
Copy link
Owner Author

import requests, os
from tqdm import tqdm

eg_link = "https://caspersci.uk.to/matryoshka.zip"
response = requests.get(eg_link, stream=True)
with tqdm.wrapattr(open(os.devnull, "wb"), "write",
                   miniters=1, desc=eg_link.split('/')[-1],
                   total=int(response.headers.get('content-length', 0))) as fout:
    for chunk in response.iter_content(chunk_size=4096):
        fout.write(chunk)

From here https://github.com/tqdm/tqdm#hooks-and-callbacks
Originally here https://stackoverflow.com/a/53877507/252556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant