From 96f84b0acef48168a9fd6af28b52f5bff9a288cf Mon Sep 17 00:00:00 2001 From: SnowingFox <1503401882@qq.com> Date: Sat, 20 Nov 2021 11:07:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feature:=20=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=AD=8C=E5=8D=95=E6=89=80=E6=9C=89=E6=AD=8C=E6=9B=B2?= =?UTF-8?q?=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/playlist_catlist.js | 14 +---------- module/playlist_track_all.js | 47 ++++++++++++++++++++++++++++++++++++ package-lock.json | 1 - 3 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 module/playlist_track_all.js diff --git a/module/playlist_catlist.js b/module/playlist_catlist.js index 9b148f6..44c4f7b 100644 --- a/module/playlist_catlist.js +++ b/module/playlist_catlist.js @@ -1,15 +1,3 @@ // 全部歌单分类 -module.exports = (query, request) => { - return request( - 'POST', - `https://music.163.com/weapi/playlist/catalogue`, - {}, - { - crypto: 'weapi', - cookie: query.cookie, - proxy: query.proxy, - realIP: query.realIP, - }, - ) -} +module.exports = (query, request) => {} diff --git a/module/playlist_track_all.js b/module/playlist_track_all.js new file mode 100644 index 0000000..03a8c3a --- /dev/null +++ b/module/playlist_track_all.js @@ -0,0 +1,47 @@ +// 通过传过来的歌单id拿到所有歌曲数据 +// 支持传递参数limit来限制获取歌曲的数据数量 例如: /playlist/track/all?id=7044354223&limit=10 + +module.exports = (query, request) => { + const data = { + id: query.id, + n: 100000, + s: query.s || 8, + } + //不放在data里面避免请求带上无用的数据 + let limit = query.limit + let trackIds + let idsData = Object.create(null) + + return request('POST', `https://music.163.com/api/v6/playlist/detail`, data, { + crypto: 'api', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }).then((res) => { + const ids = [] + let trackIds = res.body.playlist.trackIds + if (typeof limit === 'undefined') { + limit = trackIds.length + } + trackIds.forEach((item, index) => { + if (index < limit) { + ids.push(item.id) + } + }) + idsData = { + c: '[' + ids.map((id) => '{"id":' + id + '}').join(',') + ']', + } + + return request( + 'POST', + `https://music.163.com/api/v3/song/detail`, + idsData, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ) + }) +} diff --git a/package-lock.json b/package-lock.json index bec6d73..07368fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "NeteaseCloudMusicApi", "version": "4.0.23", "license": "MIT", "dependencies": { From ba38d005bf27f995a8164515c09353ccce353f8a Mon Sep 17 00:00:00 2001 From: SnowingFox <1503401882@qq.com> Date: Sat, 20 Nov 2021 12:48:53 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/v2.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/v2.md b/docs/v2.md index fc0b836..ba7254b 100644 --- a/docs/v2.md +++ b/docs/v2.md @@ -542,6 +542,7 @@ category Code 取值: **调用例子 :** `/related/playlist?id=1` + ### 获取歌单详情 说明 : 歌单能看到歌单名字 , 但看不到具体歌单内容 , 调用此接口 , 传入歌单 id, 可 @@ -558,6 +559,18 @@ category Code 取值: 返回数据如下图 : ![歌单详情](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/%E6%AD%8C%E5%8D%95%E8%AF%A6%E6%83%85.png) +### 获取歌单所有歌曲 + +说明 : 由于网易云接口限制,歌单详情只会提供10首歌,通过调用此接口,传入对应的歌单`id`,即可获得对应的歌曲 + +**必选参数 :** `id` : 歌单id + +**可选参数 :** `limit` : 限制获取歌曲的数量 + +**接口地址 :** `/playlist/track/all` + +**调用例子 :** `/playlist/track/all?id=24381616&limit=10` + ### 获取音乐 url 说明 : 使用歌单详情接口后 , 能得到的音乐的 id, 但不能得到的音乐 url, 调用此接口 From 615e1c174839625fd5bd60a236528d2a2057c880 Mon Sep 17 00:00:00 2001 From: SnowingFox <1503401882@qq.com> Date: Sat, 20 Nov 2021 15:10:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=83=BD=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=AD=8C=E5=8D=95=E6=89=80=E6=9C=89=E6=AD=8C=E6=9B=B2?= =?UTF-8?q?=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 13 +++++++++++++ docs/v2.md | 12 ------------ module/playlist_catlist.js | 14 +++++++++++++- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/docs/README.md b/docs/README.md index 240c4e4..277c720 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1278,6 +1278,19 @@ tags: 歌单标签 **调用例子 :** `/playlist/detail?id=24381616` +### 获取歌单所有歌曲 + +说明 : 由于网易云接口限制,歌单详情只会提供10首歌,通过调用此接口,传入对应的歌单`id`,即可获得对应的歌曲 + +**必选参数 :** `id` : 歌单id + +**可选参数 :** `limit` : 限制获取歌曲的数量 + +**接口地址 :** `/playlist/track/all` + +**调用例子 :** `/playlist/track/all?id=24381616&limit=10` + + ### 歌单详情动态 说明 : 调用后可获取歌单详情动态部分,如评论数,是否收藏,播放数 diff --git a/docs/v2.md b/docs/v2.md index ba7254b..08ba02f 100644 --- a/docs/v2.md +++ b/docs/v2.md @@ -559,18 +559,6 @@ category Code 取值: 返回数据如下图 : ![歌单详情](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/%E6%AD%8C%E5%8D%95%E8%AF%A6%E6%83%85.png) -### 获取歌单所有歌曲 - -说明 : 由于网易云接口限制,歌单详情只会提供10首歌,通过调用此接口,传入对应的歌单`id`,即可获得对应的歌曲 - -**必选参数 :** `id` : 歌单id - -**可选参数 :** `limit` : 限制获取歌曲的数量 - -**接口地址 :** `/playlist/track/all` - -**调用例子 :** `/playlist/track/all?id=24381616&limit=10` - ### 获取音乐 url 说明 : 使用歌单详情接口后 , 能得到的音乐的 id, 但不能得到的音乐 url, 调用此接口 diff --git a/module/playlist_catlist.js b/module/playlist_catlist.js index 44c4f7b..9b148f6 100644 --- a/module/playlist_catlist.js +++ b/module/playlist_catlist.js @@ -1,3 +1,15 @@ // 全部歌单分类 -module.exports = (query, request) => {} +module.exports = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/playlist/catalogue`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ) +} From 9022f521563126fc8e733fa6406ba17eb312fd9e Mon Sep 17 00:00:00 2001 From: SnowingFox <1503401882@qq.com> Date: Sat, 20 Nov 2021 15:12:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 277c720..2206b23 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1280,7 +1280,7 @@ tags: 歌单标签 ### 获取歌单所有歌曲 -说明 : 由于网易云接口限制,歌单详情只会提供10首歌,通过调用此接口,传入对应的歌单`id`,即可获得对应的歌曲 +说明 : 由于网易云接口限制,歌单详情只会提供10首歌,通过调用此接口,传入对应的歌单`id`,即可获得对应的所有歌曲 **必选参数 :** `id` : 歌单id