@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.
@@ -1,323 +1,526 @@
1
- # 音乐命令 (music)
2
-
3
- > 🔐 = 所有 music 命令都需要先登录
4
-
5
- ## 命令列表
6
-
7
- | 命令 | 说明 |
8
- |------|------|
9
- | `kugou-cli music search <keyword>` | 搜索歌曲 |
10
- | `kugou-cli music recommend daily` | 每日推荐 |
11
- | `kugou-cli music recommend similar -s <song>` | 相似歌曲推荐 |
12
- | `kugou-cli music favorites` | 我的收藏 |
13
- | `kugou-cli music recent` | 最近播放 |
14
- | `kugou-cli music stats` | 听歌统计 |
15
- | `kugou-cli music charts <rank_id>` | 榜单 |
16
- | `kugou-cli music create-playlist <name>` | 创建歌单(可附加歌曲) |
17
-
18
- ---
19
-
20
- ## 1. 搜索歌曲
21
-
22
- ```bash
23
- kugou-cli music search "周杰伦"
24
- kugou-cli music search "周杰伦" --page 1 --size 20
25
- ```
26
-
27
- **参数**:
28
- - `<keyword>`: 搜索关键词(必填)
29
- - `--page`: 页码,默认 1
30
- - `--size`: 每页数量,默认 20
31
-
32
- **输出示例**:
33
- ```json
34
- {
35
- "errcode": 0,
36
- "data": {
37
- "list": [
38
- {
39
- "song_name": "晴天",
40
- "mix_song_id": "32100650",
41
- "artist_name": "周杰伦",
42
- "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
43
- }
44
- ],
45
- "total": 480,
46
- "page": 1,
47
- "size": 20
48
- },
49
- "status": 1
50
- }
51
- ```
52
-
53
- ---
54
-
55
- ## 2. 歌曲推荐
56
-
57
- 支持三种推荐模式:
58
-
59
- | 类型 | 说明 | 必填参数 |
60
- |------|------|---------|
61
- | `guess` | 猜你喜欢,基于用户喜好推荐 | 无 |
62
- | `similar` | 相似推荐,根据指定歌曲推荐相似歌曲 | `--song` |
63
- | `text` | 文本推歌,根据文本描述推荐歌曲 | `--text` |
64
-
65
- ### 2.1 猜你喜欢
66
-
67
- ```bash
68
- kugou-cli music recommend guess
69
- kugou-cli music recommend guess --num 10
70
- ```
71
-
72
- **参数**:
73
- - `--num`: 推荐数量,默认 10
74
-
75
- ### 2.2 相似推荐
76
-
77
- ```bash
78
- kugou-cli music recommend similar -s "晴天"
79
- kugou-cli music recommend similar --song "晴天" -n 5
80
- kugou-cli music recommend similar --song "晴天" --text "风格相似的" -n 5
81
- ```
82
-
83
- **参数**:
84
- - `-s, --song`: 歌曲名称(必填)
85
- - `-n, --num`: 推荐数量,默认 10
86
- - `-t, --text`: 描述文本(可选),用于进一步细化相似方向
87
-
88
- ### 2.3 文本推歌
89
-
90
- ```bash
91
- kugou-cli music recommend text --text "适合跑步时听的快节奏歌曲"
92
- kugou-cli music recommend text --text "安静的钢琴曲" --num 5
93
- ```
94
-
95
- **参数**:
96
- - `-t, --text`: 文本描述(必填)
97
- - `-n, --num`: 推荐数量,默认 10
98
-
99
- **输出示例**:
100
- ```json
101
- {
102
- "errcode": 0,
103
- "data": {
104
- "list": [
105
- {
106
- "song_name": "稻香",
107
- "mix_song_id": "8889",
108
- "artist_name": "周杰伦",
109
- "play_link": "https://www.kugou.com/mixsong/agent_gateway/xxx.html"
110
- }
111
- ]
112
- },
113
- "status": 1
114
- }
115
- ```
116
-
117
- ---
118
-
119
- ## 4. 我的收藏
120
-
121
- ```bash
122
- kugou-cli music favorites
123
- kugou-cli music favorites --page 1 --size 20
124
- ```
125
-
126
- **参数**:
127
- - `--page`: 页码,默认 1
128
- - `--size`: 每页数量,默认 20
129
-
130
- > 注意:固定返回最近 10 首收藏,查看更多请前往酷狗App
131
-
132
- **输出示例**:
133
- ```json
134
- {
135
- "errcode": 0,
136
- "data": {
137
- "list": [
138
- {
139
- "song_name": "晴天",
140
- "mix_song_id": "32100650",
141
- "artist_name": "周杰伦",
142
- "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
143
- }
144
- ],
145
- "total": 50,
146
- "msg": "当前仅显示最近的10首收藏,查看更多内容,请前往酷狗App"
147
- },
148
- "status": 1
149
- }
150
- ```
151
-
152
- ---
153
-
154
- ## 5. 最近播放
155
-
156
- ```bash
157
- kugou-cli music recent
158
- kugou-cli music recent --page 1 --size 20
159
- ```
160
-
161
- **参数**:
162
- - `--page`: 页码,默认 1
163
- - `--size`: 每页数量,默认 20
164
-
165
- > 注意:固定返回最近 10 首播放记录,查看更多请前往酷狗App
166
-
167
- **输出示例**:
168
- ```json
169
- {
170
- "errcode": 0,
171
- "data": {
172
- "list": [
173
- {
174
- "song_name": "七里香",
175
- "mix_song_id": "32100651",
176
- "artist_name": "周杰伦",
177
- "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
178
- }
179
- ],
180
- "total": 100,
181
- "msg": "当前仅显示最近的10首最近播放,查看更多内容,请前往酷狗App"
182
- },
183
- "status": 1
184
- }
185
- ```
186
-
187
- ---
188
-
189
- ## 6. 听歌统计
190
-
191
- ```bash
192
- kugou-cli music stats # 默认查当月
193
- kugou-cli music stats --date-type 1 --date 20260501 # 指定周查询
194
- ```
195
-
196
- **参数**:
197
- - `--date-type`: 日期类型,0=日、1=周、2=月,默认 2(月)
198
- - `--date`: 查询日期,YYYYMMDD 格式,如 "20260501"(不填默认当月第一天)
199
- - 日类型:每天日期,如 "20260501"
200
- - 周类型:必须是周一日期,如 "20260505"(周一)
201
- - 月类型:必须是月份第一天,如 "20260501"(5月1日)
202
-
203
- **输出示例**:
204
- ```json
205
- {
206
- "errcode": 0,
207
- "data": {
208
- "server_time": 1779977674,
209
- "listen_duration": 80776,
210
- "accumulate_listen_days": 30,
211
- "continue_listen_days": 7,
212
- "listen_total": 342,
213
- "last_listen_total": 387,
214
- "top_clocks": [
215
- "今日08:00-10:00听歌30分钟",
216
- "今日14:00-16:00听歌25分钟",
217
- "今日20:00-22:00听歌20分钟"
218
- ],
219
- "rank_song": [
220
- {
221
- "song_info": {"song_name": "晴天", "mix_song_id": "8888", "artist_name": "周杰伦", "play_link": "https://www.kugou.com/..."},
222
- "count": 50
223
- }
224
- ],
225
- "rank_singer": [
226
- {"singer_id": 123, "name": "周杰伦", "avatar": "https://xxx.jpg", "total": 120}
227
- ],
228
- "rank_style": [
229
- {"style": "流行", "total": 200, "count": 80}
230
- ],
231
- "rank_language": [
232
- {"language": "华语", "total": 400, "count": 150}
233
- ]
234
- },
235
- "status": 1
236
- }
237
- ```
238
-
239
- **关键字段**:
240
- - `listen_duration`: 今日/周/月听歌时长(秒)
241
- - `top_clocks`: 听歌时长最长的 Top3 时段描述(日类型格式如"今日08:00-10:00听歌30分钟",周/月类型格式如"2026-02月听歌38213分钟")
242
- - `accumulate_listen_days`: 累计听歌天数
243
- - `continue_listen_days`: 连续听歌天数
244
- - `listen_total`: 累计听歌次数
245
- - `last_listen_total`: 昨日/上周/上月听歌次数
246
- - `rank_song`: 播放最多的歌曲排行(`count` 为播放次数)
247
- - `rank_singer`: 播放最多的歌手排行
248
- - `rank_style`: 曲风分布统计
249
- - `rank_language`: 语言分布统计
250
-
251
- ---
252
-
253
- ## 7. 榜单
254
-
255
- ```bash
256
- kugou-cli music charts 6666
257
- kugou-cli music charts 52144 --page 1 --size 20
258
- ```
259
-
260
- **可用榜单 ID**:
261
-
262
- | rank_id | 榜单名称 |
263
- |---------|----------|
264
- | 8888 | TOP500榜 |
265
- | 90379 | 星耀星光榜 |
266
- | 6666 | 飙升榜 |
267
- | 85432 | 百万收藏榜 |
268
- | 74534 | 新歌榜 |
269
- | 52144 | 抖音热歌酷狗榜 |
270
-
271
- **参数**:
272
- - `<rank_id>`: 榜单 ID(必填)
273
- - `--page`: 页码,默认 1
274
- - `--size`: 每页数量,默认 20
275
-
276
- ---
277
-
278
- ## 8. 创建歌单
279
-
280
- > 🔐 = 需要先登录
281
-
282
- ### 调用原则(AI 必读)
283
-
284
- 1. **被动调用**:必须用户**明确**要求创建歌单时才调用本命令,禁止在用户仅说"推荐/搜歌/听歌"时主动创建
285
- 2. **主动询问**:当通过搜索、推荐(猜你喜欢/相似/文本)等方式给出一批歌曲后,**必须**询问用户"是否需要将当前这批歌曲创建为歌单",等用户确认后再执行 `create-playlist --songs "<mix_song_id 列表>"`
286
- 3. **示例化推荐**:询问时建议给出歌单名建议(如"跑步歌单"、"周杰伦精选"),让用户更容易确认
287
-
288
- ### 接口说明
289
-
290
- 创建一个新的自建歌单,并可选择在创建后往歌单里添加歌曲。
291
-
292
- ```bash
293
- # 创建空歌单
294
- kugou-cli music create-playlist "我的空歌单"
295
-
296
- # 创建歌单并添加歌曲
297
- kugou-cli music create-playlist "我的批量歌单" --songs "123,456,789"
298
- ```
299
-
300
- **参数**:
301
- - `<name>`: 歌单名称(必填)
302
- - `--songs`: 待添加的歌曲 mix_song_id 列表,逗号分隔(可选)。不传则只创建空歌单
303
-
304
- **输出示例**:
305
- ```json
306
- {
307
- "errcode": 0,
308
- "errmsg": "",
309
- "data": {
310
- "name": "我的批量歌单",
311
- "song_list_url": "https://m.kugou.com/songlist/gcid_abc123def45"
312
- },
313
- "status": 1
314
- }
315
- ```
316
-
317
- **关键字段**:
318
- - `name`: 歌单名称
319
- - `song_list_url`: 歌单播放地址(H5 链接),可分享给用户打开
320
-
321
- **异常说明**:
322
- - 歌单创建成功但添加歌曲失败:返回 200 状态 + 错误信息,body 仍包含已创建歌单的 `name` 与 `song_list_url`
323
- - 歌单创建失败:返回对应错误码(参数错误 20010 / 网络错误 90000 等)
1
+ # 音乐命令 (music)
2
+
3
+ > 🔐 = 所有 music 命令都需要先登录
4
+
5
+ ## 命令列表
6
+
7
+ | 命令 | 说明 |
8
+ |------|------|
9
+ | `kugou-cli music search <keyword>` | 搜索歌曲 |
10
+ | `kugou-cli music recommend guess` | 猜你喜欢(个性化推荐) |
11
+ | `kugou-cli music recommend similar -s <song>` | 相似歌曲推荐 |
12
+ | `kugou-cli music favorites` | 我的收藏 |
13
+ | `kugou-cli music recent` | 最近播放 |
14
+ | `kugou-cli music stats` | 听歌统计 |
15
+ | `kugou-cli music charts <rank_id>` | 榜单 |
16
+ | `kugou-cli music create-playlist <name>` | 创建歌单(可附加歌曲) |
17
+ | `kugou-cli music search-playlist <keyword>` | 搜索歌单 |
18
+ | `kugou-cli music recommend-playlist` | 歌单推荐 |
19
+ | `kugou-cli music playlist-songs <global_collection_id>` | 歌单内歌曲列表 |
20
+
21
+ ---
22
+
23
+ ## 1. 搜索歌曲
24
+
25
+ ```bash
26
+ kugou-cli music search "周杰伦"
27
+ kugou-cli music search "周杰伦" --page 1 --size 20
28
+ ```
29
+
30
+ **参数**:
31
+ - `<keyword>`: 搜索关键词(必填)
32
+ - `--page`: 页码,默认 1
33
+ - `--size`: 每页数量,默认 20
34
+
35
+ **输出示例**:
36
+ ```json
37
+ {
38
+ "errcode": 0,
39
+ "data": {
40
+ "list": [
41
+ {
42
+ "song_name": "晴天",
43
+ "mix_song_id": "32100650",
44
+ "artist_name": "周杰伦",
45
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
46
+ }
47
+ ],
48
+ "total": 480,
49
+ "page": 1,
50
+ "size": 20
51
+ },
52
+ "status": 1
53
+ }
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 2. 歌曲推荐
59
+
60
+ 支持三种推荐模式:
61
+
62
+ | 类型 | 说明 | 必填参数 |
63
+ |------|------|---------|
64
+ | `guess` | 猜你喜欢,基于用户喜好推荐 | 无 |
65
+ | `similar` | 相似推荐,根据指定歌曲推荐相似歌曲 | `--song` |
66
+ | `text` | 文本推歌,根据文本描述推荐歌曲 | `--text` |
67
+
68
+ ### 2.1 猜你喜欢
69
+
70
+ ```bash
71
+ kugou-cli music recommend guess
72
+ kugou-cli music recommend guess --num 10
73
+ ```
74
+
75
+ **参数**:
76
+ - `--num`: 推荐数量,默认 10
77
+
78
+ ### 2.2 相似推荐
79
+
80
+ ```bash
81
+ kugou-cli music recommend similar -s "晴天"
82
+ kugou-cli music recommend similar --song "晴天" -n 5
83
+ kugou-cli music recommend similar --song "晴天" --text "风格相似的" -n 5
84
+ ```
85
+
86
+ **参数**:
87
+ - `-s, --song`: 歌曲名称(必填)
88
+ - `-n, --num`: 推荐数量,默认 10
89
+ - `-t, --text`: 描述文本(可选),用于进一步细化相似方向
90
+
91
+ ### 2.3 文本推歌
92
+
93
+ ```bash
94
+ kugou-cli music recommend text --text "适合跑步时听的快节奏歌曲"
95
+ kugou-cli music recommend text --text "安静的钢琴曲" --num 5
96
+ ```
97
+
98
+ **参数**:
99
+ - `-t, --text`: 文本描述(必填)
100
+ - `-n, --num`: 推荐数量,默认 10
101
+
102
+ **输出示例**:
103
+ ```json
104
+ {
105
+ "errcode": 0,
106
+ "data": {
107
+ "list": [
108
+ {
109
+ "song_name": "稻香",
110
+ "mix_song_id": "8889",
111
+ "artist_name": "周杰伦",
112
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/xxx.html"
113
+ }
114
+ ]
115
+ },
116
+ "status": 1
117
+ }
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 3. 我的收藏
123
+
124
+ ```bash
125
+ kugou-cli music favorites
126
+ ```
127
+
128
+ **参数**: 无(上游接口固定返回最近 10 首收藏,不支持分页)
129
+
130
+ > 注意:固定返回最近 10 首收藏,查看更多请前往酷狗App
131
+
132
+ **输出示例**:
133
+ ```json
134
+ {
135
+ "errcode": 0,
136
+ "data": {
137
+ "list": [
138
+ {
139
+ "song_name": "晴天",
140
+ "mix_song_id": "32100650",
141
+ "artist_name": "周杰伦",
142
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
143
+ }
144
+ ],
145
+ "total": 50,
146
+ "msg": "当前仅显示最近的10首收藏,查看更多内容,请前往酷狗App"
147
+ },
148
+ "status": 1
149
+ }
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 4. 最近播放
155
+
156
+ ```bash
157
+ kugou-cli music recent
158
+ ```
159
+
160
+ **参数**: 无(上游接口固定返回最近 10 条播放记录,不支持分页)
161
+
162
+ > 注意:固定返回最近 10 首播放记录,查看更多请前往酷狗App
163
+
164
+ **输出示例**:
165
+ ```json
166
+ {
167
+ "errcode": 0,
168
+ "data": {
169
+ "list": [
170
+ {
171
+ "song_name": "七里香",
172
+ "mix_song_id": "32100651",
173
+ "artist_name": "周杰伦",
174
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
175
+ }
176
+ ],
177
+ "total": 100,
178
+ "msg": "当前仅显示最近的10首最近播放,查看更多内容,请前往酷狗App"
179
+ },
180
+ "status": 1
181
+ }
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 5. 听歌统计
187
+
188
+ ```bash
189
+ kugou-cli music stats # 默认查当月
190
+ kugou-cli music stats --date-type 1 --date 20260501 # 指定周查询
191
+ ```
192
+
193
+ **参数**:
194
+ - `--date-type`: 日期类型,0=日、1=周、2=月(默认查当月)
195
+ - `--date`: 查询日期,YYYYMMDD 格式,如 "20260501"。不传则查当月
196
+ - 日类型:每天日期,如 "20260501"
197
+ - 周类型:必须是周一日期,如 "20260505"(周一)
198
+ - 月类型:必须是月份第一天,如 "20260501"(5月1日)
199
+
200
+ **输出示例**:
201
+ ```json
202
+ {
203
+ "errcode": 0,
204
+ "data": {
205
+ "server_time": 1779977674,
206
+ "listen_duration": 80776,
207
+ "accumulate_listen_days": 30,
208
+ "continue_listen_days": 7,
209
+ "listen_total": 342,
210
+ "last_listen_total": 387,
211
+ "top_clocks": [
212
+ "今日08:00-10:00听歌30分钟",
213
+ "今日14:00-16:00听歌25分钟",
214
+ "今日20:00-22:00听歌20分钟"
215
+ ],
216
+ "rank_song": [
217
+ {
218
+ "song_info": {"song_name": "晴天", "mix_song_id": "8888", "artist_name": "周杰伦", "play_link": "https://www.kugou.com/..."},
219
+ "count": 50
220
+ }
221
+ ],
222
+ "rank_singer": [
223
+ {"singer_id": 123, "name": "周杰伦", "avatar": "https://xxx.jpg", "total": 120}
224
+ ],
225
+ "rank_style": [
226
+ {"style": "流行", "total": 200, "count": 80}
227
+ ],
228
+ "rank_language": [
229
+ {"language": "华语", "total": 400, "count": 150}
230
+ ]
231
+ },
232
+ "status": 1
233
+ }
234
+ ```
235
+
236
+ **关键字段**:
237
+ - `listen_duration`: 今日/周/月听歌时长(秒)
238
+ - `top_clocks`: 听歌时长最长的 Top3 时段描述(日类型格式如"今日08:00-10:00听歌30分钟",周/月类型格式如"2026-02月听歌38213分钟")
239
+ - `accumulate_listen_days`: 累计听歌天数
240
+ - `continue_listen_days`: 连续听歌天数
241
+ - `listen_total`: 累计听歌次数
242
+ - `last_listen_total`: 昨日/上周/上月听歌次数
243
+ - `rank_song`: 播放最多的歌曲排行(`count` 为播放次数)
244
+ - `rank_singer`: 播放最多的歌手排行
245
+ - `rank_style`: 曲风分布统计
246
+ - `rank_language`: 语言分布统计
247
+
248
+ ---
249
+
250
+ ## 6. 榜单
251
+
252
+ ```bash
253
+ kugou-cli music charts 6666
254
+ kugou-cli music charts 52144 --page 1 --size 20
255
+ ```
256
+
257
+ **可用榜单 ID**:
258
+
259
+ | rank_id | 榜单名称 |
260
+ |---------|----------|
261
+ | 8888 | TOP500榜 |
262
+ | 90379 | 星耀星光榜 |
263
+ | 6666 | 飙升榜 |
264
+ | 85432 | 百万收藏榜 |
265
+ | 74534 | 新歌榜 |
266
+ | 52144 | 抖音热歌酷狗榜 |
267
+
268
+ **参数**:
269
+ - `<keyword>`: 搜索关键词(必填)
270
+ - `--page`: 页码,默认 1(**无简写**)
271
+ - `--size`: 每页数量,默认 20(**无简写**)
272
+
273
+ ---
274
+
275
+ ## 7. 创建歌单
276
+
277
+ > 🔐 = 需要先登录(CLI 登录 `auth login` / `auth set-secret`)
278
+
279
+ ### 7.0 调用原则(AI 必读)
280
+
281
+ 1. **被动调用**:必须用户**明确**要求创建歌单时才调用,禁止在用户仅说"推荐/搜歌/听歌"时主动创建
282
+ 2. **主动询问**:当通过搜索、推荐(猜你喜欢/相似/文本)等方式给出一批歌曲后,**必须**询问用户"是否需要将当前这批歌曲创建为歌单",等用户确认后再调用
283
+ 3. **示例化推荐**:询问时建议给出歌单名建议(如"跑步歌单"、"周杰伦精选"),让用户更容易确认
284
+ 4. **硬性默认:优先客户端创建**:用户一旦同意创建歌单,**必须先尝试** [`control playlist create`](./control.md#10-playlist-create--创建歌单)(在本地酷狗客户端内创建)。当以下**任一**条件成立时,回退到本节的 `music create-playlist`(云端创建):
285
+ - **(a)** 当前系统不是 Windows / macOS(control 不支持 Linux)
286
+ - **(b)** 本地酷狗客户端未运行,或未通过 `kugou-cli control start` 完成握手(前置条件详见 [control.md §10](./control.md#10-playlist-create--创建歌单))
287
+ - **(c)** `control playlist create` 调用失败(如 409/4091"login required"、网络错误等)—— 此时把 stderr 原样回给用户,并询问是否改走云端
288
+
289
+ 简单说:**默认 `control`;客户端不可用或失败时,才退到 `music`**。不要在用户没问的情况下主动解释为什么走云端,先尝试 client 路径即可。
290
+
291
+ 5. **创建成功后主动询问是否播放**:无论走 `control playlist create` 还是 `music create-playlist`,**只要创建成功(返回 0/成功状态)就必须主动询问用户"是否要播放这个歌单"**,等用户明确回复后再决定走哪条播放命令:
292
+ - 用户同意 → 按场景选播放路径:
293
+ - **客户端路径优先**:`kugou-cli control play-playlist --global-id "<id>"`(详见 [control.md §12](./control.md#12-play-playlist--播放整个歌单)),可叠加 `--playlist-mode` 控制是否打断当前播放
294
+ - **云端歌单(`music create-playlist` 创建的)**:走浏览器 H5 路径(详见下方 7.2)——**不要**再用 `control play-playlist`,因为本地客户端没有这首歌单
295
+ - 用户拒绝 / 不回复 → 不做任何动作,不要替用户决定
296
+ - 仅在"创建歌单成功"时才询问;建失败时不询问(直接展示错误,等用户决定下一步)
297
+
298
+ ### 7.1 接口说明(云端备选,仅在 7.0 第 4 条任一条件成立时使用)
299
+
300
+ > ⚠️ 本节是**云端备选路径**。优先走 [`control playlist create`](./control.md#10-playlist-create--创建歌单)(详见 [7.0 第 4 条](#70-调用原则ai-必读))。仅当客户端不可用时使用本节。
301
+
302
+ 创建一个新的自创建歌单,并可选择在创建后往歌单里添加歌曲。
303
+
304
+ ```bash
305
+ # 创建空歌单
306
+ kugou-cli music create-playlist "我的空歌单"
307
+
308
+ # 创建歌单并添加歌曲
309
+ kugou-cli music create-playlist "我的批量歌单" --songs "123,456,789"
310
+ ```
311
+
312
+ **参数**:
313
+ - `<name>`: 歌单名称(必填)
314
+ - `--songs`: 待添加的歌曲 mix_song_id 列表,逗号分隔(可选)。不传则只创建空歌单
315
+
316
+ **输出示例**:
317
+ ```json
318
+ {
319
+ "errcode": 0,
320
+ "errmsg": "",
321
+ "data": {
322
+ "name": "我的批量歌单",
323
+ "song_list_url": "https://m.kugou.com/songlist/gcid_abc123def45"
324
+ },
325
+ "status": 1
326
+ }
327
+ ```
328
+
329
+ **关键字段**:
330
+ - `name`: 歌单名称
331
+ - `song_list_url`: 歌单播放地址(H5 链接),可分享给用户打开
332
+
333
+ **异常说明**:
334
+ - 歌单创建成功但添加歌曲失败:返回 200 状态 + 错误信息,body 仍包含已创建歌单的 `name` 与 `song_list_url`
335
+ - 歌单创建失败:返回对应错误码(参数错误 20010 / 网络错误 90000 等)
336
+
337
+ ### 7.2 云端歌单的播放:控制浏览器打开 H5 链接
338
+
339
+ > 适用场景:用户同意播放的歌单是 `music create-playlist` 创建的(响应里有 `song_list_url`),且本地没有可用的酷狗客户端(7.0 第 4 条 (a)(b)(c) 任一成立)。
340
+
341
+ **Agent 必须遵循"先探后告知"原则**:
342
+
343
+ 1. **先探测浏览器控制能力**:当前 Agent 工具栈是否能控制本地浏览器(playwright / dev-browser / chrome-devtools MCP 等任一可用)。可用 = 可用;都不可用 = 当前环境不支持浏览器控制
344
+ 2. **可用时**:
345
+ - 用浏览器工具打开响应里的 `song_list_url`(H5 链接,格式如 `https://m.kugou.com/songlist/gcid_...`)
346
+ - 等待 H5 页面加载完成(`networkidle` / 出现"播放全部"按钮)
347
+ - **轻量职责**:点击页面上的"播放" / "播放全部"按钮(若有),控制到"页面已渲染出播放控制"为止
348
+ - 页面登录、付费、版权屏蔽等后续问题**不归 Agent 管**,告诉用户"已打开 H5 歌单并尝试点击播放,如未自动播放请手动点一下"
349
+ 3. **不可用时**(无浏览器控制工具 / 浏览器控制调用失败):
350
+ - 明确告知用户:"当前环境无法控制浏览器,请手动复制链接在浏览器打开:[song_list_url]"
351
+ - **不要**伪装已经打开或点击了播放
352
+
353
+ > **为什么不写死"先 playwright 再 chrome-devtools"?** 不同 Agent 工具栈内置的浏览器工具名不同,文档只规定行为契约("打开 + 点击播放"),具体工具由 Agent 现场选择。
354
+
355
+ ---
356
+
357
+ ## 8. 搜索歌单
358
+
359
+ 根据关键词搜索歌单。
360
+
361
+ ```bash
362
+ kugou-cli music search-playlist "周杰伦"
363
+ kugou-cli music search-playlist "周杰伦" --page 1 --size 20
364
+ kugou-cli music search-playlist "跑步" --filter 1 # 只搜 UGC
365
+ kugou-cli music search-playlist "钢琴" --filter 2 # 只搜非 UGC
366
+ ```
367
+
368
+ **参数**:
369
+ - `<keyword>`: 搜索关键词(必填)
370
+ - `--page`: 页码,默认 1
371
+ - `--size`: 每页数量,默认 20
372
+ - `--filter`: 过滤方式,`0=全部(默认) / 1=只搜 UGC / 2=只搜非 UGC`
373
+
374
+ **输出示例**:
375
+ ```json
376
+ {
377
+ "errcode": 0,
378
+ "data": {
379
+ "list": [
380
+ {
381
+ "list_id": 2651286,
382
+ "global_id": "collection_3_938985631_304_0",
383
+ "name": "<em>周杰伦</em>:无与伦比,为杰沉沦。",
384
+ "creator_id": "938985631",
385
+ "creator_name": "慕情超爱撒花",
386
+ "intro": "",
387
+ "song_list_url": "https://m.kugou.com/songlist/gcid_3z938985631z304z2"
388
+ }
389
+ ],
390
+ "total": 1000,
391
+ "page": 1,
392
+ "size": 20
393
+ },
394
+ "status": 1
395
+ }
396
+ ```
397
+
398
+ **关键字段**:
399
+ - `list_id`: 歌单 ID(数字 string)
400
+ - `global_id`: 全局歌单 ID(字符串,跨客户端兼容的稳定标识)
401
+ - `name`: 歌单名
402
+ - `creator_id`: 创建者用户 ID(字符串)
403
+ - `creator_name`: 创建者昵称
404
+ - `intro`: 歌单简介
405
+ - `song_list_url`: 歌单链接(H5),格式 `https://m.kugou.com/songlist/gcid_{encoded(global_id)}`;`global_id` 为空时返回空字符串
406
+
407
+ > **提示**: 歌单搜索/推荐只返回基础信息用于卡片展示。需要歌曲数、播放量、收藏数、封面图、歌单内歌曲等详细信息时,调用方拿到 `global_id` 后调用 [第 10 章](#10-歌单内歌曲列表) 或直接打开 `song_list_url`。
408
+
409
+ **特殊说明**:
410
+ - 上游高亮:服务端固定传 `tag=em`,返回的 `name` 字段带 `<em>...</em>` 高亮标签,前端可直接渲染
411
+ - 上游错误码:146/147=被屏蔽地区,148=非法关键字,149=页码超出范围。出现时返回 90000 网络错误,建议引导用户重试或更换关键词
412
+
413
+ ---
414
+
415
+ ## 9. 歌单推荐
416
+
417
+ 根据用户喜好个性化推荐歌单。
418
+
419
+ ```bash
420
+ kugou-cli music recommend-playlist
421
+ kugou-cli music recommend-playlist --page 1 --size 20
422
+ kugou-cli music recommend-playlist --module-id 6 # 我-最近播放-歌单下方
423
+ ```
424
+
425
+ **参数**:
426
+ - `--page`: 页码,默认 1
427
+ - `--size`: 每页数量,默认 20
428
+ - `--module-id`: 上游模块 ID,由客户端透传。常见值:
429
+ - `1` = 歌单广场(默认)
430
+ - `5` = 酷狗 X 首页为你推荐
431
+ - `6` = 我 - 最近播放 - 歌单下方
432
+ - `15` = 酷狗 12 听首页为你推荐
433
+
434
+ 不传时服务端默认填 `1`。
435
+
436
+ **输出示例**:
437
+ ```json
438
+ {
439
+ "errcode": 0,
440
+ "data": {
441
+ "list": [
442
+ {
443
+ "list_id": 2651286,
444
+ "global_id": "collection_3_938985631_304_0",
445
+ "name": "周杰伦:无与伦比,为杰沉沦。",
446
+ "creator_id": "938985631",
447
+ "creator_name": "慕情超爱撒花",
448
+ "intro": "",
449
+ "song_list_url": "https://m.kugou.com/songlist/gcid_3z938985631z304z2"
450
+ }
451
+ ],
452
+ "total": 100,
453
+ "has_next": 1,
454
+ "session": "1706428800",
455
+ "refresh_time": 0,
456
+ "page": 1,
457
+ "size": 20
458
+ },
459
+ "status": 1
460
+ }
461
+ ```
462
+
463
+ **关键字段(顶层)**:
464
+ - `total`: 总数;`has_next`: 是否有下一页(1=是 / 0=否)
465
+ - `session`: 会话标识(暂时返回时间戳)
466
+ - `refresh_time`: 客户端刷新时间(秒),`0` 或缺失表示不刷新
467
+
468
+ **关键字段(list[])**:
469
+ - 与歌单搜索([第 8 章](#8-搜索歌单))共用同一套 `PlaylistInfo` 基础字段(`list_id` / `global_id` / `name` / `creator_id` / `creator_name` / `intro` / `song_list_url`),调用方可使用同一套反序列化逻辑
470
+ - 已登录时上游根据 userid 做个性化推荐;未登录时可能返回空数据或通用推荐
471
+ - 上游可能附带 `cache` 等字段,CLI 不解析、不保证
472
+
473
+ ---
474
+
475
+ ## 10. 歌单内歌曲列表
476
+
477
+ 通过歌单全局 ID(`global_collection_id`)获取歌单内歌曲列表。一般先调用 [第 8 章](#8-搜索歌单) 或 [第 9 章](#9-歌单推荐) 拿到 `global_id`,再透传给本接口。
478
+
479
+ ```bash
480
+ kugou-cli music playlist-songs "collection_3_938985631_304_0"
481
+ kugou-cli music playlist-songs "collection_3_938985631_304_0" --page 1 --size 100
482
+ ```
483
+
484
+ **参数**:
485
+ - `<global_collection_id>`: 歌单全局 ID(必填,从 `search-playlist` / `recommend-playlist` 响应的 `global_id` 字段透传)
486
+ - `--page`: 页码,从 1 开始,默认 1
487
+ - `--size`: 每页数量,默认 100(上游建议值)
488
+
489
+ **输出示例**:
490
+ ```json
491
+ {
492
+ "errcode": 0,
493
+ "data": {
494
+ "list": [
495
+ {
496
+ "song_name": "晴天",
497
+ "mix_song_id": "8888",
498
+ "artist_name": "周杰伦",
499
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
500
+ },
501
+ {
502
+ "song_name": "七里香",
503
+ "mix_song_id": "8890",
504
+ "artist_name": "周杰伦",
505
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
506
+ }
507
+ ],
508
+ "total": 164,
509
+ "page": 1,
510
+ "size": 100
511
+ },
512
+ "status": 1
513
+ }
514
+ ```
515
+
516
+ **关键字段**:
517
+ - `list[]`: 通用 `SongInfo` 结构(`song_name` / `mix_song_id` / `artist_name` / `play_link`)
518
+ - `total`: 上游返回的歌曲总数(不含被过滤的屏蔽歌曲)
519
+
520
+ > **关于上游附带字段**:CLI 透传上游原始 JSON 字符串,响应里**可能**含其他字段(如 `hash`、`singer_id` 等),但 CLI 不解析、不保证存在。Agent 不要依赖未在 `SongInfo` 中列出的字段。
521
+
522
+ **特殊说明**:
523
+ - **屏蔽歌曲过滤**: 上游可能跳过被屏蔽的歌曲(不返回),`total` 不含被过滤项,`list` 长度可能小于 `size`
524
+ - **artist_name 拼接**: 多歌手时上游用 `/` 拼接(例如 `周杰伦/方文山`)
525
+ - **分页去重**: 上游按服务端数组下标分页,但歌曲可能在分页期间被增删,调用方需自行按 `mix_song_id` 去重
526
+ - **播放链接**: `play_link` 由服务端拿到 `mix_song_id` 后批量生成,单条失败不影响其他歌曲