MuPiBox Media DB
Manage the MuPiBox media database (data.json) via the backend API.
Requirements
- - Access to a running MuPiBox backend instance (MuPiBox host is often
http://mupibox/, API for this script defaults to http://mupibox:8200; override with --base-url) - Python 3
- Bundled script available at INLINECODE4
API basics
- - Read: INLINECODE5
- Write:
POST /api/add, POST /api/edit, INLINECODE8
Example commands
Script path: ./scripts/mupibox_media_manager.py. Default API endpoint is http://mupibox:8200 (override with --base-url).
CODEBLOCK0
Add entries
CODEBLOCK1
Remove entries
CODEBLOCK2
Move / reorder
CODEBLOCK3
Update fields
CODEBLOCK4
INLINECODE12 accepts JSON values (true, false, numbers, strings).
Restore
CODEBLOCK5
Agent workflow
- 1. For
add: resolve missing IDs/metadata first, then add. - For
remove: identify entry via list first, then remove. - For
move: confirm target positions, then move. - Verify changes using
list.
Quality checks for Spotify audiobooks
- - Prefer album IDs over playlist IDs (unless playlists are explicitly requested).
- Avoid box sets/compilations when a single canonical release is intended.
- Choose consistent versions when duplicates exist.
- Ask for clarification if uncertain instead of adding blindly.
Safety
- - No external side effects outside the MuPiBox API.
- The bundled script creates a local backup before mutations.
- Restore only from trusted backup files.
- On failure, report the latest backup file.
MuPiBox 媒体数据库
通过后端 API 管理 MuPiBox 媒体数据库(data.json)。
前提条件
- - 能够访问正在运行的 MuPiBox 后端实例(MuPiBox 主机通常为 http://mupibox/,本脚本默认 API 地址为 http://mupibox:8200;可通过 --base-url 覆盖)
- Python 3
- 捆绑脚本位于 ./scripts/mupiboxmediamanager.py
API 基础
- - 读取:GET /api/data
- 写入:POST /api/add、POST /api/edit、POST /api/delete
示例命令
脚本路径:./scripts/mupiboxmediamanager.py。默认 API 端点为 http://mupibox:8200(可通过 --base-url 覆盖)。
bash
显示列表
python3 ./scripts/mupibox
mediamanager.py --base-url
list --limit 30
筛选(例如 Spotify + 音乐)
python3 ./scripts/mupiboxmediamanager.py --base-url list --type spotify --category music --limit 100
手动备份
python3 ./scripts/mupiboxmediamanager.py --base-url backup
添加条目
bash
1) 原始 JSON
python3 ./scripts/mupiboxmediamanager.py --base-url add \
--json {type:spotify,category:audiobook,artist:示例艺术家,id:SPOTIFY_ID}
2) Spotify URL,自动提取 ID
python3 ./scripts/mupiboxmediamanager.py --base-url add \
--type spotify --category audiobook --artist 示例艺术家 \
--spotify-url https://open.spotify.com/album/SPOTIFY_ID
删除条目
bash
按索引
python3 ./scripts/mupiboxmediamanager.py --base-url remove --index 42
按 Spotify ID
python3 ./scripts/mupiboxmediamanager.py --base-url URL> remove --spotify-id SPOTIFYID
移动/重新排序
bash
python3 ./scripts/mupiboxmediamanager.py --base-url move --from 20 --to 3
更新字段
bash
python3 ./scripts/mupiboxmediamanager.py --base-url set --index 10 \
--field artist=新艺术家 \
--field category=audiobook \
--field shuffle=true
--field 接受 JSON 值(true、false、数字、字符串)。
恢复
bash
python3 ./scripts/mupiboxmediamanager.py --base-url restore \
--file ~/.mupibox-db-backups/data-YYYYMMDD-HHMMSS-before-add.json
代理工作流程
- 1. 对于 add:先解析缺失的 ID/元数据,再添加。
- 对于 remove:先通过 list 识别条目,再删除。
- 对于 move:确认目标位置,再移动。
- 使用 list 验证更改。
Spotify 有声书的质量检查
- - 优先使用专辑 ID 而非播放列表 ID(除非明确要求播放列表)。
- 当意图指向单一规范版本时,避免使用套装/合集。
- 存在重复时,选择一致的版本。
- 不确定时请询问澄清,而非盲目添加。
安全性
- - 不会对 MuPiBox API 之外产生外部副作用。
- 捆绑脚本在变更前会创建本地备份。
- 仅从可信的备份文件恢复。
- 失败时,报告最新的备份文件。