HUB
Sign inSign up

nick404/torrenthub

By nick404

•Updated 14 days ago

TorrentHub all-in-one: torrent discovery, qBittorrent download, Jellyfin archive.

Image
0

62

nick404/torrenthub repository overview

⁠TorrentHub All-in-One

TorrentHub 是一个自托管的种子发现、下载、归档与播放面板。这个 all-in-one 镜像把 Next.js 前端和 FastAPI 后端合并到一个容器,只暴露一个端口 8000:

  • Web UI:http://<LAN_IP>:8000/
  • API:http://<LAN_IP>:8000/api/v1
  • OpenAPI:http://<LAN_IP>:8000/docs

qBittorrent、Jellyfin、Amane 是独立服务,仍使用各自的上游镜像;本镜像只替代原来的 api + web 两个自定义容器。

⁠镜像

nick404/torrenthub:latest
docker pull nick404/torrenthub:latest

⁠功能

  • 5 个源:TPB、EZTV、YTS、Sukebei Nyaa、iJavTorrent
  • 封面卡片、中文标题优先、电影/剧集/成人筛选
  • 按大小区间与分辨率(2160p / 1080p / 720p / 480p)筛选
  • 点击下载后交给 qBittorrent
  • 完成后停止做种,删除 qBittorrent 任务但保留文件
  • 归档到 media/movies/<source>/、media/tv/<source>/、media/adult/<source>/
  • NFO、poster、fanart;TMDB / TVMaze / iTunes / Amane 元数据
  • Jellyfin 播放页;MKV 自动提示跳转 Jellyfin
  • 10 分钟定时同步、中文标题翻译、容量面板、缓存自动清理、回收站

⁠快速开始

⁠1. 准备目录与 .env
mkdir -p torrent-hub/{data,media}
cd torrent-hub

cat > .env <<'EOF'
LAN_IP=192.168.1.10
QBIT_PASSWORD=change-me
TMDB_API_KEY=
JELLYFIN_API_KEY=
EOF

LAN_IP 是宿主机的局域网地址。Web 与 API 同源,单端口访问,不再需要分别配置前端 API 地址。

⁠2. 保存 Compose
name: torrent-hub

services:
  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: torrent-hub-qbittorrent
    environment:
      PUID: "1000"
      PGID: "1000"
      TZ: Asia/Shanghai
      WEBUI_PORT: "8080"
      TORRENTING_PORT: "6881"
    volumes:
      - ./data/qbt-docker:/config
      - ./data/downloads:/downloads
    ports:
      - "8080:8080"
      - "6881:6881"
      - "6881:6881/udp"
    restart: unless-stopped

  app:
    image: nick404/torrenthub:latest
    container_name: torrent-hub
    environment:
      DATABASE_URL: sqlite+aiosqlite:////data/app.db
      DATA_DIR_PATH: /data
      MEDIA_ROOT: /media
      DOWNLOAD_ROOT: /downloads
      QBIT_URL: http://qbittorrent:8080
      QBIT_USERNAME: admin
      QBIT_PASSWORD: ${QBIT_PASSWORD}
      QBIT_CATEGORY: torrent-hub
      QBIT_ENABLED: "true"
      CORS_ORIGINS: http://${LAN_IP}:8000
    volumes:
      - ./data:/data
      - ./media:/media
      - ./data/downloads:/downloads
    ports:
      - "8000:8000"
    depends_on:
      - qbittorrent
    restart: unless-stopped
⁠3. 启动
docker compose up -d

打开:

http://<LAN_IP>:8000/

API 健康检查:

curl http://<LAN_IP>:8000/api/v1/health

⁠与 qBittorrent 联动

⁠1. 设置 qBittorrent 密码

首次启动后查看临时密码:

docker logs torrent-hub-qbittorrent 2>&1 | grep -i password

打开 http://<LAN_IP>:8080,用 admin + 临时密码登录,在 Options → Web UI → Password 改成 .env 中的 QBIT_PASSWORD。

⁠2. 共享下载目录

关键点是 qBittorrent 和 TorrentHub 容器必须挂载同一个宿主机目录:

