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: 未指定目录时自动保存到最大可用磁盘,修复路径判断逻辑
- 0.2.0: 添加允许指定代理功能,优化下载速度
- 0.2.1:优化分片时记录的僵尸键清理
- 0.2.2:新增功能,运行断电续传,支持程序重复运行下载同一个文件
许可证
MIT License - 详见 LICENSE 文件
Metadata
Release files for enhanced-downloader 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| enhanced_downloader-0.3.1.tar.gz | 28.0 kB | Without provenance | Details for enhanced_downloader-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| enhanced_downloader-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for enhanced_downloader-0.3.1-py3-none-any.whl |
Total release size: 55.8 kB
Release files / enhanced_downloader-0.3.1.tar.gz
| Download URL | enhanced_downloader-0.3.1.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50f283b6ac6cdc27625277568ba2368320b417e56d86f3bb82a39399d1ec7547
|
|
BLAKE2b-256 checksum How to use checksums |
0fb9af364e378c045b34be62d007e0e4651ba0a522f6a6b1a536015b5dac4978
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / enhanced_downloader-0.3.1-py3-none-any.whl
| Download URL | enhanced_downloader-0.3.1-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e20ed823dc1b995d19a7645b04ec642f4ff37c1a7b426675809a39af88cb90b5
|
|
BLAKE2b-256 checksum How to use checksums |
416a2542408927215617c4149a11778e505dbc984bef02f304c684f9ae2ff8be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for enhanced-downloader 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.