Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47285076
NeteaseCloudMusicApi_nicole-n
提交
752d1965
N
NeteaseCloudMusicApi_nicole-n
项目概览
weixin_47285076
/
NeteaseCloudMusicApi_nicole-n
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NeteaseCloudMusicApi_nicole-n
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
752d1965
编写于
1月 04, 2018
作者:
B
binaryify
提交者:
GitHub
1月 04, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #163 from twesix/master
添加了代理功能
上级
76e850f5
cec25610
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
8 deletion
+49
-8
README.MD
README.MD
+7
-0
app.js
app.js
+8
-0
docs/README.md
docs/README.md
+27
-7
util/util.js
util/util.js
+7
-1
未找到文件。
README.MD
浏览文件 @
752d1965
...
...
@@ -17,6 +17,13 @@
## 版本新特性
### ? ? ? | 2018.01.04
添加了proxy功能
### 2.8.0 | 2018.01.04
用 'request' 重写了请求函数
### 2.6.5 | 2017.7.16
优化 CORS 设置
...
...
app.js
浏览文件 @
752d1965
...
...
@@ -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
"
));
...
...
docs/README.md
浏览文件 @
752d1965
...
...
@@ -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' 重写了请求函数
...
...
@@ -333,9 +353,9 @@ $ set PORT=4000 && node app.js
**接口地址:**
`/music/url`
**调用例子:**
`/music/url?id=3
47230`
`/music/url?id=
347230,347231
`
**调用例子:**
`/music/url?id=3
3894312`
`/music/url?id=
405998841,33894312
`
返回数据如下图:
![
音乐 url
](
https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/%E9%9F%B3%E4%B9%90%20url.png
)
...
...
@@ -411,8 +431,8 @@ $ set PORT=4000 && node app.js
**调用例子:**
`/search/multimatch?keywords=海阔天空`
###
收藏单曲到歌单
说明:调用此接口,
传入音乐 id和 limit 参数, 可获得该专辑的所有评论(需要登录)
###
对歌单添加或删除歌曲
说明:调用此接口,
可以添加歌曲到歌单或者从歌单删除某首歌曲(需要登录)
**必选参数:**
`op`
: 从歌单增加单曲为add,删除为 del
...
...
@@ -435,8 +455,8 @@ $ set PORT=4000 && node app.js
**接口地址:**
`/lyric`
**调用例子:**
`/lyric?id=3
47230`
**调用例子:**
`/lyric?id=3
3894312`
返回数据如下图:
![
获取歌词
](
https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/%E6%AD%8C%E8%AF%8D.png
)
...
...
util/util.js
浏览文件 @
752d1965
...
...
@@ -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
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录