qbittorrent:
  volumes:
    - ./data/downloads:/downloads

app:
  volumes:
    - ./data/downloads:/downloads

qBittorrent 的保存路径设为 /downloads;TorrentHub 的 DOWNLOAD_ROOT=/downloads。如果两者路径不一致,下载完成后的归档会找不到文件。

⁠3. 完成后的流程

TorrentHub 每 5 秒轮询 qBittorrent:

  1. 检测到任务完成
  2. POST /api/v2/torrents/stop 停止做种
  3. POST /api/v2/torrents/delete,deleteFiles=false
  4. 从 /downloads 找到最大视频
  5. 硬链接/复制到 /media
  6. 写入 NFO、poster、fanart
  7. 触发 Jellyfin/Stash 刷新(若配置)
  8. 下载记录标记 completed

qBittorrent 任务列表会清空,但文件保留在 data/downloads;归档后通常使用硬链接,不会重复占用完整视频空间。

⁠4. 使用已有 qBittorrent

如果不想用 Compose 里的 qBittorrent:

  • 删除 qbittorrent 服务
  • 把 QBIT_URL 改成容器能访问的地址,例如 http://192.168.1.10:8080
  • 确保 TorrentHub 挂载了同一个 /downloads 目录(或改成相同的绝对路径)
  • qBittorrent 的 WebUI 用户名/密码填入 QBIT_USERNAME / QBIT_PASSWORD

⁠Jellyfin(可选)

先启动 Jellyfin(使用完整 Compose 或单独容器),设置:

JELLYFIN_URL=http://jellyfin:8096
JELLYFIN_PUBLIC_URL=http://<LAN_IP>:8096
JELLYFIN_API_KEY=<token>

Jellyfin 媒体库目录:

/media/movies
/media/tv
/media/adult

MP4 可直接在浏览器播放;MKV 会显示 Jellyfin 播放按钮。Jellyfin token 失效后需要重新登录并更新环境变量。

⁠数据目录

路径内容
data/app.dbSQLite 数据库
data/downloads/qBittorrent 下载暂存
media/归档后的视频、NFO、海报
data/covers/封面缓存
data/trash/回收站,默认保留 7 天
data/jellyfin/Jellyfin 配置/缓存
data/amane/Amane 数据

备份至少包含 data/app.db、media/ 和 .env。

⁠缓存与容量

  • 每日 04:00 清理可再生缓存
  • 磁盘低于 15 GB 时触发紧急缓存清理
  • 封面 30 天 / 512 MB;Jellyfin 转码 7 天 / 2 GB;Amane 512 MB;trash 7 天
  • 种子元数据 14 天 / 50,000 条,保留被引用条目
  • 资料库媒体默认不自动删除;软配额默认 80 GB
  • 前端右上角可预览/执行清理

宿主机 Docker 清理:

docker builder prune --filter until=168h
docker image prune -a --filter until=336h
docker container prune --filter until=168h

⁠常见问题

页面打开但 API 请求 404?
all-in-one 使用相对路径 /api/v1,请从 http://<LAN_IP>:8000/ 访问,不要只打开静态文件。

下载完成但资料库没有条目?
检查 qBittorrent 与 TorrentHub 是否共享 /downloads,并查看 docker logs torrent-hub。

qBittorrent 任务消失但文件还在?
预期行为:完成后停止做种并删除任务,deleteFiles=false 保留文件。

MKV 不能直接播放?
浏览器通常不支持 MKV;点击 Jellyfin 播放按钮,或下载原文件。

⁠安全

  • 不要提交 .env
  • 不要把 qBittorrent、Jellyfin、TorrentHub 直接暴露到公网
  • 公网访问请使用 VPN 或带认证的反向代理
  • 公开种子站内容版权归权利人所有,请遵守所在地法律与站点条款

⁠License

MIT(示例文档;第三方镜像与站点内容遵循各自许可证/条款)。

Tag summary

Content type

Image

Digest

sha256:9fb452b8b…

Size

126.7 MB

Last updated

14 days ago

docker pull nick404/torrenthub