Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jurakin/parallel-downloader

Downloads file using parallel downloading (if range header is supported otherwise downloads normally).
https://github.com/jurakin/parallel-downloader

Last synced: about 2 months ago
JSON representation

Downloads file using parallel downloading (if range header is supported otherwise downloads normally).

Awesome Lists containing this project

README

        

# Parallel Downloader

Downloads file using parallel downloading (if range header is supported otherwise downloads normally).

## How it works

The library is based on adding [range headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests) to request and downloading the file in threads simultaneously.

## Instalation

- Requirements are `threading` and `requests` (built-in)
- Install from repository `python3 -m pip install git+https://github.com/jurakin/parallel-downloader`

## Examples

The parallel downloader is accessible via python or a console script:

```python
parallel-downloader https://i.imgur.com/z4d4kWk.jpg cat.jpg --parts 10
```
is the same as

```python
import parallel_downloader as d

url = "https://i.imgur.com/z4d4kWk.jpg"
file = "cat.jpg"

# download url to file using 10 parts
d.ParallelDownloader(url, file, 10).wait()
```

Using `.start()` and `.wait()`:

```python
import parallel_downloader as d

url = "https://i.imgur.com/z4d4kWk.jpg"
file = "cat.jpg"

# download url to file using 10 parts
p = d.ParallelDownloader(url, file, 10)

print("before downloading")

p.start()

print("downloading")

p.wait()

print("downloaded")
```

Using `.terminate()`:

```python
import parallel_downloader as d

import time

url = "https://i.imgur.com/z4d4kWk.jpg"
file = "cat.jpg"

# download url to file using 10 parts
p = d.ParallelDownloader(url, file, 10).wait()

time.sleep(1)

p.terminate()
```

## Result

The result image is:

![cat](./cat.jpg?raw=true)

## License

This project is released under GNU General Public License v3.0

## Credits

This project is inspired by [ulozto-downloader](https://github.com/setnicka/ulozto-downloader)'s parallel downloader.