IDM Downloader
一个用于调用 Internet Download Manager (IDM) 进行文件下载的 Python 库,支持进度监控和回调。
特性
- ✅ 简单易用的 API
- ✅ 实时下载进度监控
- ✅ 支持进度回调
- ✅ 支持暂停/恢复/停止下载
- ✅ 自动检测 IDM 安装路径
- ✅ 解析 IDM 日志获取详细进度信息
- ⚠️ 仅支持 Windows 系统
安装
pip install idm-downloader
快速开始
最简单的使用方式
from idm_downloader import simple_download
result = simple_download(
url="https://example.com/file.mp4",
save_path="C:\\Downloads"
)
print(f"下载{'成功' if result else '失败'}")
使用 IDMDownloader 类(支持回调)
from idm_downloader import IDMDownloader
def progress_callback(progress_info):
"""进度回调函数"""
print(f"进度: {progress_info['percent']}%")
print(f"已下载: {progress_info['formatted_downloaded']}")
print(f"速度: {progress_info['speed']}")
print(f"剩余时间: {progress_info['remaining_time']}")
print(f"状态: {progress_info['status']}")
print("-" * 30)
def status_callback(msg, level):
"""状态回调函数"""
print(f"[{level.upper()}] {msg}")
# 创建下载器实例
downloader = IDMDownloader(
progress_callback=progress_callback,
status_callback=status_callback,
)
# 开始下载
result = downloader.download(
url="https://example.com/file.zip",
save_path="C:\\Downloads",
filename="myfile.zip", # 可选,指定文件名
timeout=3600, # 超时时间,默认3600秒
)
print(f"下载{'成功' if result else '失败'}")
控制下载
downloader = IDMDownloader()
# 开始下载
result = downloader.download(url, save_path)
# 暂停下载
downloader.pause()
# 恢复下载
downloader.resume()
# 停止下载
downloader.stop()
命令行使用
idm-download https://example.com/file.mp4 C:\Downloads
进度信息字典
progress_callback 函数接收的 progress_info 字典包含以下信息:
{
"percent": 50.5, # 下载百分比
"downloaded": 102400, # 已下载字节数
"total": 204800, # 总字节数
"speed": "100 KB/s", # 下载速度
"status": "downloading", # 状态 (downloading/completed/error/rebuilding)
"remaining_time": "2分钟30秒",# 剩余时间
"formatted_downloaded": "100 KB", # 格式化后的已下载大小
"formatted_total": "200 KB", # 格式化后的总大小
"formatted_size": "100 KB / 200 KB" # 格式化的大小显示
}
独立使用
你也可以在其他项目中直接复制和使用 idm_downloader.py 文件,无需安装包。
前置要求
- Windows 操作系统
- Internet Download Manager (IDM) 已安装
本地安装和开发
# 克隆代码
git clone https://github.com/yourusername/idm-downloader.git
cd idm-downloader
# 安装依赖和开发工具
pip install -e .[dev]
# 本地安装(开发模式)
pip install -e .
许可证
MIT License. 详见 LICENSE 文件。
贡献
欢迎提交 Issue 和 Pull Request!
Metadata
Release files for idm-downloader 0.1.5
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 |
|---|---|---|---|---|
| idm_downloader-0.1.5.tar.gz | 12.3 kB | Without provenance | Details for idm_downloader-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| idm_downloader-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for idm_downloader-0.1.5-py3-none-any.whl |
Total release size: 23.2 kB
Release files / idm_downloader-0.1.5.tar.gz
| Download URL | idm_downloader-0.1.5.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9032f2accd04e74c5c0b231e85c40713d4480315de14c093a63f79297bebea2b
|
|
BLAKE2b-256 checksum How to use checksums |
1380a4a94000a833166473e18b2525dfbe3940f8092b564821bb10783b6b82ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / idm_downloader-0.1.5-py3-none-any.whl
| Download URL | idm_downloader-0.1.5-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0334bce9406365cf22ba0878c58992b77db7926ee2fff61140ffbd9d6009562e
|
|
BLAKE2b-256 checksum How to use checksums |
0eef021a6be70bcad8bf734b24a1b2cf95066ab88c09284ecb10681816555b3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Security for idm-downloader 0.1.5
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.