Files
server-ops/daily/2026-06-20.md

46 lines
1.7 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.

# 2026-06-20 Audiobookshelf 部署 + 章节排序经验
## Audiobookshelf 部署
- Docker 容器ghcr.io/advplyr/audiobookshelf:latest (v2.35.1),端口 13378
- docker-compose 管理,路径:`/home/ubuntu/audiobookshelf/`
- Caddy 反代podcast.xybkwd.top
- 数据目录config/ metadata/ audiobooks/ podcasts/
## 章节排序三层同步铁律
Audiobookshelf 的章节显示依赖三层数据:
| 层 | 数据位置 | 关键字段 |
|:---|:---|:---|
| 文件系统 | 文件名 `01-标题.mp3` | 数字前缀保证字母序 |
| books.chapters (SQLite) | JSON 数组 | `start` 时间戳递减 |
| books.audioFiles (SQLite) | JSON 数组 | `index` 顺序递增 |
**只改文件名不生效**,必须三条线同步。
## 完整工作流
```
yt-dlp 下载 → --print upload_date 获取发布时间
→ 按 upload_date 排序 → 生成 01~N 前缀
→ 重命名 01-源端完整标题.mp3
→ 放入 /home/ubuntu/audiobookshelf/audiobooks/专辑名/
→ watcher 自动检测(不重启容器)
→ 验证 chapters.start + audioFiles.index 顺序正确
```
## B站下载要点
- 需 cookies 认证(从本地 Firefox cookies.sqlite 提取 → SCP 上传 /tmp/bilibili_cookies.txt
- B站无纯音频流`-f worstvideo+worstaudio/worst -x` 最小化下载量
- 每集 ~40-50MB音频下载速度 6-14 MB/s日本 CDN 节点)
- 服务器带宽 1.5TB/月,完全够用
## 踩坑记录
1. `rm` 数据库必须先问用户 - 造成账号数据丢失
2. Audiobookshelf 章节排序不是靠文件名,是靠 start 时间戳
3. 操作文件前不要盲目 rm先用 ls 确认
4. 容器不需要频繁重启watcher 会自动检测文件变化