mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-03 17:02:09 +08:00
commit
752d1965f7
@ -17,6 +17,13 @@
|
||||
|
||||
|
||||
## 版本新特性
|
||||
|
||||
### ? ? ? | 2018.01.04
|
||||
添加了proxy功能
|
||||
|
||||
### 2.8.0 | 2018.01.04
|
||||
用 'request' 重写了请求函数
|
||||
|
||||
### 2.6.5 | 2017.7.16
|
||||
优化 CORS 设置
|
||||
|
||||
|
8
app.js
8
app.js
@ -23,6 +23,14 @@ app.use(cache("2 minutes", onlyStatus200));
|
||||
|
||||
app.use(express.static(path.resolve(__dirname, "public")));
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
const proxy = req.query.proxy;
|
||||
if (proxy) {
|
||||
req.headers.cookie = req.headers.cookie + `__proxy__${proxy}`;
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// 获取专辑内容
|
||||
app.use("/album", require("./router/album"));
|
||||
|
||||
|
@ -12,7 +12,27 @@
|
||||
## 工作原理
|
||||
跨站请求伪造 (CSRF), 伪造请求头,调用官方 API
|
||||
|
||||
## 可以使用代理
|
||||
在query参数中加上proxy=your-proxy即可让这一次的请求使用proxy
|
||||
|
||||
```javascript
|
||||
// 例子
|
||||
const url = `http://localhost:3000/music/url?id=33894312&proxy=http://121.196.226.246:84`
|
||||
fetch(url)
|
||||
.then(function()
|
||||
{
|
||||
// do what you want
|
||||
})
|
||||
|
||||
// 结果
|
||||
// {"data":[{"id":33894312,"url":"http://m10.music.126.net/20180104125640/930a968b3fb04908b733506b3833e60b/ymusic/0fd6/4f65/43ed/a8772889f38dfcb91c04da915b301617.mp3","br":320000,"size":10691439,"md5":"a8772889f38dfcb91c04da915b301617","code":200,"expi":1200,"type":"mp3","gain":-2.0E-4,"fee":0,"uf":null,"payed":0,"flag":0,"canExtend":false}],"code": 200}
|
||||
```
|
||||
|
||||
## 版本新特性
|
||||
|
||||
### ? ? ? | 2018.01.04
|
||||
添加了proxy功能
|
||||
|
||||
### 2.8.0 | 2018.01.04
|
||||
用 'request' 重写了请求函数
|
||||
|
||||
@ -334,8 +354,8 @@ $ set PORT=4000 && node app.js
|
||||
`/music/url`
|
||||
|
||||
**调用例子:**
|
||||
`/music/url?id=347230`
|
||||
`/music/url?id=347230,347231`
|
||||
`/music/url?id=33894312`
|
||||
`/music/url?id=405998841,33894312`
|
||||
|
||||
返回数据如下图:
|
||||

|
||||
@ -411,8 +431,8 @@ $ set PORT=4000 && node app.js
|
||||
**调用例子:**
|
||||
`/search/multimatch?keywords=海阔天空`
|
||||
|
||||
### 收藏单曲到歌单
|
||||
说明:调用此接口,传入音乐 id和 limit 参数, 可获得该专辑的所有评论(需要登录)
|
||||
### 对歌单添加或删除歌曲
|
||||
说明:调用此接口,可以添加歌曲到歌单或者从歌单删除某首歌曲(需要登录)
|
||||
|
||||
**必选参数:**
|
||||
`op`: 从歌单增加单曲为add,删除为 del
|
||||
@ -436,7 +456,7 @@ $ set PORT=4000 && node app.js
|
||||
`/lyric`
|
||||
|
||||
**调用例子:**
|
||||
`/lyric?id=347230`
|
||||
`/lyric?id=33894312`
|
||||
|
||||
返回数据如下图:
|
||||

|
||||
|
@ -2,6 +2,8 @@ const Encrypt = require("./crypto.js");
|
||||
const request = require("request");
|
||||
const querystring = require("querystring");
|
||||
|
||||
// request.debug = true;
|
||||
|
||||
function randomUserAgent() {
|
||||
const userAgentList = [
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
|
||||
@ -37,6 +39,9 @@ function createWebAPIRequest(
|
||||
callback,
|
||||
errorcallback
|
||||
) {
|
||||
console.log(cookie);
|
||||
const proxy = cookie.split("__proxy__")[1];
|
||||
cookie = cookie.split("__proxy__")[0];
|
||||
const cryptoreq = Encrypt(data);
|
||||
const options = {
|
||||
url: `http://${host}${path}`,
|
||||
@ -54,7 +59,8 @@ function createWebAPIRequest(
|
||||
body: querystring.stringify({
|
||||
params: cryptoreq.params,
|
||||
encSecKey: cryptoreq.encSecKey
|
||||
})
|
||||
}),
|
||||
proxy: proxy
|
||||
};
|
||||
|
||||
request(options, function(error, res, body) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user