@chenhao6682108/dsh-skill-musicbee 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/README.zh.md +2 -0
- package/package.json +1 -1
- package/skills/musicbee/SKILL.md +19 -17
- package/skills/musicbee/scripts/__pycache__/party_build.cpython-311.pyc +0 -0
- package/skills/musicbee/scripts/mb-doctor.ps1 +3 -0
- package/skills/musicbee/scripts/mb_tools/__pycache__/__init__.cpython-311.pyc +0 -0
- package/skills/musicbee/scripts/mb_tools/__pycache__/__main__.cpython-311.pyc +0 -0
- package/skills/musicbee/scripts/mb_tools/__pycache__/cli.cpython-311.pyc +0 -0
- package/skills/musicbee/scripts/mb_tools/__pycache__/scan.cpython-311.pyc +0 -0
- package/skills/musicbee/scripts/mb_tools/__pycache__/tags.cpython-311.pyc +0 -0
- package/skills/musicbee/scripts/party_build.py +66 -11
package/README.md
CHANGED
|
@@ -64,7 +64,10 @@ it feeds (`playlists_dir`, `library_root`, `python` → `MUSICBEE_PY`).
|
|
|
64
64
|
Then copy `references/party-2026-11-20-final.json`, change only the path fields and `library_root`,
|
|
65
65
|
and keep the rule fields (`req`, `ending`, `body`, `share`, `long_sec`, `no_repeat_style`,
|
|
66
66
|
`ballroom_gap_max`) as they are. `party_build.py -h` lists every accepted field, and each failure
|
|
67
|
-
message names the exact next command to run.
|
|
67
|
+
message names the exact next command to run. `playlists_dir` and `prefix_mbp` are **optional in the
|
|
68
|
+
config**: `party_build.py` reads MusicBee's own `Playlists` folder from `<ENV_LibPath>` and picks a
|
|
69
|
+
same-library `.mbp` for the 52-byte header, so only `library_root` (the folder whose subfolders are the
|
|
70
|
+
style names) has to be written by hand.
|
|
68
71
|
|
|
69
72
|
## How it works
|
|
70
73
|
|
package/README.zh.md
CHANGED
|
@@ -57,6 +57,8 @@ scripts\mb-doctor.cmd -Json :: 给程序读的 JSON
|
|
|
57
57
|
然后把 `references/party-2026-11-20-final.json` 复制一份,只改路径字段和 `library_root`,
|
|
58
58
|
规则字段(`req`、`ending`、`body`、`share`、`long_sec`、`no_repeat_style`、`ballroom_gap_max`)原样保留。
|
|
59
59
|
`party_build.py -h` 会列出所有可用字段;每条报错都会写清楚下一步该跑什么命令。
|
|
60
|
+
`playlists_dir` 和 `prefix_mbp` 现在可以**整个省略**:`party_build.py` 从 `<ENV_LibPath>` 读到 MusicBee 的
|
|
61
|
+
`Playlists` 目录,并自动挑一个同库 `.mbp` 取 52 字节文件头——手写只剩 `library_root`(风格子目录的父目录)。
|
|
60
62
|
|
|
61
63
|
## 实现方式
|
|
62
64
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenhao6682108/dsh-skill-musicbee",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "MusicBee playlist and library toolkit as a DSH skill plugin: scan a music library into a JSON index, write ID3/Vorbis/MP4 tags, build validated dsh (3dj) party playlists, rewrite and remap .mbp playlist files, and make MusicBee re-read them. Ships mb-doctor to auto-detect the MusicBee library, Playlists folder and Python. Windows and a local MusicBee install required; no network access and no audio data is modified.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek",
|
package/skills/musicbee/SKILL.md
CHANGED
|
@@ -51,26 +51,27 @@ CLI 入口:`scripts\mb-tools.cmd`(内部 `python -X utf8 -m mb_tools`;命
|
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
-
##
|
|
54
|
+
## 零、路径从哪来(默认自动,不用手填)
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
只有三样本机信息相关,其中**两样已经自动**:
|
|
57
|
+
|
|
58
|
+
| 信息 | 现在怎么来 |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `playlists_dir` | **自动**:`party_build.py` 直接读 `%APPDATA%\MusicBee\MusicBee3Settings.ini` 的 `<ENV_LibPath>`,得到 `<库>\Playlists` |
|
|
61
|
+
| `prefix_mbp` | **自动**:从上面那个 `Playlists` 目录里挑任意一个同库 `.mbp` 取 52 字节文件头 |
|
|
62
|
+
| `library_root` | 仍然要写一句:它是**风格子目录的父目录**(如 `C:\音乐分类\1blues`),机器猜不出你的分类习惯 |
|
|
63
|
+
|
|
64
|
+
所以配置里 `playlists_dir` 和 `prefix_mbp` **可以整个省略**;`out_mbp` 写相对路径时按 `Playlists` 目录解析(如 `3dj\2026-11-27 blues舞会6.mbp`)。
|
|
65
|
+
|
|
66
|
+
想先看清本机状态(可选):
|
|
58
67
|
|
|
59
68
|
```bat
|
|
60
|
-
scripts\mb-doctor.cmd ::
|
|
61
|
-
scripts\mb-doctor.cmd -StyleRoot "D:\你的曲库\1blues" ::
|
|
69
|
+
scripts\mb-doctor.cmd :: MusicBee 库 / Playlists / 分组 / Python
|
|
70
|
+
scripts\mb-doctor.cmd -StyleRoot "D:\你的曲库\1blues" :: 顺便列出风格子目录名(写 styles 用)
|
|
62
71
|
scripts\mb-doctor.cmd -Json :: 给程序读的 JSON
|
|
63
72
|
```
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|---|---|---|
|
|
67
|
-
| `MusicBeeLibrary` | MusicBee 库目录 | (用来推导 `Playlists`) |
|
|
68
|
-
| `PlaylistsDir` | `.mbp` 所在目录,须已存在 | `playlists_dir` |
|
|
69
|
-
| `PlaylistGroups` | 已有分组(如 `1blues`、`3dj`) | 决定 `prefix_mbp` 和 `out_mbp` |
|
|
70
|
-
| `StyleRoot` / `StyleSubfolders` | 风格子目录的父目录及其子目录名 | `library_root` 与 `styles` |
|
|
71
|
-
| `Python` | 可用解释器路径 | 设环境变量 `MUSICBEE_PY`,或直接用它 |
|
|
72
|
-
|
|
73
|
-
三项齐了再改配置:复制 `references/party-2026-11-20-final.json` 一份,**只改路径字段和 `library_root`**,
|
|
74
|
+
复制 `references/party-2026-11-20-final.json` 一份,改 `library_root`、`out_mbp`、`name` 即可;
|
|
74
75
|
`req` / `ending` / `body` / `share` / `long_sec` / `no_repeat_style` / `ballroom_gap_max` 这些规则原样保留。
|
|
75
76
|
|
|
76
77
|
### 报错 → 该做什么
|
|
@@ -79,8 +80,9 @@ scripts\mb-doctor.cmd -Json :: 给程序读的 JSON
|
|
|
79
80
|
|---|---|
|
|
80
81
|
| `配置缺少字段:library_root…` | 填「风格子目录的父目录」;用 `mb-doctor.cmd -StyleRoot <目录>` 确认 |
|
|
81
82
|
| `索引文件不存在:…` | 先 `mb-tools.cmd scan --dir <曲库根> --out <那个 index 路径>` |
|
|
82
|
-
|
|
|
83
|
-
|
|
|
83
|
+
| `找不到 MusicBee 的 Playlists 目录…` | MusicBee 至少启动过一次才会写 settings ini;或在配置里显式写 `playlists_dir` |
|
|
84
|
+
| `playlists_dir 不存在:…` | 同上;或改正配置里的 `playlists_dir` |
|
|
85
|
+
| `Playlists 目录下没有任何 .mbp…` | 先在 MusicBee 里建一个歌单,或在配置里显式写 `prefix_mbp` |
|
|
84
86
|
| `曲目无法唯一定位:…` | `set` 里的标题必须与索引完全一致;`scan` 后曲库改过要重扫 |
|
|
85
87
|
| `风格池不存在于索引:…` | `library_root` 指错了层级(少了/多了 `1blues` 这层),或 `styles` 名与子目录名不符 |
|
|
86
88
|
|
|
@@ -359,7 +361,7 @@ scripts\restart-musicbee.cmd
|
|
|
359
361
|
| 字段 | 说明 |
|
|
360
362
|
|---|---|
|
|
361
363
|
| `index` / `library_root` | 索引 JSON 与 1blues 根目录(按子目录判风格) |
|
|
362
|
-
| `playlists_dir` / `prefix_mbp` / `out_mbp` | Playlists
|
|
364
|
+
| `playlists_dir` / `prefix_mbp` / `out_mbp` | Playlists 根(**可省略,自动从 MusicBee 设置取**)、52 字节头来源(**可省略,自动挑同库 .mbp**)、输出 .mbp(相对路径按 Playlists 解析) |
|
|
363
365
|
| `name` / `start` | 歌单名(= 文件名)、开始时间 `"22:30"` |
|
|
364
366
|
| `styles` / `req` / `body` | 可能用到的风格池、固定配额(风格→首数)、其余曲目允许的风格 |
|
|
365
367
|
| `set` | 播放顺序曲目表,每行 `[风格, 艺人片段, 标题, 能量H/M/L, 理由, 段落]`;标题须与索引一致 |
|
|
Binary file
|
|
@@ -111,5 +111,8 @@ if (-not $styleOk) { Write-Host " library_root : pass -StyleRoot to see i
|
|
|
111
111
|
if (-not $py) { Write-Host " python : set MUSICBEE_PY=%LOCALAPPDATA%\Programs\Python\...\python.exe, or run scripts\bootstrap.ps1" }
|
|
112
112
|
if (-not $exe) { Write-Host " MusicBee.exe : install MusicBee, or pass -MusicBeeExe to restart-musicbee.cmd" }
|
|
113
113
|
if ($hasPlaylists -and $styleOk -and $py -and $exe) { Write-Host " everything needed was found. Next: fill a party config and run party_build.py <config.json>" }
|
|
114
|
+
Write-Host ""
|
|
115
|
+
Write-Host "IMPORTANT: playlists_dir and prefix_mbp are detected automatically by party_build.py, so the"
|
|
116
|
+
Write-Host " only path you still must supply is library_root (the folder whose subfolders are the styles)."
|
|
114
117
|
|
|
115
118
|
if ($hasPlaylists -and $py) { exit 0 } else { exit 1 }
|
|
Binary file
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"""
|
|
46
46
|
import json
|
|
47
47
|
import os
|
|
48
|
+
import re
|
|
48
49
|
import struct
|
|
49
50
|
import sys
|
|
50
51
|
|
|
@@ -177,31 +178,85 @@ def mmss(t):
|
|
|
177
178
|
|
|
178
179
|
|
|
179
180
|
# ---------------------------------------------------------------- 校验
|
|
181
|
+
# ------------------------------------------------------------ 默认路径
|
|
182
|
+
def default_playlists_dir():
|
|
183
|
+
"""MusicBee 的 Playlists 目录:从 settings ini 的 <ENV_LibPath> 推导,取不到返回 ""。"""
|
|
184
|
+
ini = os.path.join(os.environ.get("APPDATA", ""), "MusicBee", "MusicBee3Settings.ini")
|
|
185
|
+
try:
|
|
186
|
+
with open(ini, encoding="utf-8-sig", errors="ignore") as f:
|
|
187
|
+
txt = f.read()
|
|
188
|
+
except OSError:
|
|
189
|
+
return ""
|
|
190
|
+
m = re.search(r"<ENV_LibPath>([^<]*)</ENV_LibPath>", txt)
|
|
191
|
+
if not m:
|
|
192
|
+
return ""
|
|
193
|
+
lib = m.group(1).strip()
|
|
194
|
+
return os.path.join(lib, "Playlists") if lib else ""
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def auto_prefix_mbp(playlists_dir):
|
|
198
|
+
"""同库任意一个 .mbp 都能提供那 52 字节文件头;按路径排序取第一个可读的。"""
|
|
199
|
+
found = []
|
|
200
|
+
for dirpath, _dirs, files in os.walk(playlists_dir):
|
|
201
|
+
for name in files:
|
|
202
|
+
if name.lower().endswith(".mbp"):
|
|
203
|
+
found.append(os.path.join(dirpath, name))
|
|
204
|
+
for p in sorted(found):
|
|
205
|
+
try:
|
|
206
|
+
if os.path.getsize(p) >= 56:
|
|
207
|
+
return p
|
|
208
|
+
except OSError:
|
|
209
|
+
continue
|
|
210
|
+
return ""
|
|
211
|
+
|
|
212
|
+
|
|
180
213
|
def run(cfg):
|
|
181
|
-
need = ["index", "
|
|
214
|
+
need = ["index", "out_mbp", "name", "styles", "req", "body", "set"]
|
|
182
215
|
missing = [k for k in need if k not in cfg]
|
|
183
216
|
if missing:
|
|
184
217
|
die("配置缺少字段:" + "、".join(missing) +
|
|
185
218
|
"\n 必填:" + " / ".join(need) +
|
|
186
|
-
"\n
|
|
219
|
+
"\n playlists_dir / prefix_mbp 可以省略:默认从 MusicBee 设置里自动取。")
|
|
220
|
+
|
|
221
|
+
# playlists_dir:配置没写就用 MusicBee 自己的 Playlists 目录
|
|
222
|
+
playlists_dir = cfg.get("playlists_dir") or default_playlists_dir()
|
|
223
|
+
if not playlists_dir:
|
|
224
|
+
die("找不到 MusicBee 的 Playlists 目录(settings ini 里没有 <ENV_LibPath>)。\n"
|
|
225
|
+
" 先启动一次 MusicBee,或在配置里显式写 playlists_dir。")
|
|
226
|
+
if not os.path.isdir(playlists_dir):
|
|
227
|
+
die("playlists_dir 不存在:" + playlists_dir +
|
|
228
|
+
"\n 先启动一次 MusicBee 让它写出库路径,或在配置里改正 playlists_dir。")
|
|
229
|
+
cfg["playlists_dir"] = playlists_dir
|
|
230
|
+
print("playlists_dir = " + playlists_dir)
|
|
231
|
+
|
|
232
|
+
# prefix_mbp:没写就从 Playlists 目录里自动挑一个同库 .mbp 取 52 字节头
|
|
233
|
+
if not cfg.get("prefix_mbp"):
|
|
234
|
+
prefix = auto_prefix_mbp(playlists_dir)
|
|
235
|
+
if not prefix:
|
|
236
|
+
die("Playlists 目录下没有任何 .mbp,取不到 52 字节文件头。\n"
|
|
237
|
+
" 先在 MusicBee 里建一个歌单,或在配置里显式写 prefix_mbp。")
|
|
238
|
+
cfg["prefix_mbp"] = prefix
|
|
239
|
+
print("prefix_mbp = " + prefix + " (auto)")
|
|
240
|
+
|
|
241
|
+
# out_mbp 写成相对路径时,按 Playlists 目录解析
|
|
242
|
+
if not os.path.isabs(cfg["out_mbp"]):
|
|
243
|
+
cfg["out_mbp"] = os.path.join(playlists_dir, cfg["out_mbp"])
|
|
244
|
+
|
|
245
|
+
library_root = cfg.get("library_root")
|
|
246
|
+
if not library_root:
|
|
247
|
+
die("配置缺少字段:library_root(风格子目录的父目录,例如 ...\\1blues)" +
|
|
248
|
+
"\n 先跑 scripts\\mb-doctor.cmd -StyleRoot <那个目录> 确认风格子目录名")
|
|
249
|
+
if not os.path.isdir(library_root):
|
|
250
|
+
die("library_root 不是有效目录:" + library_root)
|
|
187
251
|
|
|
188
252
|
index_path = cfg["index"]
|
|
189
253
|
if not os.path.exists(index_path):
|
|
190
254
|
die("索引文件不存在:" + index_path +
|
|
191
255
|
"\n 它是 mb-tools scan 的产物,先生成:mb-tools.cmd scan --dir <曲库根> --out " + index_path)
|
|
192
|
-
if not os.path.isdir(cfg["playlists_dir"]):
|
|
193
|
-
die("playlists_dir 不存在:" + cfg["playlists_dir"] +
|
|
194
|
-
"\n 先跑 scripts\\mb-doctor.cmd 查看探测到的 Playlists 目录")
|
|
195
256
|
|
|
196
257
|
tracks = json.load(open(index_path, encoding="utf-8"))
|
|
197
258
|
if isinstance(tracks, dict):
|
|
198
259
|
tracks = tracks.get("tracks") or tracks.get("items") or []
|
|
199
|
-
library_root = cfg.get("library_root")
|
|
200
|
-
if not library_root:
|
|
201
|
-
die("配置缺少字段:library_root(风格子目录的父目录,例如 ...\\1blues)" +
|
|
202
|
-
"\n 先跑 scripts\\mb-doctor.cmd -StyleRoot <那个目录> 确认风格子目录名")
|
|
203
|
-
if not os.path.isdir(library_root):
|
|
204
|
-
die("library_root 不是有效目录:" + library_root)
|
|
205
260
|
pools = load_pools(tracks, library_root)
|
|
206
261
|
for st in cfg["styles"]:
|
|
207
262
|
if st not in pools:
|