Skip to main content

A high-performance download library with IDM-style multi-threaded chunked downloading, smart scheduling, and resume support

Project description

English | 简体中文

littledl

High-performance download library with IDM-style multi-threaded chunked downloading, intelligent scheduling, and resume support.

Features

Core Features

  • 🚀 Multi-threaded Chunked Downloads: Split files into chunks and download in parallel for maximum speed
  • 🎯 Direct File Writing: Write directly to final file, no temporary file merging
  • 🧠 Intelligent Scheduling: Smart chunk reassignment and adaptive concurrency
  • ⏯️ Resume Support: Continue interrupted downloads from where they left off
  • 📊 Real-time Speed Monitoring: Live speed calculation, ETA estimation, and trend analysis
  • 🔁 Reliable Fallback: Auto fallback to single-stream mode when chunked download fails

Advanced Features

  • 🔐 Multiple Authentication Methods: Basic, Bearer, Digest, API Key, OAuth2
  • 🌐 Full Proxy Support: System proxy auto-detection, PAC files, SOCKS5
  • ⏱️ Speed Limiting: Token bucket, leaky bucket, and adaptive algorithms
  • Integrity Verification: Optional post-download hash verification (verify_hash, expected_hash)
  • 🔍 Server Detection: Automatic detection of server capabilities for optimal download strategy
  • 💻 Cross-platform: Windows, macOS, Linux, FreeBSD
  • 🔒 Security: SSL verification, safe path handling

Installation

pip install littledl

Or with uv:

uv add littledl

Documentation

For full documentation, visit https://littledl.zsxiaoshu.cn/

Quick Start

Basic Usage

from littledl import download_file_sync

path = download_file_sync("https://example.com/large_file.zip")
print(f"Saved to: {path}")

Async Usage

import asyncio
from littledl import download_file

async def main():
    path = await download_file(
        "https://example.com/large_file.zip",
        save_path="./downloads",
        filename="my_file.zip",
    )
    print(f"Saved to: {path}")

asyncio.run(main())

Progress Callback

from littledl import download_file_sync

def on_progress(downloaded: int, total: int, speed: float, eta: int):
    percent = (downloaded / total) * 100
    print(f"\rProgress: {percent:.1f}% | Speed: {speed/1024/1024:.2f} MB/s | ETA: {eta}s", end="")

path = download_file_sync(
    "https://example.com/large_file.zip",
    progress_callback=on_progress,
)

Also supports callback payload as event/dict/kwargs:

from littledl import ProgressEvent

def on_event(event: ProgressEvent):
    print(event.progress, event.remaining)

def on_dict(payload: dict):
    print(payload["downloaded"], payload["speed"])

def on_kwargs(**payload):
    print(payload["eta"])

Chunk Status Callback

from littledl import ChunkEvent, download_file_sync

def on_chunk(event: ChunkEvent):
    print(
        f"chunk={event.chunk_index} status={event.status} "
        f"progress={event.progress:.1f}% speed={event.speed/1024:.1f}KB/s"
    )

path = download_file_sync(
    "https://example.com/large_file.zip",
    chunk_callback=on_chunk,
)

Advanced Usage

Authentication Configuration

from littledl import DownloadConfig, AuthConfig, AuthType

auth = AuthConfig(
    auth_type=AuthType.BEARER,
    token="your-api-token",
)

config = DownloadConfig(auth=auth)

Proxy Configuration

from littledl import DownloadConfig, ProxyConfig, ProxyMode

# System proxy (auto-detect)
proxy = ProxyConfig(mode=ProxyMode.SYSTEM)

# Custom proxy
proxy = ProxyConfig(
    mode=ProxyMode.CUSTOM,
    http_proxy="http://proxy.example.com:8080",
)

config = DownloadConfig(proxy=proxy)

Speed Limiting

from littledl import DownloadConfig, SpeedLimitConfig, SpeedLimitMode

speed_limit = SpeedLimitConfig(
    enabled=True,
    mode=SpeedLimitMode.GLOBAL,
    max_speed=1024 * 1024,  # 1 MB/s
)

config = DownloadConfig(speed_limit=speed_limit)

Multi-language Support

Set language via environment variable:

export LITTLELDL_LANGUAGE=zh  # Chinese
export LITTLELDL_LANGUAGE=en  # English

Or in code:

from littledl import set_language, get_available_languages

set_language("zh")  # Switch to Chinese
print(get_available_languages())  # {'en': 'English', 'zh': '中文'}

Configuration Options

Option Type Default Description
enable_chunking bool True Enable multi-threaded chunked download
max_chunks int 16 Maximum concurrent chunks
chunk_size int 4MB Default chunk size
buffer_size int 64KB Disk write buffer size
timeout float 300 Read/write timeout (seconds)
resume bool True Enable resume support
verify_ssl bool True Verify SSL certificates
fallback_to_single_on_failure bool True Fallback to single-stream if chunked download fails
verify_hash bool False Verify downloaded file hash
expected_hash str None Expected hash value used for verification
hash_algorithm str sha256 Hash algorithm for verification
min_file_size int None Reject files smaller than this size
max_file_size int None Reject files larger than this size

Cross-platform Support

Feature Windows macOS Linux FreeBSD
Multi-threaded download
Resume support
System proxy detection
Direct file writing

Contributing

See CONTRIBUTING.md for development setup and contribution guidelines.

Security

See SECURITY.md for security policy and vulnerability reporting.

License

Apache-2.0 License - See LICENSE file for details.

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

littledl-0.1.0.tar.gz (104.9 kB view details)

Uploaded Source

Built Distribution

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

littledl-0.1.0-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

Details for the file littledl-0.1.0.tar.gz.

File metadata

  • Download URL: littledl-0.1.0.tar.gz
  • Upload date:
  • Size: 104.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for littledl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 631b2b064525868259bc8c44e1a2a061ff0e46aaddd66eff5113d70e8e175e11
MD5 6772babdf15a3c56c0f93d861faaaf44
BLAKE2b-256 7222e981c02864add9b1227db794eafcff00b9080a747ed18ce89ee6ebf6685a

See more details on using hashes here.

Provenance

The following attestation bundles were made for littledl-0.1.0.tar.gz:

Publisher: pypi.yml on shu-shu-1/Little-Tree-Downloader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file littledl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: littledl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for littledl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9bcc73ecda6c8f3ae59e09f44e87ec680568a5b188a057169c13728ba2a39b5
MD5 4ae5ec78ad2819b0d27270645ab63534
BLAKE2b-256 159f69907edc04d78da4d51325982fa4767e77e438f8bd23e678860ac76e83ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for littledl-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on shu-shu-1/Little-Tree-Downloader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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