From 0b5e4ce77eb8561c1e5213fec5a1c566aa4cd7b8 Mon Sep 17 00:00:00 2001 From: Nzix Date: Fri, 27 Jul 2018 00:14:54 +0800 Subject: [PATCH 1/4] fix cookie check regexp --- util/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/util.js b/util/util.js index cc1454e..1c67585 100644 --- a/util/util.js +++ b/util/util.js @@ -40,7 +40,7 @@ function createWebAPIRequest( errorcallback ) { // console.log(cookie); - if (cookie.match(/_csrf=[^(;|$)]+;/g)) + if (cookie.match(/_csrf=[^(;|$)]+/g)) data.csrf_token = cookie.match(/_csrf=[^(;|$)]+/g)[0].slice(6); else data.csrf_token = ""; const proxy = cookie.split("__proxy__")[1]; From adf9ae21d1e0d81194d823e539c57d04745d02ff Mon Sep 17 00:00:00 2001 From: Nzix Date: Fri, 27 Jul 2018 00:17:50 +0800 Subject: [PATCH 2/4] support inital index for artist list --- router/artist_list.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/router/artist_list.js b/router/artist_list.js index 0c90a61..27e2515 100644 --- a/router/artist_list.js +++ b/router/artist_list.js @@ -22,11 +22,14 @@ module.exports = (req, res, createWebAPIRequest, request) => { // 其他女歌手 4002 // 其他组合/乐队 4003 + // initial 取值A为65,B为66...以此类推 + const data = { categoryCode: req.query.cat || "1001", offset: req.query.offset || 0, total: req.query.total ? "true" : "false", - limit: req.query.limit || 30 + limit: req.query.limit || 30, + initial: req.query.initial || "" }; createWebAPIRequest( "music.163.com", From 2c5dcdfe8ea501534d30b7accc4daeeb924a394b Mon Sep 17 00:00:00 2001 From: Nzix Date: Fri, 27 Jul 2018 00:19:18 +0800 Subject: [PATCH 3/4] related playlist recommendation --- router/related_playlist.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 router/related_playlist.js diff --git a/router/related_playlist.js b/router/related_playlist.js new file mode 100644 index 0000000..d855122 --- /dev/null +++ b/router/related_playlist.js @@ -0,0 +1,37 @@ +//related ,相关歌单 +module.exports = (req, res, createWebAPIRequest, request) => { + const options = { + url: "http://music.163.com/playlist?id=" + req.query.id, + method: "GET", + headers: { + Referer: "http://music.163.com", + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3380.0 Safari/537.36" + } + }; + request(options, (error, response, body) => { + if (error) { + res.status(502).send("fetch error"); + } else { + try { + const pattern = /