douyinWEB/README.md
eric 2515f438c2 Update README for dylive/feiniu production and sync deploy scripts.
Document Caddy domains, SeaweedFS covers, VPS ports, and keep monitor DB current.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-08 10:14:27 -05:00

137 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 抖音直播间监控(douyinWEB)
批量监控抖音直播间 **开播 / 停播 / 播放时长 / 截图**,控制台对齐 `sh2` 的 `youtube-relay-log` 可视化与场次列表。
探测逻辑参考 `sh2/d2ypp2`(`web/enter + a_bogus`、Cookie、循环间隔),默认不爬直播间 HTML,降低风控。
## 线上地址
| 用途 | URL |
|------|-----|
| 控制台 | https://dylive.nomadro.com/ |
| API | https://dylive.nomadro.com/api/health · `/docs` 见下方直连 |
| PocketBase | https://dylive.nomadro.com/_/ |
| SeaweedFS S3 | https://feiniu.nomadro.com/ |
| S3 别名 | https://s3.nomadro.com/ |
HTTPS 由服务器 **Caddy** 自动签发;进程端口:
| 服务 | 端口 |
|------|------|
| Next.js | `4015` |
| FastAPI | `8014` |
| PocketBase | `8092` |
| SeaweedFS S3 | `8333` |
systemd:`douyinweb-web` / `douyinweb-api` / `douyinweb-pb`,以及 `seaweed-master|volume|filer|s3`。
## 技术栈
- **Next.js 15** — 雷达台 / 场次 / 直播间 / 主播 / 截图 / 设置
- **FastAPI** — 轮询、场次、SSE、REST
- **PocketBase** — 可选镜像
- **SQLite** — 监控热路径
- **SeaweedFS** — 开源对象存储(S3 API),封面上传
## 功能
- 直播间:单条 / 批量添加、标签、启用停用、黑名单、CSV 导出
- 开播建场、停播结场、进行中实时计时(每房仅一场,幂等去重)
- 开播截图 → 本地 + 上传 SeaweedFS;进行中场次缩略图,**点击放大**
- 可视化分析、主播画像、封面墙、事件时间线、SSE + Toast
- Cookie:可从 sh2 `config.ini` 的 `抖音cookie` 导入(`POST /api/settings/sync-cookie`)
- 防风控(对齐 sh2):
- 仅 `webcast/room/web/enter` + `a_bogus`
- 并发 1、间隔抖动、离线约 300s / 在播约 120s
- 错误退避;风控短冷却约 90s
## 目录
```
douyinWEB/
backend/app/ FastAPI(douyin / monitor / ab_sign / s3_storage …)
backend/data/ SQLite、封面、导入快照(入库便于部署同步)
frontend/src/ Next.js App Router
pb/ PocketBase 数据;Linux 二进制部署时下载
scripts/ 本地启动与 VPS 部署脚本
```
## 本地启动
```bat
scripts\start.bat
```
或:
```bat
pb\pocketbase.exe serve --http=127.0.0.1:8090
cd backend && python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload
cd frontend && npm run dev -- --port 3000 --hostname 127.0.0.1
```
- 控制台:http://127.0.0.1:3000
- API:http://127.0.0.1:8000/docs
- PB:http://127.0.0.1:8090/_/
默认 PB:`admin@douyin.local` / `DouyinMonitor_Admin_2026`
```bat
cd backend && pip install -r requirements.txt
cd frontend && npm install
```
## 导入与运维脚本
```bat
python scripts\import_from_11.py # 从 Desktop\11.txt 导入房间
python scripts\apply_sh2_antirisk.py # 对齐 sh2 防风控并错开检测
python scripts\sync_cookie_and_probe.py # 同步 Cookie 并抽样探测
```
VPS 相关(需 SSH 可达):
```bat
python scripts\deploy_seaweedfs.py # 安装 SeaweedFS + 部署封面能力
python scripts\setup_caddy_dylive.py # 配置 dylive / feiniu / s3 反代
python scripts\recapture_covers_now.py # 为当前进行中场次补抓封面
python scripts\restart_vps.py # 重启 douyinWEB 进程
```
## 关键设置(防风控)
| 项 | 建议 |
|----|------|
| `max_concurrency` | 1 |
| `offline_interval_sec` | ≥ 300 |
| `live_interval_sec` | ≥ 90–120 |
| `min_request_gap_sec` | ≥ 3 + jitter |
| `dy_cookie` | 有效抖音 Cookie |
| `capture_cover_on_start` | 开播截图(上传 SeaweedFS) |
## 环境变量(`DY_` 前缀)
见 `backend/app/config.py`,线上 API 示例:
```
DY_PB_URL=http://127.0.0.1:8092
DY_S3_ENABLED=true
DY_S3_ENDPOINT=http://127.0.0.1:8333
DY_S3_PUBLIC_BASE=https://feiniu.nomadro.com
DY_S3_ACCESS_KEY=douyin
DY_S3_SECRET_KEY=…
DY_S3_BUCKET=douyin-covers
```
## Git
```
https://gitea.dsx2020.com/eric/douyinWEB.git
```
## 说明
- 仓库含 `backend/data/` 与 `pb/pb_data/`,便于部署后带真实房间与 Cookie 开箱可用。
- Windows `pocketbase.exe` 不入库;Ubuntu 使用 Linux 版 `pocketbase`。
- 仅状态监控与场次统计,不含推流录制(推流仍在 sh2)。