Skip to main content

一个功能强大的增强型下载模块,支持多线程下载、断点续传和进度显示

Project description

Enhanced Downloader

一个功能强大的Python下载模块,支持:

  • 单线程和多线程下载
  • 自动检测服务器是否支持分片
  • 断点续传
  • 进度显示
  • 返回内容或保存到文件
  • 智能下载策略

安装

pip install enhanced_downloader

使用示例

from enhanced_downloader import download_file

# 下载并保存到指定路径
download_path = download_file("https://example.com/large_file.zip", save_path="/path/to/save")
print(f"文件保存路径: {download_path}")

# 下载并返回内容
file_content = download_file("https://example.com/file.txt", return_content=True)
print(f"获取到文件内容,大小: {len(file_content)} 字节")

# 使用更多参数
download_path = download_file(
    url="https://example.com/large_file.zip",
    save_path="output.zip",
    num_threads=20,
    timeout=60,
    temp_dir="/tmp/downloads",
    min_size_for_multithread=5*1024*1024  # 5MB以上使用多线程
)

高级用法

from enhanced_downloader import EnhancedDownloader

# 创建下载器实例
downloader = EnhancedDownloader()

# 使用实例方法
downloader.download(
    url="https://example.com/file.zip",
    save_path="downloads/file.zip",
    num_threads=30,
    force_single_thread=False
)

参数说明

  • url: 下载链接
  • save_path: 保存文件的路径,支持目录或完整文件路径
  • return_content: 是否返回文件内容而不是保存到本地
  • chunk_size: 下载块大小
  • timeout: 请求超时时间(秒)
  • num_threads: 多线程下载时的线程数
  • temp_dir: 临时文件目录
  • force_single_thread: 是否强制使用单线程下载
  • min_size_for_multithread: 启用多线程下载的最小文件大小

版本更新

  • 0.1.0: 初始版本
  • 0.1.1: 优化多线程下载性能
  • 0.1.2: 添加速度限制功能
  • 0.1.3: 未指定目录时自动保存到最大可用磁盘,修复路径判断逻辑

许可证

MIT License - 详见 LICENSE 文件

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

enhanced_downloader-0.1.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

enhanced_downloader-0.1.3-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file enhanced_downloader-0.1.3.tar.gz.

File metadata

  • Download URL: enhanced_downloader-0.1.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for enhanced_downloader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 68bbd5865412a91cfd845ae7113c0cbb078675cf6a4dbaf5b702d8df291ed972
MD5 38b6644c7c95d5bbcf4da4cc92c73e2e
BLAKE2b-256 03190e0425b55abe99a25cf7b1481a19b296e2dfd51b52c08fba984ce71224e4

See more details on using hashes here.

File details

Details for the file enhanced_downloader-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for enhanced_downloader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bd5ed4e76713cc12ac1ee28dc82a498363f97251847b0e090a36fc9b8dd0e353
MD5 97b43a926b26e7e078691d926b0facc3
BLAKE2b-256 5f6c0c9e4cefbfdf853d49758ef2635854548878e89c2d4a8e5d85f0aa9c1849

See more details on using hashes here.

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