This project helps you to download media file.
Project description
Parallel Media Downloader
Helps you to download media file in parallel without async / await syntax.
Feature
This project helps you to download media files in parallel without async / await syntax.
Installation
pip install parallelmediadownloader
Usage
Minimum example:
from datetime import datetime
from parallelmediadownloader.media_download_coroutine import DownloadOrder
from parallelmediadownloader.media_file import SaveOrder
from parallelmediadownloader.parallel_media_downloader import ParallelMediaDownloader
path_directory_download = "path/directory/download"
created_date_time = datetime.now()
list_download_order = [
DownloadOrder(
"https://example.com/test01.png",
SaveOrder(
path_directory_download,
"test01.png",
created_date_time,
),
),
DownloadOrder(
"https://example.com/test02.png",
SaveOrder(
path_directory_download,
"test02.png",
created_date_time,
),
),
DownloadOrder(
"https://example.com/test03.png",
SaveOrder(
path_directory_download,
"test03.png",
created_date_time,
),
),
]
list_media_download_result = ParallelMediaDownloader.execute(list_download_order)
API
ParallelMediaDownloader.execute
class ParallelMediaDownloader:
"""API of parallel media downloading."""
@staticmethod
def execute(
list_download_order: Iterable[DownloadOrder],
*,
limit: int = 5,
media_filter: Optional[MediaFilter] = None,
allow_http_status: List[int] = None
) -> List[MediaDownloadResult]:
list_download_order: Iterable[DownloadOrder]
List of DownloadOrder
. Method will download them in parallel.
limit: int = 5
Limit number of parallel processes.
media_filter: Optional[MediaFilter] = None
Filter extends MediaFilter
to remove downloaded media file depending on file or content of media.
NotImageFilter
will be help to understand its roll:
class NotImageFilter(MediaFilter):
def _filter(self, media_file: MediaFile) -> bool:
return not str(media_file.path_file).lower().endswith((".png", ".jpg", ".jpeg", ".gif"))
allow_http_status: List[int] = None
By default, ParallelMediaDownloader.execute will check HTTP status code by Response.raise_for_status and whole process will stop.
When HTTP status applies allow_http_status, process will continue.
Then, MediaDownloadResult.media_file
will be None
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file parallelmediadownloader-0.1.0.tar.gz
.
File metadata
- Download URL: parallelmediadownloader-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
14556e824c7700cc003aae0e4be524e74fb10503dc3ed6edc96eacfb0a39ad23
|
|
MD5 |
fa0943684a1b02e51e4a4ddebd06e65f
|
|
BLAKE2b-256 |
eae3c2c7084b3e6cfe21b55ecfdea40e0d587c8e8cd28032b0229f4c36c724c1
|
File details
Details for the file parallelmediadownloader-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: parallelmediadownloader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4290bebd6930346f7663602165bd2fecb8719ded54207134a48fcc6921c3a660
|
|
MD5 |
5086fb72f165234c522b2d15b16a3ffe
|
|
BLAKE2b-256 |
241923fff3b682bf796a869bfb18b3f09ee879425778a3b2655718fd6d41133c
|