.. image:: https://codecov.io/gh/choldgraf/download/branch/master/graph/badge.svg :target: https://codecov.io/gh/choldgraf/download :align: left
.. image:: https://circleci.com/gh/choldgraf/download.svg?style=svg :target: https://circleci.com/gh/choldgraf/download :align: left
A no-frills tool to download files from the web. It will attempt to be smart about not downloading data that's already there, checking to make sure that there were no errors in fetching data, automatically unzipping the contents of downloaded zipfiles (if desired), and displaying a progress bar with statistics.
This draws heavily from the `MNE-python <https://martinos.org/mne>`_ ``_fetch_file`` function.
This package doesn't get a ton of developer attention, but is hopefully well-scoped enough that it should still be useful! If you'd like to help improve it, fix bugs, etc, please reach out in the issues!
Either clone this repository and install with::
python setup.py install
or, simply install with
pip install download
Download a file on the web is as easy as::
from download import download path = download(url, file_path)
a file called
file_name will be downloaded to the folder of
File types ^^^^^^^^^^
If your file is a zip file, you can add the flag::
path = download(url, file_path, kind="zip")
in this case, the file will be downloaded, and then unzipped into the folder
Supported formats are
'file', 'zip', 'tar', 'tar.gz'
Progress bar ^^^^^^^^^^^^
Whether to display a progress bar during file download.
path = download(url, file_path, progressbar=True)
True and the URL points to a single file, overwrite the old file if possible.
path = download(url, file_path, replace=False)
The URL open timeout in seconds. Defaults to 10 seconds::
path = download(url, file_path, timeout=10)
Whether to print download status to the screen.
path = download(url, file_path, verbose=True)
Why do I occasionally get a "Error file size is..." error? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Occasionally, when you try to download a file, the server from
which you are downloading will return that the download is finished,
when it is not.
download will check whether the final downloaded
file is the correct size. If not, it will throw this error. In this case,
you should try re-downloading the file.