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`
|
||||
|
||||
**调用例子:**
|
||||
`/playlist/detail?id=24381616`
|
||||
`/top/playlist/highquality?limit=30`
|
||||
|
||||
|
||||
### 获取歌单详情
|
||||
|
@ -23,8 +23,9 @@ router.get("/", (req, res) => {
|
||||
cookie,
|
||||
music_req => {
|
||||
console.log(music_req)
|
||||
detail = music_req
|
||||
mergeRes()
|
||||
// detail = music_req
|
||||
res.send(music_req)
|
||||
// mergeRes()
|
||||
},
|
||||
err => {
|
||||
res.status(502).send('fetch error')
|
||||
@ -33,34 +34,34 @@ router.get("/", (req, res) => {
|
||||
|
||||
// FIXME:i dont know the api to get coverimgurl
|
||||
// so i get it by parsing html
|
||||
const http_client = http.get({
|
||||
hostname: 'music.163.com',
|
||||
path: '/playlist?id=' + req.query.id,
|
||||
headers: {
|
||||
'Referer': 'http://music.163.com',
|
||||
},
|
||||
}, function (res) {
|
||||
res.setEncoding('utf8')
|
||||
let html = ''
|
||||
res.on('data', function (chunk) {
|
||||
html += chunk
|
||||
})
|
||||
res.on('end', function () {
|
||||
console.log('end', html)
|
||||
const regImgCover = /\<img src=\"(.*)\" class="j-img"/ig
|
||||
imgurl = regImgCover.exec(html)[1]
|
||||
mergeRes()
|
||||
// const http_client = http.get({
|
||||
// hostname: 'music.163.com',
|
||||
// path: '/playlist?id=' + req.query.id,
|
||||
// headers: {
|
||||
// 'Referer': 'http://music.163.com',
|
||||
// },
|
||||
// }, function (res) {
|
||||
// res.setEncoding('utf8')
|
||||
// let html = ''
|
||||
// res.on('data', function (chunk) {
|
||||
// html += chunk
|
||||
// })
|
||||
// res.on('end', function () {
|
||||
// console.log('end', html)
|
||||
// const regImgCover = /\<img src=\"(.*)\" class="j-img"/ig
|
||||
// imgurl = regImgCover.exec(html)[1]
|
||||
// mergeRes()
|
||||
|
||||
})
|
||||
})
|
||||
// })
|
||||
// })
|
||||
|
||||
function mergeRes() {
|
||||
if (imgurl != undefined && detail != undefined) {
|
||||
detail = JSON.parse(detail)
|
||||
detail.playlist.picUrl = imgurl
|
||||
res.send(detail)
|
||||
}
|
||||
}
|
||||
// function mergeRes() {
|
||||
// if (imgurl != undefined && detail != undefined) {
|
||||
// detail = JSON.parse(detail)
|
||||
// detail.playlist.picUrl = imgurl
|
||||
// res.send(detail)
|
||||
// }
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user