mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
修复文档描述错误,调整歌单详情接口
This commit is contained in:
parent
4a8008761a
commit
a0114df488
@ -276,7 +276,7 @@ $ set PORT=4000 && node app.js
|
|||||||
`/top/playlist/highquality`
|
`/top/playlist/highquality`
|
||||||
|
|
||||||
**调用例子:**
|
**调用例子:**
|
||||||
`/playlist/detail?id=24381616`
|
`/top/playlist/highquality?limit=30`
|
||||||
|
|
||||||
|
|
||||||
### 获取歌单详情
|
### 获取歌单详情
|
||||||
|
@ -23,8 +23,9 @@ router.get("/", (req, res) => {
|
|||||||
cookie,
|
cookie,
|
||||||
music_req => {
|
music_req => {
|
||||||
console.log(music_req)
|
console.log(music_req)
|
||||||
detail = music_req
|
// detail = music_req
|
||||||
mergeRes()
|
res.send(music_req)
|
||||||
|
// mergeRes()
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
res.status(502).send('fetch error')
|
res.status(502).send('fetch error')
|
||||||
@ -33,34 +34,34 @@ router.get("/", (req, res) => {
|
|||||||
|
|
||||||
// FIXME:i dont know the api to get coverimgurl
|
// FIXME:i dont know the api to get coverimgurl
|
||||||
// so i get it by parsing html
|
// so i get it by parsing html
|
||||||
const http_client = http.get({
|
// const http_client = http.get({
|
||||||
hostname: 'music.163.com',
|
// hostname: 'music.163.com',
|
||||||
path: '/playlist?id=' + req.query.id,
|
// path: '/playlist?id=' + req.query.id,
|
||||||
headers: {
|
// headers: {
|
||||||
'Referer': 'http://music.163.com',
|
// 'Referer': 'http://music.163.com',
|
||||||
},
|
// },
|
||||||
}, function (res) {
|
// }, function (res) {
|
||||||
res.setEncoding('utf8')
|
// res.setEncoding('utf8')
|
||||||
let html = ''
|
// let html = ''
|
||||||
res.on('data', function (chunk) {
|
// res.on('data', function (chunk) {
|
||||||
html += chunk
|
// html += chunk
|
||||||
})
|
// })
|
||||||
res.on('end', function () {
|
// res.on('end', function () {
|
||||||
console.log('end', html)
|
// console.log('end', html)
|
||||||
const regImgCover = /\<img src=\"(.*)\" class="j-img"/ig
|
// const regImgCover = /\<img src=\"(.*)\" class="j-img"/ig
|
||||||
imgurl = regImgCover.exec(html)[1]
|
// imgurl = regImgCover.exec(html)[1]
|
||||||
mergeRes()
|
// mergeRes()
|
||||||
|
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
|
||||||
function mergeRes() {
|
// function mergeRes() {
|
||||||
if (imgurl != undefined && detail != undefined) {
|
// if (imgurl != undefined && detail != undefined) {
|
||||||
detail = JSON.parse(detail)
|
// detail = JSON.parse(detail)
|
||||||
detail.playlist.picUrl = imgurl
|
// detail.playlist.picUrl = imgurl
|
||||||
res.send(detail)
|
// res.send(detail)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user