mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
Merge pull request #1397 from SnowingFox/master
feature: 新增获取歌单所有歌曲的API
This commit is contained in:
commit
9f0ea1dabc
@ -1280,6 +1280,19 @@ tags: 歌单标签
|
||||
|
||||
**调用例子 :** `/playlist/detail?id=24381616`
|
||||
|
||||
### 获取歌单所有歌曲
|
||||
|
||||
说明 : 由于网易云接口限制,歌单详情只会提供10首歌,通过调用此接口,传入对应的歌单`id`,即可获得对应的所有歌曲
|
||||
|
||||
**必选参数 :** `id` : 歌单id
|
||||
|
||||
**可选参数 :** `limit` : 限制获取歌曲的数量
|
||||
|
||||
**接口地址 :** `/playlist/track/all`
|
||||
|
||||
**调用例子 :** `/playlist/track/all?id=24381616&limit=10`
|
||||
|
||||
|
||||
### 歌单详情动态
|
||||
|
||||
说明 : 调用后可获取歌单详情动态部分,如评论数,是否收藏,播放数
|
||||
|
@ -542,6 +542,7 @@ category Code 取值:
|
||||
|
||||
**调用例子 :** `/related/playlist?id=1`
|
||||
|
||||
|
||||
### 获取歌单详情
|
||||
|
||||
说明 : 歌单能看到歌单名字 , 但看不到具体歌单内容 , 调用此接口 , 传入歌单 id, 可
|
||||
|
47
module/playlist_track_all.js
Normal file
47
module/playlist_track_all.js
Normal file
@ -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,
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -5,7 +5,6 @@
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "4.0.23",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user