Metadata-Version: 2.4
Name: idm-downloader
Version: 0.1.5
Summary: A Python library for downloading files using Internet Download Manager (IDM) with progress monitoring.
Author-email: Your Name <your.email@example.com>
License: MIT License
        
        Copyright (c) 2026 Your Name
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/yourusername/idm-downloader
Project-URL: Documentation, https://github.com/yourusername/idm-downloader#readme
Project-URL: Repository, https://github.com/yourusername/idm-downloader
Project-URL: Issues, https://github.com/yourusername/idm-downloader/issues
Keywords: idm,download,internet-download-manager,downloader
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: File Transfer Protocol (FTP)
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Dynamic: license-file

# IDM Downloader

一个用于调用 Internet Download Manager (IDM) 进行文件下载的 Python 库，支持进度监控和回调。

## 特性

- ✅ 简单易用的 API
- ✅ 实时下载进度监控
- ✅ 支持进度回调
- ✅ 支持暂停/恢复/停止下载
- ✅ 自动检测 IDM 安装路径
- ✅ 解析 IDM 日志获取详细进度信息
- ⚠️ 仅支持 Windows 系统

## 安装

```bash
pip install idm-downloader
```

## 快速开始

### 最简单的使用方式

```python
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 类（支持回调）

```python
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 '失败'}")
```

### 控制下载

```python
downloader = IDMDownloader()

# 开始下载
result = downloader.download(url, save_path)

# 暂停下载
downloader.pause()

# 恢复下载
downloader.resume()

# 停止下载
downloader.stop()
```

### 命令行使用

```bash
idm-download https://example.com/file.mp4 C:\Downloads
```

## 进度信息字典

`progress_callback` 函数接收的 `progress_info` 字典包含以下信息：

```python
{
    "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) 已安装

## 本地安装和开发

```bash
# 克隆代码
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！
