DLB - 多线程下载工具库
基于 Python 开发的高效多线程下载工具,支持进度显示和智能配置
功能特性
- 多线程加速:支持自定义并发线程数 (
-j参数) - 可视化进度:使用 Rich 库实现美观的终端进度条,显示下载速度和剩余时间
- 智能配置:自动保存用户设置到
~/.dlb.json - 多语言支持:自动适配中英文界面
- Cookie 支持:可通过配置或命令行设置请求 Cookies
- 断点续传:支持自动续传未完成的下载任务
- 下载重试:支持失败自动重试,采用指数退避策略
- 日志记录:自动记录下载日志到
~/.dlb/logs/dlb.log
安装方式
通过 PyPI 安装 (推荐)
pip install beiane-dlb
从 Gitee 仓库安装
pip install git+https://gitee.com/byusistudio/dlb.git
开发版安装
git clone https://gitee.com/byusistudio/dlb.git
cd dlb
pip install -e .
快速开始
基础下载
dlb https://example.com/file1.zip https://example.com/file2.zip
高级用法
# 指定输出目录和线程数
dlb -o ./downloads -j 8 https://example.com/large-file.iso
# 设置 Cookie 并保存配置
dlb --cookie "session=abc123" --set-config -j 4
# 批量下载视频文件
dlb $(seq -f "https://video-site.com/video_%03d.mp4" 1 100)
配置文件
默认配置文件路径:~/.dlb.json
{
"language": "auto",
"max_workers": 5,
"max_downloads": 10,
"cookies": "",
"placeholder": false,
"timeout": 30,
"chunk_size": 1048576,
"retries": 3
}
配置项说明:
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| language | string | auto | 界面语言,可选值:auto、zh_CN、en_US |
| max_workers | int | 5 | 最大并发线程数 |
| max_downloads | int | 10 | 最大同时下载数量 |
| cookies | string | "" | HTTP 请求 Cookie |
| placeholder | bool | false | 是否创建占位文件 |
| timeout | int | 30 | 连接超时时间(秒) |
| chunk_size | int | 1048576 | 下载块大小(字节),默认 1MB |
| retries | int | 3 | 失败重试次数 |
构建与发布
环境准备
创建 .env 文件并配置 PyPI token:
PYPI_TOKEN=your_pypi_token_here
Linux / macOS
bash build.sh
Windows
build.bat
项目结构
dlb/
├── dlb/
│ ├── __init__.py # 包初始化
│ ├── cli.py # 命令行接口
│ ├── config.py # 配置管理
│ ├── core.py # 核心下载逻辑
│ ├── i18n.py # 国际化支持
│ ├── logger.py # 日志记录
│ └── locales/ # 翻译文件
│ ├── en_US.json
│ └── zh_CN.json
├── build.sh # Linux/macOS 构建脚本
├── build.bat # Windows 构建脚本
├── .env.example # 环境变量模板
├── pyproject.toml # 项目配置
├── setup.py # 安装配置
└── README.md # 项目说明
版权与协议
Copyright © 2025 北啊呢
本项目采用 MIT 开源协议,您可以自由地:
- 使用、复制、修改本软件
- 进行再分发和商业使用
项目地址
访问 Gitee 仓库获取最新代码:
gitee.com/byusistudio/dlb
贡献指南
欢迎通过以下方式参与贡献:
- 提交 Issue 报告问题
- Fork 仓库后发起 Pull Request
- 完善多语言翻译文件
- 编写测试用例
技术支持
如遇使用问题,请优先查阅:
dlb --help
或提交 Issue 至项目仓库,我们将尽快为您解答。
Metadata
Release files for beiane-dlb 0.3.0
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 |
|---|---|---|---|---|
| beiane_dlb-0.3.0.tar.gz | 9.2 kB | Without provenance | Details for beiane_dlb-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| beiane_dlb-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for beiane_dlb-0.3.0-py3-none-any.whl |
Total release size: 19.4 kB
Release files / beiane_dlb-0.3.0.tar.gz
| Download URL | beiane_dlb-0.3.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51ac3d19553f5a3cb2b40a2000f2090145e47a0378207f5d816f1597a7ccb455
|
|
BLAKE2b-256 checksum How to use checksums |
7841c6de70931b7989265489e17fd0e653990e7b0ff8159d20c6a8fc9faeec37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / beiane_dlb-0.3.0-py3-none-any.whl
| Download URL | beiane_dlb-0.3.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e52a2553e387c5d16971a18d670318ad81d1be699524344aa835c8dc49002977
|
|
BLAKE2b-256 checksum How to use checksums |
81900b076fbde9c19aed655045ffcbac80bff1c38805905fdf5a6d7d513f579b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for beiane-dlb 0.3.0
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.