NeteaseCloudMusicApi
Advanced tools
Comparing version 2.8.2 to 2.8.3
23
app.js
@@ -9,13 +9,14 @@ const express = require("express"); | ||
// 跨域设置 | ||
// app.all('*', function (req, res, next) { | ||
// if (req.path !== '/' && !req.path.includes('.')) { | ||
// res.header('Access-Control-Allow-Credentials', true) | ||
// // 这里获取 origin 请求头 而不是用 * | ||
// res.header('Access-Control-Allow-Origin', req.headers['origin'] || '*') | ||
// res.header('Access-Control-Allow-Headers', 'X-Requested-With') | ||
// res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS') | ||
// res.header('Content-Type', 'application/json;charset=utf-8') | ||
// } | ||
// next() | ||
// }) | ||
app.all("*", function(req, res, next) { | ||
if (req.path !== "/" && !req.path.includes(".")) { | ||
res.header("Access-Control-Allow-Credentials", true); | ||
// 这里获取 origin 请求头 而不是用 * | ||
res.header("Access-Control-Allow-Origin", req.headers["origin"] || "*"); | ||
res.header("Access-Control-Allow-Headers", "X-Requested-With"); | ||
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS"); | ||
res.header("Content-Type", "application/json;charset=utf-8"); | ||
} | ||
next(); | ||
}); | ||
const onlyStatus200 = (req, res) => res.statusCode === 200; | ||
@@ -22,0 +23,0 @@ |
# 更新日志 | ||
### 2.8.3 | 2018.01.12 | ||
优化部分功能和文档 | ||
### 2.8.2 | 2018.01.05 | ||
增加 Dockerfile,支持以 Docker 容器模式运行 | ||
### 2.8.1 | 2018.01.04 | ||
添加了proxy功能 | ||
添加了 proxy 功能 | ||
@@ -12,3 +21,3 @@ ### 2.8.0 | 2018.01.04 | ||
更新排行榜接口,新增云音乐ACG音乐榜,云音乐嘻哈榜 | ||
更新排行榜接口 , 新增云音乐 ACG 音乐榜 , 云音乐嘻哈榜 | ||
@@ -15,0 +24,0 @@ ### 2.7.7 | 2017.11.27 |
{ | ||
"name": "NeteaseCloudMusicApi", | ||
"version": "2.8.2", | ||
"version": "2.8.3", | ||
"description": "网易云音乐 NodeJS 版 API", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -1,34 +0,34 @@ | ||
const express = require('express') | ||
const crypto = require('crypto') | ||
const router = express() | ||
const { createWebAPIRequest } = require('../util/util') | ||
const express = require("express"); | ||
const crypto = require("crypto"); | ||
const router = express(); | ||
const { createWebAPIRequest } = require("../util/util"); | ||
router.get('/', (req, res) => { | ||
const phone = req.query.phone | ||
const cookie = req.get('Cookie') ? req.get('Cookie') : '' | ||
const md5sum = crypto.createHash('md5') | ||
md5sum.update(req.query.password) | ||
router.get("/", (req, res) => { | ||
const phone = req.query.phone; | ||
const cookie = req.get("Cookie") ? req.get("Cookie") : ""; | ||
const md5sum = crypto.createHash("md5"); | ||
md5sum.update(req.query.password); | ||
const data = { | ||
phone: phone, | ||
password: md5sum.digest('hex'), | ||
rememberLogin: 'true' | ||
} | ||
password: md5sum.digest("hex"), | ||
rememberLogin: "true" | ||
}; | ||
createWebAPIRequest( | ||
'music.163.com', | ||
'/weapi/login/cellphone', | ||
'POST', | ||
"music.163.com", | ||
"/weapi/login/cellphone", | ||
"POST", | ||
data, | ||
cookie, | ||
(music_req, cookie) => { | ||
// console.log(music_req) | ||
cookie = cookie&&cookie.map(x => x.replace("Domain=.music.163.com", "")) | ||
cookie = | ||
cookie && cookie.map(x => x.replace("Domain=.music.163.com", "")); | ||
res.set({ | ||
'Set-Cookie': cookie | ||
}) | ||
res.send(music_req) | ||
"Set-Cookie": cookie | ||
}); | ||
res.send(music_req); | ||
}, | ||
err => res.status(502).send('fetch error') | ||
) | ||
}) | ||
err => res.status(502).send("fetch error") | ||
); | ||
}); | ||
module.exports = router | ||
module.exports = router; |
@@ -1,34 +0,27 @@ | ||
const http = require('http') | ||
const express = require('express') | ||
const router = express() | ||
const { createWebAPIRequest } = require('../util/util') | ||
const http = require("http"); | ||
const express = require("express"); | ||
const router = express(); | ||
const { createWebAPIRequest } = require("../util/util"); | ||
router.get('/', (req, res) => { | ||
const cookie = req.get('Cookie') ? req.get('Cookie') : '' | ||
let detail, imgurl | ||
router.get("/", (req, res) => { | ||
const cookie = req.get("Cookie") ? req.get("Cookie") : ""; | ||
const data = { | ||
id: req.query.id, | ||
offset: 0, | ||
total: true, | ||
limit: 1000, | ||
n: 1000, | ||
csrf_token: '' | ||
} | ||
csrf_token: "" | ||
}; | ||
createWebAPIRequest( | ||
'music.163.com', | ||
'/weapi/v3/playlist/detail', | ||
'POST', | ||
"music.163.com", | ||
"/weapi/v3/playlist/detail", | ||
"POST", | ||
data, | ||
cookie, | ||
music_req => { | ||
console.log(music_req) | ||
// detail = music_req | ||
res.send(music_req) | ||
// mergeRes() | ||
// console.log(music_req) | ||
res.send(music_req); | ||
}, | ||
err => { | ||
res.status(502).send('fetch error') | ||
res.status(502).send("fetch error"); | ||
} | ||
) | ||
); | ||
@@ -65,4 +58,4 @@ // FIXME:i dont know the api to get coverimgurl | ||
// } | ||
}) | ||
}); | ||
module.exports = router | ||
module.exports = router; |
@@ -1,24 +0,27 @@ | ||
const express = require('express') | ||
const router = express() | ||
const { createWebAPIRequest } = require('../util/util') | ||
const express = require("express"); | ||
const router = express(); | ||
const { createWebAPIRequest } = require("../util/util"); | ||
router.get('/', (req, res) => { | ||
const cookie = req.get('Cookie') ? req.get('Cookie') : '' | ||
router.get("/", (req, res) => { | ||
const cookie = req.get("Cookie") ? req.get("Cookie") : ""; | ||
const data = { | ||
offset: 0, | ||
offset: req.query.offset || 0, | ||
uid: req.query.uid, | ||
limit: 1000, | ||
csrf_token: '' | ||
} | ||
limit: req.query.limit || 30, //貌似无效 | ||
csrf_token: "" | ||
}; | ||
createWebAPIRequest( | ||
'music.163.com', | ||
'/weapi/user/playlist', | ||
'POST', | ||
"music.163.com", | ||
"/weapi/user/playlist", | ||
"POST", | ||
data, | ||
cookie, | ||
music_req => res.send(music_req), | ||
err => res.status(502).send('fetch error') | ||
) | ||
}) | ||
music_req => { | ||
res.send(music_req); | ||
// console.log(JSON.parse(music_req)) | ||
}, | ||
err => res.status(502).send("fetch error") | ||
); | ||
}); | ||
module.exports = router | ||
module.exports = router; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
141004
101
2495