Help us shape the future of Go! Take the 2026 Go Developer Survey

download-manager

command module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

Download Manager

面向多源任务的下载管理器:采集、排队、下载、状态追踪、聚合浏览与配置治理。

功能总览

  • 多任务类型:urllist(通用 URL 列表)、tktube / hanime(视频站)、vikacg / booksite(图片/漫画站,booksite 为 xkcd 模板验证),任务接入标准化(SiteAdapter + TaskUI 插件)
  • 多存储后端:memory / file / mongo(v2 + testcontainers 集成测试)
  • 多下载器:native(HTTP,域名限流 + 代理池 + 重试 + 断点续传)、wget、scraper、composite / multi
  • HLS 链路:m3u8 下载 + ffmpeg 合并(cmd/m3u8d 独立 CLI)
  • 对象生命周期:pending → downloading → completed / failed / cancelled,支持取消/撤销/批量/重试/重排
  • 聚合视图:跨任务搜索、筛选、排序、分页、内容分组、合集与推荐
  • 实时事件:SSE 推送对象/任务状态变更
  • 配置治理:在线更新、备份、回滚、diff、标签与备注
  • 鉴权:basic / token(DM_AUTH_ENABLED 驱动,Docker/公网默认开启),UI 登录页
  • 运行模式:full(下载 + 管理) / ui(仅管理界面,只读)

快速开始

本地构建
make build          # 构建到 build/bin/download-manager
./build/bin/download-manager --config config.yaml

UI 仅模式:

./build/bin/download-manager --ui-only
Docker Compose(推荐生产)
cp deploy/docker/config.yaml.example config.yaml   # 若存在
docker compose up -d                               # app + mongo 两容器

容器部署需设置 DM_AUTH_PASSWORD(必填,fail-closed);详见 部署文档。

配置
  • 完整配置参考:docs/config.md
  • 示例配置:仓库根 config.yaml(本地测试用)

环境变量

变量 说明
DM_AUTH_ENABLED 1 时默认开启 basic 鉴权(用户名 admin + DM_AUTH_PASSWORD)
DM_AUTH_PASSWORD / DM_AUTH_TOKEN / DM_AUTH_TOKEN_EXPIRES 鉴权凭据与过期时间(RFC3339)
DM_MONGO_URI 容器部署指向 mongo 服务(如 mongodb://mongo:27017/...)
DM_RUN_MODE / DM_UI_ONLY 运行模式(full / ui),优先级低于 CLI flag

工程约定

  • 优先使用标准库:errors / os/io / net/http / context / sync
  • 日志统一 pkg/logutil(slog + lumberjack 轮转)
  • 单实例文件锁 github.com/gofrs/flock
  • 提交遵循 Conventional Commits(type(scope): subject,pr-title 门禁)
  • CI 门禁:Test × 4 / Lint / Playwright UI E2E / SonarQube + archcheck(分层/notest/构建对齐)

文档

发布

版本由 release-please 自动管理(Conventional Commits 驱动),tag 推送触发 GoReleaser 构建 6 平台制品(darwin/linux/windows × amd64/arm64)+ checksums。

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
m3u8d command
scraper_get command
tkcheck command
ui command
Package main 独立 UI 进程:内嵌 web/static 静态资源 + 反向代理 API/文件到下载进程。
Package main 独立 UI 进程:内嵌 web/static 静态资源 + 反向代理 API/文件到下载进程。
internal
archcheck
Package archcheck 是分层与包可见性的可执行门禁:把仓库的层级关系 变成断言,而不是文档里的一句话。
Package archcheck 是分层与包可见性的可执行门禁:把仓库的层级关系 变成断言,而不是文档里的一句话。
pkg
configutil
Package configutil provides helper functions for extracting typed values from map[string]any configuration maps (commonly used in config.Task.Extra).
Package configutil provides helper functions for extracting typed values from map[string]any configuration maps (commonly used in config.Task.Extra).
TEMPLATE/ui
Package ui registers {{TYPE}} custom UI assets via the TaskUIAssets framework.
Package ui registers {{TYPE}} custom UI assets via the TaskUIAssets framework.
booksite
Package booksite 是 Book Site 站点适配任务类型。
Package booksite 是 Book Site 站点适配任务类型。
booksite/ui
Package ui registers booksite custom UI assets via the TaskUIAssets framework.
Package ui registers booksite custom UI assets via the TaskUIAssets framework.
mock
Package mock implements a configurable mock task type for testing.
Package mock implements a configurable mock task type for testing.
mock/ui
Package mockui 注册 mock 任务 UI 资产(视频查看器,模拟视频任务能力)。
Package mockui 注册 mock 任务 UI 资产(视频查看器,模拟视频任务能力)。
urllist/ui
Package ui registers url_list custom UI assets via the TaskUIAssets framework.
Package ui registers url_list custom UI assets via the TaskUIAssets framework.
testutil
assert
Package assert provides test assertion helpers, including Eventually/MustEventually for polling-based async condition checking.
Package assert provides test assertion helpers, including Eventually/MustEventually for polling-based async condition checking.
mockdl
Package mockdl provides a mock implementation of core.Downloader for testing.
Package mockdl provides a mock implementation of core.Downloader for testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL