| 1 |
.. image:: https://badge.fury.io/py/dlmanager.svg |
| 2 |
:target: https://pypi.python.org/pypi/dlmanager |
| 3 |
|
| 4 |
.. image:: https://readthedocs.org/projects/dlmanager/badge/?version=latest |
| 5 |
:target: http://dlmanager.readthedocs.org/en/latest/?badge=latest |
| 6 |
:alt: Documentation Status |
| 7 |
|
| 8 |
.. image:: https://travis-ci.org/parkouss/dlmanager.svg?branch=master |
| 9 |
:target: https://travis-ci.org/parkouss/dlmanager |
| 10 |
|
| 11 |
.. image:: https://codecov.io/github/parkouss/dlmanager/coverage.svg?branch=master |
| 12 |
:target: https://codecov.io/github/parkouss/dlmanager?branch=master |
| 13 |
|
| 14 |
dlmanager |
| 15 |
========= |
| 16 |
|
| 17 |
**dlmanager** is Python 2 and 3 download manager library, with the following |
| 18 |
features: |
| 19 |
|
| 20 |
- Download files in background and in parallel |
| 21 |
- Cancel downloads |
| 22 |
- store downloads in a given directory, avoiding re-downloading files |
| 23 |
- Limit the size of this directory, removing oldest files |
| 24 |
|
| 25 |
|
| 26 |
Example |
| 27 |
------- |
| 28 |
|
| 29 |
.. code-block:: python |
| 30 |
|
| 31 |
from dlmanager import DownloadManager, PersistLimit |
| 32 |
|
| 33 |
manager = DownloadManager( |
| 34 |
"dlmanager-destir", |
| 35 |
persist_limit=PersistLimit( |
| 36 |
size_limit=1073741824, # 1 GB max |
| 37 |
file_limit=10, # force to keep 10 files even if size_limit is reached |
| 38 |
) |
| 39 |
) |
| 40 |
|
| 41 |
# Start downloads in background |
| 42 |
# Note that if files are already present, this is a no-op. |
| 43 |
manager.download(url1) |
| 44 |
manager.download(url2) |
| 45 |
|
| 46 |
# Wait for completion |
| 47 |
try: |
| 48 |
manager.wait() |
| 49 |
except: |
| 50 |
manager.cancel() |
| 51 |
raise |
| 52 |
|
| 53 |
|
| 54 |
Installation |
| 55 |
------------ |
| 56 |
|
| 57 |
Use pip: :: |
| 58 |
|
| 59 |
pip install -U dlmanager |