Skip to main content

PyURLFetch

A Python library for implementing convenient resumable download functionality.

Extracted from MacWave's package download flow. It handles .partial files and HTTP Range requests for resuming, optional rate limiting, proxies, skipping SSL verification, and a rich progress bar.

Install

Not published on PyPI yet. Install name is PyURLFetch, import name is pyurlfetch — install straight from the repository:

# core (requests + urllib3)
pip install "git+https://github.com/Sha0huaZhang/PyURLFetch.git"

# with the rich progress bar
pip install "pyurlfetch[progress] @ git+https://github.com/Sha0huaZhang/PyURLFetch.git"

Or from a local clone:

git clone https://github.com/Sha0huaZhang/PyURLFetch.git
cd PyURLFetch
pip install .

Usage

from pyurlfetch import download_file

download_file(
    "https://example.com/archive.tar.gz",
    "archive.tar.gz",
    resume=True,
    limit_rate="1M",
)

The download is written to archive.tar.gz.partial and renamed to the target once complete, so an interrupted download can be resumed by calling the same function again with resume=True.

Failures raise an exception instead of exiting the process:

from pyurlfetch import HTTPStatusError, NetworkError, UserAborted

try:
    download_file(url, dest, resume=True)
except HTTPStatusError as error:
    print(error.status_code, error.url)
except (NetworkError, UserAborted) as error:
    print("download failed:", error)

Retrying

download_file does not prompt interactively. Control retries either with max_retries or with an on_retry(attempt, error) -> bool callback:

download_file(url, dest, max_retries=3)

download_file(url, dest, on_retry=lambda attempt, error: input("retry? [y/N] ") == "y")

Metadata

Release files for PyURLFetch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyURLFetch 0.1.0
File Size Uploaded
pyurlfetch-0.1.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyURLFetch 0.1.0
File Interpreter ABI Platform
pyurlfetch-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / pyurlfetch-0.1.0.tar.gz

Download URL pyurlfetch-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
baf13a17e677c0d952b1084e381e4b87904c9b8d928f75cf7161c2dd1d6906f2
BLAKE2b-256 checksum
How to use checksums
1e9d8c03a9ecb15e1bc73b7392d6d9984e6df2b19d07bec9c7e0cc712834d46c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / pyurlfetch-0.1.0-py3-none-any.whl

Download URL pyurlfetch-0.1.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f34f295ada879e56992d1b15bc635107ad1286a30781e14eefa137023d2d682
BLAKE2b-256 checksum
How to use checksums
4ed4769b350f3fca9862c10bb7f8724d9faa1e4d8fc9ae1300cf3c1919d3c41c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page