mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-10-23 15:43:10 +00:00
commit
49d82d7988
@ -22,11 +22,14 @@ module.exports = (req, res, createWebAPIRequest, request) => {
|
||||
// 其他女歌手 4002
|
||||
// 其他组合/乐队 4003
|
||||
|
||||
// initial 取值a-z/A-Z
|
||||
|
||||
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 || "").toUpperCase().charCodeAt() || ""
|
||||
};
|
||||
createWebAPIRequest(
|
||||
"music.163.com",
|
||||
|
37
router/related_playlist.js
Normal file
37
router/related_playlist.js
Normal file
@ -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 = /<div class="cver u-cover u-cover-3">[\s\S]*?<img src="([^"]+)">[\s\S]*?<a class="sname f-fs1 s-fc0" href="([^"]+)"[^>]*>([^<]+?)<\/a>[\s\S]*?<a class="nm nm f-thide s-fc3" href="([^"]+)"[^>]*>([^<]+?)<\/a>/g;
|
||||
const data = {playlists:[],code:200};
|
||||
let result;
|
||||
while ((result = pattern.exec(body)) != null) {
|
||||
data.playlists.push({
|
||||
creator: {
|
||||
userId: result[4].slice('/user/home?id='.length),
|
||||
nickname: result[5]
|
||||
},
|
||||
coverImgUrl: result[1].slice(0,-('?param=50y50'.length)),
|
||||
name: result[3],
|
||||
id: result[2].slice('/playlist?id='.length)
|
||||
});
|
||||
}
|
||||
res.send(JSON.stringify(data));
|
||||
} catch (error) {
|
||||
res.status(502).send("fetch error");
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user