Skip to main content

A HTTP and FTP parallel file downloader.

Project description

Latest PyPI version Azure Pipelines Build Status

A parallel file downloader using asyncio. parfive can handle downloading multiple files in parallel as well as downloading each file in a number of chunks.

Usage

parfive works by creating a downloader object, appending files to it and then running the download. parfive has a synchronous API, but uses asyncio to paralellise downloading the files.

A simple example is:

from parfive import Downloader
dl = Downloader()
dl.enqueue_file("http://data.sunpy.org/sample-data/predicted-sunspot-radio-flux.txt", path="./")
files = dl.download()

Parfive also bundles a CLI. The following example will download the two files concurrently.:

$ parfive 'http://212.183.159.230/5MB.zip' 'http://212.183.159.230/10MB.zip'
$ parfive --help
usage: parfive [-h] [--max-conn MAX_CONN] [--overwrite] [--no-file-progress]
              [--directory DIRECTORY] [--print-filenames]
              URLS [URLS ...]

Parfive, the python asyncio based downloader

positional arguments:
  URLS                  URLs of files to be downloaded.

optional arguments:
  -h, --help            show this help message and exit
  --max-conn MAX_CONN   Number of maximum connections.
  --overwrite           Overwrite if the file exists.
  --no-file-progress    Show progress bar for each file.
  --directory DIRECTORY
                        Directory to which downloaded files are saved.
  --print-filenames     Print successfully downloaded files's names to stdout.

Results

parfive.Downloader.download returns a parfive.Results object, which is a list of the filenames that have been downloaded. It also tracks any files which failed to download.

Handling Errors

If files fail to download, the urls and the response from the server are stored in the Results object returned by parfive.Downloader. These can be used to inform users about the errors. (Note, the progress bar will finish in an incomplete state if a download fails, i.e. it will show 4/5 Files Downloaded).

The Results object is a list with an extra attribute errors, this property returns a list of named tuples, where these named tuples contains the .url and the .response, which is a aiohttp.ClientResponse or a aiohttp.ClientError object.

Installation

parfive is available on PyPI, you can install it with pip:

pip install parfive

or if you want to use FTP downloads:

pip install parfive[ftp]

Requirements

  • Python 3.7 or above

  • aiohttp

  • tqdm

  • aioftp (for downloads over FTP)

Licence

MIT Licensed

Authors

parfive was written by Stuart Mumford.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parfive-1.5.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parfive-1.5.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file parfive-1.5.0.tar.gz.

File metadata

  • Download URL: parfive-1.5.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for parfive-1.5.0.tar.gz
Algorithm Hash digest
SHA256 f36128e8a93f3494ce3de8af883eeba4bd651ab228682810a46ec4b7897a84b3
MD5 0ec5dcbcda6ca3ddc0057d675ed70947
BLAKE2b-256 8ad8d1870618e45bd20d3767807e6d7b5c232cb8db602913272491f40d25fe8a

See more details on using hashes here.

File details

Details for the file parfive-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: parfive-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for parfive-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9928fee32787965ecd409415a7a22b4f9654bfe8c946d58ce4d076c381723a8c
MD5 fd3bbe2540a8cc3bf3bfadb892fe221e
BLAKE2b-256 c2acc0ab2ec4507b7240d22164e9097e38238f3bbdd1c224728f943f78be5eea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page