修复歌单详情接口数据不完整的问题 #167

This commit is contained in:
binaryify 2018-01-16 22:40:34 +08:00
parent 4856050bb1
commit 35dbd5cb6d
4 changed files with 12 additions and 35 deletions

View File

@ -1,5 +1,9 @@
# 更新日志 # 更新日志
### 2.8.6 | 2018.01.16
修复歌单详情接口数据不完整的问题
### 2.8.5 | 2018.01.16 ### 2.8.5 | 2018.01.16
修复评论点赞失败的问题 修复评论点赞失败的问题

View File

@ -1,6 +1,6 @@
{ {
"name": "NeteaseCloudMusicApi", "name": "NeteaseCloudMusicApi",
"version": "2.8.5", "version": "2.8.6",
"description": "网易云音乐 NodeJS 版 API", "description": "网易云音乐 NodeJS 版 API",
"scripts": { "scripts": {
"start": "node app.js", "start": "node app.js",

View File

@ -7,6 +7,7 @@ router.get("/", (req, res) => {
const cookie = req.get("Cookie") ? req.get("Cookie") : ""; const cookie = req.get("Cookie") ? req.get("Cookie") : "";
const data = { const data = {
id: req.query.id, id: req.query.id,
n: 100000,
csrf_token: "" csrf_token: ""
}; };
@ -17,44 +18,14 @@ router.get("/", (req, res) => {
data, data,
cookie, cookie,
music_req => { music_req => {
// console.log(music_req) // console.log(JSON.parse(music_req).playlist.tracks.length)
// console.log(JSON.parse(music_req).playlist.trackIds.length)
res.send(music_req); res.send(music_req);
}, },
err => { err => {
res.status(502).send("fetch error"); res.status(502).send("fetch error");
} }
); );
// 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()
// })
// })
// function mergeRes() {
// if (imgurl != undefined && detail != undefined) {
// detail = JSON.parse(detail)
// detail.playlist.picUrl = imgurl
// res.send(detail)
// }
// }
}); });
module.exports = router; module.exports = router;

View File

@ -39,7 +39,7 @@ function createWebAPIRequest(
callback, callback,
errorcallback errorcallback
) { ) {
console.log(cookie); // console.log(cookie);
const proxy = cookie.split("__proxy__")[1]; const proxy = cookie.split("__proxy__")[1];
cookie = cookie.split("__proxy__")[0]; cookie = cookie.split("__proxy__")[0];
const cryptoreq = Encrypt(data); const cryptoreq = Encrypt(data);
@ -71,7 +71,9 @@ function createWebAPIRequest(
//如: Domain=.music.163.com //如: Domain=.music.163.com
let cookie = res.headers["set-cookie"]; let cookie = res.headers["set-cookie"];
if (Array.isArray(cookie)) { if (Array.isArray(cookie)) {
cookie = cookie.map(x => x.replace(/.music.163.com/g, "")).sort((a, b) => a.length - b.length) cookie = cookie
.map(x => x.replace(/.music.163.com/g, ""))
.sort((a, b) => a.length - b.length);
} }
callback(body, cookie); callback(body, cookie);
} }