@kg-ai/kugou-skill 0.1.7 → 0.1.8
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 +198 -139
- package/SKILL.md +223 -143
- package/bin/darwin-arm64/kugou-cli +0 -0
- package/bin/darwin-x64/kugou-cli +0 -0
- package/bin/linux-arm64/kugou-cli +0 -0
- package/bin/linux-x64/kugou-cli +0 -0
- package/bin/win32-x64/kugou-cli.exe +0 -0
- package/package.json +1 -1
- package/references/auth.md +2 -2
- package/references/control.md +680 -0
- package/references/error-handling.md +3 -3
- package/references/install.md +3 -2
- package/references/music.md +526 -323
- package/references/output-format.md +50 -4
- package/references/update.md +2 -1
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
# 控制命令 (control)
|
|
2
|
+
|
|
3
|
+
> AI-facing usage guide for `kugou-cli control` — the local PC/Mac Kugou client control subcommands.
|
|
4
|
+
|
|
5
|
+
本模块通过本机 HTTP server 控制 PC/Mac 酷狗客户端,支持播放控制、收藏管理、歌单创建等操作。输出格式为原始 JSON(详见 [references/output-format.md](./output-format.md))。
|
|
6
|
+
|
|
7
|
+
**前置条件**: CLI 已登录(`kugou-cli auth login`)+ 酷狗客户端正在运行。仅支持 Windows / macOS(Linux 运行时会报错,见下方错误场景)。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 命令列表
|
|
12
|
+
|
|
13
|
+
### 读操作(read)
|
|
14
|
+
|
|
15
|
+
| 命令 | 说明 |
|
|
16
|
+
|------|------|
|
|
17
|
+
| `kugou-cli control start` | 显式触发握手/唤起客户端(用于预热或调试) |
|
|
18
|
+
| `kugou-cli control status` | 获取客户端状态(协议版本、登录态、能力列表) |
|
|
19
|
+
| `kugou-cli control current` | 获取当前播放歌曲(歌名、进度、音量、收藏状态) |
|
|
20
|
+
|
|
21
|
+
### 播放器控制(player)
|
|
22
|
+
|
|
23
|
+
| 命令 | 说明 |
|
|
24
|
+
|------|------|
|
|
25
|
+
| `kugou-cli control play` | 播放歌曲(按 mixsongid) |
|
|
26
|
+
| `kugou-cli control play-playlist` | 播放整个歌单(按 global_collection_id) |
|
|
27
|
+
| `kugou-cli control continue-play` | 拉取"另一设备续播"列表并开始播放 |
|
|
28
|
+
| `kugou-cli control player` | 播放器控制(播放/暂停/切歌/停止) |
|
|
29
|
+
| `kugou-cli control seek` | 进度控制(快进/快退/跳转) |
|
|
30
|
+
| `kugou-cli control volume` | 音量控制(增减/设置/静音) |
|
|
31
|
+
|
|
32
|
+
### 账户操作(account)
|
|
33
|
+
|
|
34
|
+
| 命令 | 说明 |
|
|
35
|
+
|------|------|
|
|
36
|
+
| `kugou-cli control favorite song` | 收藏/取消收藏歌曲 |
|
|
37
|
+
| `kugou-cli control favorite songlist` | 收藏/取消收藏歌单 |
|
|
38
|
+
| `kugou-cli control playlist create` | 创建本地歌单(带歌曲列表) |
|
|
39
|
+
|
|
40
|
+
### 系统操作(utility)
|
|
41
|
+
|
|
42
|
+
| 命令 | 说明 |
|
|
43
|
+
|------|------|
|
|
44
|
+
| `kugou-cli control open` | 打开客户端内页面(主界面/歌手/专辑/歌单/搜索) |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 1. start — 显式触发握手
|
|
49
|
+
|
|
50
|
+
触发酷狗客户端的 URL scheme 唤起,等待客户端建立本机 HTTP 通道并返回状态。仅用于预热通道或调试连通性,不调用任何 `/v1/...` 业务接口。
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
kugou-cli control start
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**输出示例**(成功):
|
|
57
|
+
```json
|
|
58
|
+
{"handshake":"ok","addr":"http://127.0.0.1:52144"}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**输出示例**(失败):
|
|
62
|
+
```
|
|
63
|
+
kugou-cli control: not logged in, run `kugou-cli auth login` first: auth file not found
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 2. status — 获取客户端状态
|
|
69
|
+
|
|
70
|
+
查询本地酷狗客户端的协议版本、登录态和能力列表。对应 `GET /v1/status`。
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
kugou-cli control status
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**输出示例**:
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"code": 0,
|
|
80
|
+
"data": {
|
|
81
|
+
"version": "1.0.0",
|
|
82
|
+
"login": true,
|
|
83
|
+
"capabilities": ["play", "pause", "seek", "volume", "favorite", "playlist"]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 3. current — 获取当前播放
|
|
91
|
+
|
|
92
|
+
查询当前播放歌曲详情,包括歌名、歌手、进度、音量和收藏状态。对应 `GET /v1/player/current`。
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
kugou-cli control current
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**输出示例**:
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"code": 0,
|
|
102
|
+
"data": {
|
|
103
|
+
"song_name": "晴天",
|
|
104
|
+
"singer_name": "周杰伦",
|
|
105
|
+
"mixsongid": "32100650",
|
|
106
|
+
"position_ms": 45000,
|
|
107
|
+
"duration_ms": 240000,
|
|
108
|
+
"volume": 65,
|
|
109
|
+
"favorited": false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 4. play — 播放歌曲
|
|
117
|
+
|
|
118
|
+
在客户端播放一首歌曲。`--mixsongid` 必填,其余字段可选(仅用于客户端展示,不影响播放命中)。
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
kugou-cli control play --mixsongid 32100650 --song-name "晴天" --singer-name "周杰伦"
|
|
122
|
+
kugou-cli control play --mix-song-id 32100650 --mode "append_queue"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**参数**:
|
|
126
|
+
|
|
127
|
+
| 参数 | 说明 |
|
|
128
|
+
|------|------|
|
|
129
|
+
| `--mixsongid` | 歌曲 mixsongid(必填),也支持 `--mix-song-id` 别名 |
|
|
130
|
+
| `--song-name` | 歌曲显示名(可选) |
|
|
131
|
+
| `--singer-name` | 歌手显示名(可选) |
|
|
132
|
+
| `--mode` | 播放模式:`append_queue`(追加队列)、`next_play`(下一首播放) |
|
|
133
|
+
|
|
134
|
+
**输出示例**:
|
|
135
|
+
```json
|
|
136
|
+
{"code":0,"data":{"accepted":true}}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 5. player — 播放器控制
|
|
142
|
+
|
|
143
|
+
发送传输控制动作到播放器(播放/暂停/切歌等)。对应 `POST /v1/player/control`。
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
kugou-cli control player --action pause
|
|
147
|
+
kugou-cli control player --action next
|
|
148
|
+
kugou-cli control player --action resume
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**参数**:
|
|
152
|
+
|
|
153
|
+
| 参数 | 说明 |
|
|
154
|
+
|------|------|
|
|
155
|
+
| `--action` | 动作(必填):`play` `resume` `pause` `toggle` `next` `prev` `previous` `stop` |
|
|
156
|
+
|
|
157
|
+
`prev` 和 `previous` 视为同义词。
|
|
158
|
+
|
|
159
|
+
**输出示例**:
|
|
160
|
+
```json
|
|
161
|
+
{"code":0,"data":{"accepted":true}}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 5.1 continue-play — 拉取另一设备续播列表并播放
|
|
167
|
+
|
|
168
|
+
拉取云端"另一设备最近播放"的续播列表(酷狗首页的"续接播放"入口),并在本地客户端开始播放。对应 `POST /v1/player/continue_play`。
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# 默认:替换当前队列,从头播放
|
|
172
|
+
kugou-cli control continue-play
|
|
173
|
+
|
|
174
|
+
# 不打断当前播放:把续播列表追加到本地队列尾部
|
|
175
|
+
kugou-cli control continue-play --mode append_queue
|
|
176
|
+
|
|
177
|
+
# 把续播列表插到当前曲目之后立即播放
|
|
178
|
+
kugou-cli control continue-play --mode next_play
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**参数**:
|
|
182
|
+
|
|
183
|
+
| 参数 | 说明 |
|
|
184
|
+
|------|------|
|
|
185
|
+
| `--mode` | 队列策略:空(默认,替换队列)/ `append_queue`(追加队列尾部)/ `next_play`(下一首播放) |
|
|
186
|
+
|
|
187
|
+
**前置条件**:
|
|
188
|
+
- 已登录:`kugou-cli auth login`
|
|
189
|
+
- 客户端内已登录(否则返回 409/4091"login required",见错误场景 §2)
|
|
190
|
+
- 本地客户端必须运行(`kugou-cli control start` 健康)
|
|
191
|
+
|
|
192
|
+
**输出示例**:
|
|
193
|
+
```json
|
|
194
|
+
{"code":0,"data":{"accepted":true}}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 6. seek — 进度控制
|
|
200
|
+
|
|
201
|
+
控制当前播放歌曲的进度。对应 `POST /v1/player/seek`。
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# 快进 30 秒
|
|
205
|
+
kugou-cli control seek --action forward --offset-ms 30000
|
|
206
|
+
|
|
207
|
+
# 快退 10 秒
|
|
208
|
+
kugou-cli control seek --action rewind --offset-ms 10000
|
|
209
|
+
|
|
210
|
+
# 跳转到 2 分钟位置
|
|
211
|
+
kugou-cli control seek --action set --position-ms 120000
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**参数**:
|
|
215
|
+
|
|
216
|
+
| 参数 | 说明 |
|
|
217
|
+
|------|------|
|
|
218
|
+
| `--action` | 动作(必填):`forward` `rewind` `set` |
|
|
219
|
+
| `--offset-ms` | 偏移量(毫秒,forward/rewind 时必填) |
|
|
220
|
+
| `--position-ms` | 绝对位置(毫秒,action=set 时必填) |
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 7. volume — 音量控制
|
|
225
|
+
|
|
226
|
+
调整客户端音量或静音状态。对应 `POST /v1/player/volume`。
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# 音量增加 5 格
|
|
230
|
+
kugou-cli control volume --action up --delta 5
|
|
231
|
+
|
|
232
|
+
# 音量减少 10 格
|
|
233
|
+
kugou-cli control volume --action down --delta 10
|
|
234
|
+
|
|
235
|
+
# 设置音量到 42
|
|
236
|
+
kugou-cli control volume --action set --volume 42
|
|
237
|
+
|
|
238
|
+
# 静音
|
|
239
|
+
kugou-cli control volume --action mute
|
|
240
|
+
|
|
241
|
+
# 取消静音
|
|
242
|
+
kugou-cli control volume --action unmute
|
|
243
|
+
|
|
244
|
+
# 切换静音状态
|
|
245
|
+
kugou-cli control volume --action toggle_mute
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**参数**:
|
|
249
|
+
|
|
250
|
+
| 参数 | 说明 |
|
|
251
|
+
|------|------|
|
|
252
|
+
| `--action` | 动作(必填):`up` `down` `set` `mute` `unmute` `toggle_mute` |
|
|
253
|
+
| `--delta` | 音量变化量(up/down 时必填) |
|
|
254
|
+
| `--volume` | 绝对音量 0-100(action=set 时必填;CLI 不做范围校验,由客户端夹取) |
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 8. favorite song — 收藏歌曲
|
|
259
|
+
|
|
260
|
+
收藏或取消收藏一首歌曲。对应 `POST /v1/favorite`(target_type=song)。
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# 收藏歌曲
|
|
264
|
+
kugou-cli control favorite song --mixsongid 32100650 --song-name "晴天" --singer-name "周杰伦"
|
|
265
|
+
|
|
266
|
+
# 取消收藏
|
|
267
|
+
kugou-cli control favorite song --action remove --mixsongid 32100650
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**参数**:
|
|
271
|
+
|
|
272
|
+
| 参数 | 说明 |
|
|
273
|
+
|------|------|
|
|
274
|
+
| `--action` | 操作(默认 `add`):`add` `remove` |
|
|
275
|
+
| `--mixsongid` | 歌曲 mixsongid(必填) |
|
|
276
|
+
| `--song-name` | 歌曲显示名(可选) |
|
|
277
|
+
| `--singer-name` | 歌手显示名(可选) |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 9. favorite songlist — 收藏歌单
|
|
282
|
+
|
|
283
|
+
收藏或取消收藏一个歌单。对应 `POST /v1/favorite`(target_type=songlist)。
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# 收藏歌单(action=add 时必填 --list-name 与 --owner-user-id)
|
|
287
|
+
kugou-cli control favorite songlist --list-name "精选" --global-collection-id abcdef --owner-user-id 1286024014
|
|
288
|
+
|
|
289
|
+
# 取消收藏(--global-collection-id 必填;--list-name / --owner-user-id 不允许传)
|
|
290
|
+
kugou-cli control favorite songlist --action remove --global-collection-id abcdef
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**参数**:
|
|
294
|
+
|
|
295
|
+
| 参数 | 说明 |
|
|
296
|
+
|------|------|
|
|
297
|
+
| `--action` | 操作(默认 `add`):`add` `remove` |
|
|
298
|
+
| `--global-collection-id` | 歌单全局 ID(即协议层的 `list_gid`,`add` / `remove` 都必填) |
|
|
299
|
+
| `--list-name` | 歌单显示名(**`action=add` 时必填**) |
|
|
300
|
+
| `--owner-user-id` | 歌单所有者 ID(**`action=add` 时必填**;`action=remove` 时不允许传) |
|
|
301
|
+
| `--list-icon` | 歌单图标 URL(可选) |
|
|
302
|
+
| `--list-intro` | 歌单简介(可选) |
|
|
303
|
+
| `--list-tags` | 歌单标签(可选) |
|
|
304
|
+
|
|
305
|
+
> **校验**:CLI 在本地做严格校验,缺任一必填项都会 exit 1 报错:
|
|
306
|
+
> - `--global-collection-id`:**`add` 和 `remove` 两种 action 都必填**(用于标识目标歌单)
|
|
307
|
+
> - `--list-name`:仅 `--action=add` 必填
|
|
308
|
+
> - `--owner-user-id`:仅 `--action=add` 必填;`--action=remove` 时**禁止**传(避免向取消请求带过时元数据)
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 10. playlist create — 创建歌单
|
|
313
|
+
|
|
314
|
+
> ✅ **创建歌单的首选路径**。Agent 在用户同意创建歌单时**必须**先尝试本命令;只有当客户端不可用(Linux / 客户端未运行 / 握手失败 / 调用失败)时才回退到云端备选 [`music create-playlist`](./music.md#71-接口说明云端备选仅在-70-第-4-条任一条件成立时使用)。完整决策逻辑见 [music.md §7 创建歌单](./music.md#7-创建歌单)。
|
|
315
|
+
|
|
316
|
+
在本地客户端创建一个新歌单,并可选地添加歌曲。对应 `POST /v1/songlist/create`。
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
kugou-cli control playlist create --name "周杰伦精选" --mixsongids "32100650,32068120"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**参数**:
|
|
323
|
+
|
|
324
|
+
| 参数 | 说明 |
|
|
325
|
+
|------|------|
|
|
326
|
+
| `--name` | 歌单名称(必填) |
|
|
327
|
+
| `--mixsongids` | 歌曲 mixsongid 列表,逗号分隔(必填,至少含一个有效 ID) |
|
|
328
|
+
|
|
329
|
+
`--mixsongids` 示例:`"32100650,32068120"` 或 `"32100650, 32068120"`(空格会被忽略)。
|
|
330
|
+
|
|
331
|
+
**前置条件**(与 control 其他子命令一致,详见 [§前置条件总结](#前置条件总结)):
|
|
332
|
+
- CLI 已登录(`kugou-cli auth login`)
|
|
333
|
+
- 本地酷狗客户端(Windows / macOS)正在运行且握手健康(`kugou-cli control start`)
|
|
334
|
+
- 客户端内已登录(否则会收到 409/4091 `login required`,见 [§错误场景 2](#场景-2客户端未登录http-409--code-4091))
|
|
335
|
+
|
|
336
|
+
**输出示例**:
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"code": 0,
|
|
340
|
+
"data": {
|
|
341
|
+
"accepted": true,
|
|
342
|
+
"count": 2,
|
|
343
|
+
"global_collection_id": "全局歌单id",
|
|
344
|
+
"name": "歌单名",
|
|
345
|
+
"songlist_id": 123456
|
|
346
|
+
},
|
|
347
|
+
"message": "ok",
|
|
348
|
+
"request_id": "ec-124-1786072145"
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
> **字段语义说明(重要)**:
|
|
353
|
+
> - `data.global_collection_id`:字符串形态的歌单全局 ID(协议层 `list_gid`),**可直接传给 `control play-playlist --global-id`**(详见 [§12 play-playlist](./control.md#12-play-playlist--播放整个歌单))
|
|
354
|
+
> - `data.songlist_id`:数字形态的本地客户端歌单 ID,**不能直接传给 `play-playlist --global-id`**,仅在客户端 UI 内展示用
|
|
355
|
+
>
|
|
356
|
+
> 实际响应字段由客户端版本决定,**两条不一定同时存在**——某些客户端版本可能只返回 `songlist_id` 而无 `global_collection_id`。Agent 在用户同意播放时优先取 `global_collection_id`;若缺失,按下方"ID 流转提示"回退。
|
|
357
|
+
|
|
358
|
+
### 创建成功后必须主动询问用户是否播放
|
|
359
|
+
|
|
360
|
+
> 🎵 **AI 必读**:本命令返回成功(`code: 0`)后,Agent **必须主动询问用户**"是否要播放这个歌单",等用户明确回复后再决定下一步。详见 [music.md §7.0 调用原则 第 5 条](./music.md#70-调用原则ai-必读)。
|
|
361
|
+
|
|
362
|
+
用户同意时优先调用:
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
# 客户端路径:默认清空当前队列、按歌单顺序从头播放
|
|
366
|
+
kugou-cli control play-playlist --global-id "<global_id>"
|
|
367
|
+
|
|
368
|
+
# 不打断当前播放:把新歌单追加到队列尾部
|
|
369
|
+
kugou-cli control play-playlist --global-id "<global_id>" --playlist-mode append_queue
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
> **ID 流转提示**:本命令 `data.songlist_id` 是数字 ID,而 `control play-playlist --global-id` 需要的是字符串 `global_collection_id`(协议层 `list_gid`),二者不可直接互转。Agent 在用户同意播放时按以下顺序获取可用 ID:
|
|
373
|
+
> 1. **优先**:取响应里 `data.global_collection_id`(字符串)→ 直接传给 `play-playlist --global-id`
|
|
374
|
+
> 2. **回退一**:客户端未返回 `global_collection_id` 时,用响应里的歌单名(`data.name`)跑 `kugou-cli music search-playlist "<name>"`,从结果里挑一个匹配的 `global_id` 传给 `play-playlist`
|
|
375
|
+
> 3. **回退二**:以上两步都拿不到时,告诉用户"刚创建的歌单 ID 无法用于播放命令,请在客户端 UI 内打开播放"(**不要**编造或猜 ID)
|
|
376
|
+
> 4. **绝对禁止**:把数字 `songlist_id` 当成 `global_id` 用——类型不匹配,客户端协议层会拒绝
|
|
377
|
+
|
|
378
|
+
> **播放路径全部失败的回退**:若用户同意播放,但客户端仍不可用(control play-playlist 因客户端未运行 / ID 拿不到而失败),Agent **不要**循环重试。按 [music.md §7.2 云端歌单的播放](./music.md#72-云端歌单的播放控制浏览器打开-h5-链接) 走"先探后告知"的浏览器路径:用浏览器工具打开云端 `song_list_url` 尝试点击播放,工具不可用时明确告知用户手动打开。
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## 11. open — 打开客户端页面
|
|
383
|
+
|
|
384
|
+
在酷狗客户端中打开指定页面(非静默,客户端主窗口会切换到对应视图)。对应 `POST /v1/open`。`silent` 字段硬编码为 `false`。
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
# 打开主界面
|
|
388
|
+
kugou-cli control open --target-type main
|
|
389
|
+
|
|
390
|
+
# 打开歌手页
|
|
391
|
+
kugou-cli control open --target-type singer --singer-id 12345
|
|
392
|
+
|
|
393
|
+
# 打开专辑页(可选 --mixsongid 作为专辑根曲)
|
|
394
|
+
kugou-cli control open --target-type album --album-id 67890 --mixsongid 8888
|
|
395
|
+
|
|
396
|
+
# 打开歌单页
|
|
397
|
+
kugou-cli control open --target-type songlist --global-collection-id "collection_3_938985631_304_0"
|
|
398
|
+
|
|
399
|
+
# 打开搜索结果页
|
|
400
|
+
kugou-cli control open --target-type search --keyword "周杰伦"
|
|
401
|
+
|
|
402
|
+
# 打开指定 URL
|
|
403
|
+
kugou-cli control open --target-type url --url "https://www.kugou.com/"
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**target-type 和必填参数**:
|
|
407
|
+
|
|
408
|
+
| target-type | 必填参数 | 说明 |
|
|
409
|
+
|-------------|----------|------|
|
|
410
|
+
| `main` | 无 | 打开主界面 |
|
|
411
|
+
| `singer` | `--singer-id` | 歌手页 |
|
|
412
|
+
| `album` | `--album-id` | 专辑页 |
|
|
413
|
+
| `songlist` | `--global-collection-id` | 歌单页(协议 wire 字段 `list_gid`) |
|
|
414
|
+
| `search` | `--keyword` | 搜索结果页 |
|
|
415
|
+
| `url` | `--url` | 指定 URL |
|
|
416
|
+
|
|
417
|
+
**通用可选参数**:
|
|
418
|
+
|
|
419
|
+
| 参数 | 说明 |
|
|
420
|
+
|------|------|
|
|
421
|
+
| `--mixsongid` | 可选 mixsongid(如 `album` 时作为专辑根曲) |
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## 12. play-playlist — 播放整个歌单
|
|
426
|
+
|
|
427
|
+
按歌单的 `global_collection_id`(即协议层的 `list_gid`)让本地酷狗客户端联网拉歌单后播放。本命令只传 `list_gid` 给客户端,**无需 CLI 端联网预翻页**——歌单内容由客户端在收到请求后异步拉取(CLI 不需要外网/代理)。
|
|
428
|
+
|
|
429
|
+
**`--global-id` 的合法来源**(按推荐顺序):
|
|
430
|
+
|
|
431
|
+
1. **`music search-playlist` / `recommend-playlist` 响应的 `global_id` 字段**(最稳,跨客户端兼容)
|
|
432
|
+
2. **`control playlist create` 响应的 `data.global_collection_id` 字段**(仅当客户端版本返回该字段时可用——见 [§10 输出字段语义](./control.md#10-playlist-create--创建歌单))
|
|
433
|
+
3. `music playlist-songs <global_collection_id>` 直接使用你已有的字符串 ID
|
|
434
|
+
|
|
435
|
+
**不要**:把 `control playlist create` 响应里的数字 `data.songlist_id` 当成 `global-id` 用(类型不匹配,会被客户端协议层拒绝)。
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
# 默认:清空当前队列,按歌单顺序从头播放
|
|
439
|
+
kugou-cli control play-playlist --global-id "collection_3_938985631_304_0"
|
|
440
|
+
|
|
441
|
+
# 不打断当前播放:歌单追加到队列尾部
|
|
442
|
+
kugou-cli control play-playlist --global-id "..." --playlist-mode append_queue
|
|
443
|
+
|
|
444
|
+
# 把歌单插到当前曲目之后立即播放
|
|
445
|
+
kugou-cli control play-playlist --global-id "..." --playlist-mode next_play
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**参数**:
|
|
449
|
+
|
|
450
|
+
| 参数 | 说明 |
|
|
451
|
+
|------|------|
|
|
452
|
+
| `--global-id` | 歌单全局 ID(必填),即协议层的 `list_gid`,例如 `collection_3_938985631_304_0`。必须是字符串(不要传数字 `songlist_id`)|
|
|
453
|
+
| `--playlist-mode` | 队列策略:`auto`(默认)/ `append_queue` / `next_play` |
|
|
454
|
+
|
|
455
|
+
**playlist-mode 详解**:
|
|
456
|
+
|
|
457
|
+
| 取值 | wire 上的 `play_mode` | 客户端行为 | 适用场景 |
|
|
458
|
+
|------|----------------------|----------|----------|
|
|
459
|
+
| `auto`(默认) | **省略** | 客户端默认 = 清空当前队列后按歌单顺序从头播放 | 切到歌单里从头听 |
|
|
460
|
+
| `append_queue` | `"append_queue"` | 歌单追加到播放队列尾部,不打断当前播放 | 不打断当前歌曲,排队播放 |
|
|
461
|
+
| `next_play` | `"next_play"` | 歌单插入到当前曲目之后立即播放,后续队列顺延 | 听完这首就想听歌单 |
|
|
462
|
+
|
|
463
|
+
**请求协议**:
|
|
464
|
+
|
|
465
|
+
1. CLI 组装一次请求体,仅含 `list_gid`(默认模式不含 `play_mode`):
|
|
466
|
+
```json
|
|
467
|
+
{ "list_gid": "collection_3_938985631_304_0" }
|
|
468
|
+
```
|
|
469
|
+
2. `POST /v1/player/play` 单次请求发给本地客户端。该接口为**异步**:本地客户端在收到请求后联网拉歌单歌曲,待拉取完成后才回复 HTTP 响应。CLI 端无需等待联网。
|
|
470
|
+
3. 失败(HTTP 非 200 或传输错误)→ stderr 报错并 exit 1。**HTTP 状态码与 body 子码区分**:
|
|
471
|
+
- HTTP 状态码(如 `400` / `500`):CLI 打印 `HTTP <code>` 到 stderr
|
|
472
|
+
- 响应 body 的 `code` 子码(如 `4000` / `5001`):CLI 透传 body 到 stdout,由调用方解析;CLI 自身只判断 HTTP 状态
|
|
473
|
+
- 常见场景:
|
|
474
|
+
- `HTTP 400`(body 可能含 `code: 4000` `missing songs`):客户端未传 `list_gid` 也没传 `songs`(CLI 几乎不会触发)
|
|
475
|
+
- `HTTP 500`(body 可能含 `code: 5001`):客户端拉歌单失败(网络/歌单不存在/内容为空/能力不可用)
|
|
476
|
+
- 其它 5xx:客户端拒绝,错误信息原样输出到 stderr
|
|
477
|
+
|
|
478
|
+
> **无数量上限**:本命令对 `list_gid` 没有大小限制,由客户端协议层自行分页。超大歌单若被客户端拒绝,错误原样输出到 stderr。
|
|
479
|
+
|
|
480
|
+
**前置条件**:
|
|
481
|
+
|
|
482
|
+
- 已登录:`kugou-cli auth login`
|
|
483
|
+
- 酷狗桌面客户端在后台运行,且握手健康:`kugou-cli control start`
|
|
484
|
+
- **不需要联网**:歌单内容由本地客户端在响应 `POST /v1/player/play` 后异步拉取(只要客户端本身能访问外网即可)
|
|
485
|
+
|
|
486
|
+
**典型联动**:
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
# 搜歌单 → 取 global_id → 播放
|
|
490
|
+
GID=$(kugou-cli music search-playlist "周杰伦" | jq -r '.data.list[0].global_id')
|
|
491
|
+
kugou-cli control play-playlist --global-id "$GID"
|
|
492
|
+
|
|
493
|
+
# 立即听下一首(不打断当前曲目)
|
|
494
|
+
kugou-cli control play-playlist --global-id "$GID" --playlist-mode next_play
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## 错误场景
|
|
500
|
+
|
|
501
|
+
### 场景 1:CLI 未登录(登录态缺失)
|
|
502
|
+
|
|
503
|
+
未登录时,任意 `control` 子命令都会在入口被拦截。
|
|
504
|
+
|
|
505
|
+
**触发**:
|
|
506
|
+
```bash
|
|
507
|
+
kugou-cli control status
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**stderr**:
|
|
511
|
+
```
|
|
512
|
+
kugou-cli control: not logged in, run `kugou-cli auth login` first: auth file not found
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**stdout**: 无
|
|
516
|
+
|
|
517
|
+
**exit code**: 1
|
|
518
|
+
|
|
519
|
+
**修复**: 运行 `kugou-cli auth login` 完成 CLI 扫码登录。
|
|
520
|
+
|
|
521
|
+
---
|
|
522
|
+
|
|
523
|
+
### 场景 2:客户端未登录(HTTP 409 / code: 4091)
|
|
524
|
+
|
|
525
|
+
`favorite song`、`favorite songlist`、`playlist create` 等需要账号的操作,如果客户端本身未登录(cookie/token 过期或从未登录),协议层返回 `code: 4091`。
|
|
526
|
+
|
|
527
|
+
**触发**:
|
|
528
|
+
```bash
|
|
529
|
+
kugou-cli control favorite song --mixsongid 32100650
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**stdout**(协议响应原样输出):
|
|
533
|
+
```json
|
|
534
|
+
{"code":4091,"msg":"login required"}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
**stderr**(CLI 追加的提示):
|
|
538
|
+
```
|
|
539
|
+
HTTP 409
|
|
540
|
+
请在酷狗客户端内登录后重试
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
**exit code**: 0(CLI 正常退出,调用方从 stdout 的 `code` 字段自行判断)
|
|
544
|
+
|
|
545
|
+
**注意**: CLI 不会 exit 1,也不会提示去运行 `kugou-cli auth login`(那是 CLI 登录,跟客户端登录是两件独立的事)。
|
|
546
|
+
|
|
547
|
+
**修复**: 在酷狗客户端 UI 内扫码登录客户端。
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
### 场景 3:客户端未安装或未启动(握手超时)
|
|
552
|
+
|
|
553
|
+
握手在 6 秒内未完成,说明酷狗客户端未安装、未运行或未响应 URL scheme 唤起。
|
|
554
|
+
|
|
555
|
+
**触发**:
|
|
556
|
+
```bash
|
|
557
|
+
kugou-cli control status
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
(假设客户端未运行)
|
|
561
|
+
|
|
562
|
+
**stderr**:
|
|
563
|
+
```
|
|
564
|
+
is Kugou client installed?
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**stdout**: 无
|
|
568
|
+
|
|
569
|
+
**exit code**: 1
|
|
570
|
+
|
|
571
|
+
**排查步骤**:
|
|
572
|
+
1. 确认酷狗客户端已安装(Windows: `KuGou.exe`,Mac: `/Applications/KuGou.app`)
|
|
573
|
+
2. 确认客户端已启动并运行
|
|
574
|
+
3. Windows 用户确认 URL scheme `kugou://` 已注册(可在 PowerShell 中试 `start kugou://workbuddy`)
|
|
575
|
+
4. Mac 用户在 Safari 地址栏试 `mackugou://workbuddy` 确认 LaunchServices 注册正常
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
### 场景 4:Linux 不支持
|
|
580
|
+
|
|
581
|
+
在非 Windows / macOS 系统上运行任意 `control` 子命令,会被运行时拦截。
|
|
582
|
+
|
|
583
|
+
**触发**(在 Linux 上):
|
|
584
|
+
```bash
|
|
585
|
+
kugou-cli control status
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
**stderr**:
|
|
589
|
+
```
|
|
590
|
+
kugou-cli control: linux is not supported
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
**stdout**: 无
|
|
594
|
+
|
|
595
|
+
**exit code**: 1
|
|
596
|
+
|
|
597
|
+
**说明**: 酷狗客户端仅提供 Windows 和 macOS 版本,因此 control 命令也仅在这两个平台可用。所有非 Windows/macOS 系统都会被拒绝,包括 Linux、FreeBSD、OpenBSD 等。
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## 典型 AI Agent 工作流
|
|
602
|
+
|
|
603
|
+
以下为通过 `control` 命令控制本地酷狗客户端的典型流程。
|
|
604
|
+
|
|
605
|
+
### 完整示例:搜索并播放歌曲
|
|
606
|
+
|
|
607
|
+
```
|
|
608
|
+
# 1. 搜索歌曲(music 命令,返回 mix_song_id)
|
|
609
|
+
$ kugou-cli music search "周杰伦 晴天"
|
|
610
|
+
{
|
|
611
|
+
"data": {
|
|
612
|
+
"list": [{
|
|
613
|
+
"song_name": "晴天",
|
|
614
|
+
"mix_song_id": "32100650",
|
|
615
|
+
"artist_name": "周杰伦"
|
|
616
|
+
}]
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
# 2. 让客户端播放这首歌
|
|
621
|
+
$ kugou-cli control play --mixsongid 32100650 --song-name "晴天" --singer-name "周杰伦"
|
|
622
|
+
{"code":0,"data":{"accepted":true}}
|
|
623
|
+
|
|
624
|
+
# 3. 暂停播放
|
|
625
|
+
$ kugou-cli control player --action pause
|
|
626
|
+
{"code":0,"data":{"accepted":true}}
|
|
627
|
+
|
|
628
|
+
# 4. 查看当前播放状态
|
|
629
|
+
$ kugou-cli control current
|
|
630
|
+
{
|
|
631
|
+
"code": 0,
|
|
632
|
+
"data": {
|
|
633
|
+
"song_name": "晴天",
|
|
634
|
+
"position_ms": 30000,
|
|
635
|
+
"volume": 65
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
# 5. 收藏当前歌曲
|
|
640
|
+
$ kugou-cli control favorite song --mixsongid 32100650
|
|
641
|
+
{"code":0,"data":{"accepted":true}}
|
|
642
|
+
|
|
643
|
+
# 6. 搜索更多歌曲并创建歌单
|
|
644
|
+
$ kugou-cli music search "周杰伦"
|
|
645
|
+
# 假设返回多个结果,mix_song_id 分别为 32100650、32068120、31598745
|
|
646
|
+
|
|
647
|
+
$ kugou-cli control playlist create --name "周杰伦精选" --mixsongids "32100650,32068120,31598745"
|
|
648
|
+
{"code":0,"data":{"songlist_id":"abc123","name":"周杰伦精选","count":3}}
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
### 与 music 命令的配合
|
|
652
|
+
|
|
653
|
+
`music search` 返回的 `mix_song_id`(或 `mix_song_id`)可直接传给 `control play --mixsongid`,无需任何 ID 转换。
|
|
654
|
+
|
|
655
|
+
```
|
|
656
|
+
music search "歌手" → 提取 mix_song_id → control play --mixsongid <id>
|
|
657
|
+
→ control favorite song --mixsongid <id>
|
|
658
|
+
→ control playlist create --mixsongids <id1>,<id2>
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
---
|
|
662
|
+
|
|
663
|
+
## 前置条件总结
|
|
664
|
+
|
|
665
|
+
| 条件 | 说明 |
|
|
666
|
+
|------|------|
|
|
667
|
+
| CLI 已登录 | `kugou-cli auth login`(扫码登录,存储登录态) |
|
|
668
|
+
| 酷狗客户端运行中 | 客户端内置 HTTP server 必须启动(`control start` 会自动触发) |
|
|
669
|
+
| 客户端已登录 | 在酷狗客户端 UI 内扫码登录(影响 `favorite`/`playlist create` 等操作) |
|
|
670
|
+
| Windows / macOS | Linux 不支持(运行时检查) |
|
|
671
|
+
|
|
672
|
+
---
|
|
673
|
+
|
|
674
|
+
## 相关文档
|
|
675
|
+
|
|
676
|
+
- [references/output-format.md](./output-format.md) — 输出格式与展示规范
|
|
677
|
+
- [references/music.md](./music.md) — music 命令使用指南
|
|
678
|
+
- [references/auth.md](./auth.md) — auth 命令使用指南
|
|
679
|
+
|
|
680
|
+
> 客户端协议规范由酷狗客户端内部定义,不在用户可访问的文档范围内。本文档只描述 CLI 端可观察的行为。
|
|
@@ -13,10 +13,10 @@ echo $? # 非 0 表示出错
|
|
|
13
13
|
|
|
14
14
|
| 错误信息 | 原因 | 处理方式 |
|
|
15
15
|
|---------|------|---------|
|
|
16
|
-
| `账号登录过期,请重新登录` |
|
|
16
|
+
| `账号登录过期,请重新登录` | 登录态已过期(errcode 语义由上游约定)。CLI 已**自动**清理本地登录态 | 引导用户重新登录:`kugou-cli auth login`(扫码)或 `kugou-cli auth set-secret "<新 secret>"` |
|
|
17
17
|
| `not logged in` / `auth file not found` | 未登录 | 引导用户执行 `kugou-cli auth login` |
|
|
18
18
|
| `HTTP error: 400` | 请求参数有误 | 检查命令参数是否正确 |
|
|
19
19
|
| `HTTP error: 500` | 服务端错误 | 稍后重试,或告知用户 |
|
|
20
|
-
| `API error:
|
|
20
|
+
| `API error: <errmsg> (code=<N>)` | 业务错误(上游 errcode ≠ 0) | 根据 errmsg 提示用户 |
|
|
21
21
|
| `network error: ...` | 网络连接问题 | 检查网络,可尝试 `--proxy` |
|
|
22
|
-
| `failed to get device info` |
|
|
22
|
+
| `failed to get device info` | 设备信息获取失败(仅 control) | 运行时环境异常,检查权限 |
|