提交 35dbd5cb 编写于 作者: B binaryify

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

上级 4856050b
# 更新日志 # 更新日志
### 2.8.6 | 2018.01.16
修复歌单详情接口数据不完整的问题
### 2.8.5 | 2018.01.16 ### 2.8.5 | 2018.01.16
修复评论点赞失败的问题 修复评论点赞失败的问题
......
{ {
"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",
......
...@@ -7,6 +7,7 @@ router.get("/", (req, res) => { ...@@ -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) => { ...@@ -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;
...@@ -39,7 +39,7 @@ function createWebAPIRequest( ...@@ -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( ...@@ -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);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册