提交 26b5cad8 编写于 作者: zhuangtongfa's avatar zhuangtongfa 提交者: GitHub

Merge pull request #484 from HIjack2015/jk-branch

Jk branch
# 更新日志
### 3.9.0 | 2019.05.03
- 新增 云盘歌曲删除, 热门话题, 电台 - 推荐类型, 电台 - 非热门类型, 电台 - 今日优选, 心动模式/智能播放等接口
- 更新文档:banner接口 增加 `type` 参数; 获取动态消息接口增加 `pagesize``lasttime` 参数; 电台 - 付费精选接口修改默认`limit`为 30
### 3.8.1 | 2019.04.24
- 修复歌词接口出错问题
### 3.8.0 | 2019.04.14
- 增加注册,发送验证码,校验验证码接口 via:[https://github.com/Binaryify/NeteaseCloudMusicApi/pull/460](https://github.com/Binaryify/NeteaseCloudMusicApi/pull/460)
- 增加注册,发送验证码,校验验证码接口 via:[https://github.com/Binaryify/NeteaseCloudMusicApi/pull/460](https://github.com/Binaryify/NeteaseCloudMusicApi/pull/460) @[KongValley](https://github.com/KongValley)
### 3.7.1 | 2019.04.09
- 修复登录460问题
......
......@@ -20,6 +20,7 @@
## 功能特性
1. 登录
2. 刷新登录
3. 发送验证码
......@@ -118,6 +119,12 @@
96. 已收藏专辑列表
97. 获取动态评论
98. 歌单收藏者列表
99. 云盘歌曲删除
100. 热门话题
101. 电台 - 推荐类型
102. 电台 - 非热门类型
103. 电台 - 今日优选
104. 心动模式/智能播放
## 环境要求
......
......@@ -114,6 +114,13 @@
96. 已收藏专辑列表
97. 获取动态评论
98. 歌单收藏者列表
99. 云盘歌曲删除
100. 热门话题
101. 电台 - 推荐类型
102. 电台 - 非热门类型
103. 电台 - 今日优选
104. 心动模式/智能播放
## 安装
......@@ -204,22 +211,24 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
## 接口文档
### 调用前须知
!> 本项目不提供线上 demo,请不要轻易信任使用他人提供的公开服务,以免发生安全问题,泄露自己的账号和密码
!> 为使用方便,降低门槛,登录接口直接使用了 get 明文请求,请按实际需求对源码修改
!> 为使用方便,降低门槛, 文档示例接口直接使用了 GET 请求,本项目同时支持 GET/POST 请按实际需求使用
!> 由于接口做了缓存处理 ( 缓存 2 分钟,不缓存数据极容易引起网易服务器高频ip错误 , 可在 app.js 设置 , 可能会导致登陆后获取不
到 cookie), 相同的 url 会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓
!> 由于接口做了缓存处理 ( 缓存 2 分钟,不缓存数据极容易引起网易服务器高频ip错误 , 可在 app.js 设置 , 可能会导致登陆后获取不到 cookie), **相同的 url** 会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓
存结果的接口 , 可在请求 url 后面加一个时间戳参数使 url 不同 , 例子 :
`/simi/playlist?id=347230&timestamp=1503019930000`
`/simi/playlist?id=347230&timestamp=1503019930000` (之所以加入缓存机制是因为项目早期没有缓存机制,很多 issues 都是报 IP高频,请按自己需求改造缓存中间件(app.js),源码不复杂)
!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` 否则
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jQuery, axios 版本也类似
!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` (axios 为 `withCredentials: true`)否则
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jQuery 和 axios
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是等待 2 分钟或者重启服务重新登录后再调用接口
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是加时间戳或者等待 2 分钟或者重启服务重新登录后再调用接口,可自行改造缓存方法
!> 部分接口如登录接口不能调用太频繁 , 否则可能会触发 503 错误或者 ip 高频错误 ,若需频繁调用 , 需要准备 IP 代理池 (更新:已加入缓存机制,但仍需注意).
!> 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致,请清除缓存再查看
!> 本项目仅供学习使用,请尊重版权,请勿利用此项目从事商业行为
!> 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致,请清除缓存再查看
!> 由于网易限制,此项目在国外服务器上使用会受到限制,如需解决 , 可使用大陆服务器或者使用代理 , 感谢 [@hiyangguo](https://github.com/hiyangguo)提出的[解决方法](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/29#issuecomment-298358438):
在 'util.js' 的 'headers' 处增加 `X-Real-IP':'211.161.244.70' // 任意国内 IP`
......@@ -279,7 +288,7 @@ Cookies
**接口地址 :** `/captch/sent`
**调用例子 :** `/captch/sent?cellphone=13xxx`
**调用例子 :** `/captch/sent?phone=13xxx`
......@@ -524,16 +533,44 @@ tags:歌单tag
**调用例子 :** `/user/record?uid=32953014&type=1`
### 获取热门话题
说明 : 调用此接口 , 可获取热门话题
**可选参数 :** `limit`: 取出评论数量 , 默认为 20
`offset`: 偏移数量 , 用于分页 , 如 :( 评论页数 -1)\*20, 其中 20 为 limit 的值
**接口地址 :** `/act/hot`
**调用例子 :** `/act/hot?limit=30&offset=30`
### 心动模式/智能播放
说明 : 调用此接口 , 可获取心动模式/智能播放列表
**必选参数 :** `id` : 歌曲 id
`pid` : 歌单 id
**可选参数 :**
`sid` : 要开始播放的歌曲的 id
**接口地址 :** `/playmode/intelligence/list`
**调用例子 :** `/playmode/intelligence/list?id=33894312&pid=24381616` , `/playmode/intelligence/list?id=33894312&pid=24381616&sid=36871368`
### 获取动态消息
说明 : 调用此接口 , 可获取各种动态 , 对应网页版网易云,朋友界面里的各种动态消息
,如分享的视频,音乐,照片等!
**必选参数 :** 未知
**必选参数 :**
`pagesize` : 每页数据,默认20
`lasttime` : 返回数据的 `lasttime` ,默认-1,传入上一次返回结果的 lasttime,将会返回下一页的数据
**接口地址 :** `/event`
**调用例子 :** `/event`
**调用例子 :** `/event?pagesize=30&lasttime=1556740526369`
### 歌手分类列表
......@@ -1142,9 +1179,23 @@ mp3url 不能直接用 , 可通过 `/song/url` 接口传入歌曲 id 获取具
说明 : 调用此接口 , 可获取 banner( 轮播图 ) 数据
**可选参数 :**
`type`:资源类型,对应以下类型,默认为 0 即PC
```
0: pc
1: android
2: iphone
3: ipad
```
**接口地址 :** `/banner`
**调用例子 :** `/banner`
**调用例子 :** `/banner`, `/banner?type=2`
### 资源点赞( MV,电台,视频)
......@@ -1706,6 +1757,15 @@ MV 数据 , 数据包含 mv 名字 , 歌手 , 发布时间 , mv 视频地址等
**调用例子 :** `/user/cloud`
### 云盘歌曲删除
说明 : 登陆后调用此接口 , 可删除云盘歌曲
**必选参数 :** `id`: 歌曲id,可多个,用逗号隔开
**接口地址 :** `/user/cloud/del`
**调用例子 :** `/user/cloud/del`
### 电台 - 推荐
说明 : 登陆后调用此接口 , 可获得推荐电台
......@@ -1757,10 +1817,43 @@ type='1009' 获取其 id, 如`/search?keywords= 代码时间 &type=1009`
说明 : 可以获取付费精选的电台列表 , 传入 `limit``offset` 可以进行分页
**可选参数 :**
`limit` : 返回数量 , 默认为 30
`offset` : 偏移数量,用于分页 , 如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
**接口地址 :** `/dj/paygift`
**调用例子 :** `/dj/paygift?limit=10&offset=20`
### 电台 - 非热门类型
说明 : 登陆后调用此接口, 可获得电台非热门类型
**接口地址 :** `/dj/category/excludehot`
**调用例子 :** `/dj/category/excludehot`
### 电台 - 推荐类型
说明 : 登陆后调用此接口, 可获得电台推荐类型
**接口地址 :** `/dj/category/recommend`
**调用例子 :** `/dj/category/recommend`
### 电台 - 今日优选
说明 : 登陆后调用此接口, 可获得电台今日优选
**接口地址 :** `/dj/today/perfered`
**调用例子 :** `/dj/today/perfered`
### 电台 - 详情
说明 : 登陆后调用此接口 , 传入`rid`, 可获得对应电台的详情介绍
......@@ -1784,8 +1877,7 @@ type='1009' 获取其 id, 如`/search?keywords= 代码时间 &type=1009`
`limit` : 返回数量 , 默认为 30
`offset` : 偏移数量,用于分页 , 如
: 如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
`offset` : 偏移数量,用于分页 , 如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
`asc` : 排序方式,默认为 `false` (新 => 老 ) 设置 `true` 可改为 老 => 新
......
......@@ -3,7 +3,7 @@
> 网易云音乐 NodeJS 版 API
- 全部接口已升级到最新
- 具备登录接口
- 具备登录接口,多达100多个接口
- 更完善的文档
......
......@@ -8,6 +8,7 @@
<link rel="icon" href="favicon.ico">
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta name="referrer" content="never">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
</head>
<body>
......
......@@ -11,4 +11,6 @@ nodejs 版本:
>重现步骤尽量详细,不能含糊不清
>如果不是提建议,提 issues 如果不照着模版来将不会优先处理或直接关闭
\ No newline at end of file
>如果不是提建议,提 issues 如果不照着模版来将不会优先处理或直接关闭
>先在 issues 搜一下是否有相似问题,没有再发
// 首页轮播图
module.exports = (query, request) => {
const type = {
0: 'pc',
1: 'android',
2: 'iphone',
3: 'ipad'
}[query.type || 0] || 'pc';
return request(
'POST', `https://music.163.com/api/v2/banner/get`, {clientType: "pc"},
'POST', `https://music.163.com/api/v2/banner/get`, {clientType: type},
{crypto: 'linuxapi', proxy: query.proxy}
)
}
\ No newline at end of file
// 电台banner
module.exports = (query, request) => {
const data = {};
return request(
"POST",
`http://music.163.com/weapi/djradio/banner/get`,
{},
{ crypto: "weapi", cookie: query.cookie, proxy: query.proxy }
);
};
// dj非热门类型
module.exports = (query, request) => {
return request(
'POST', `http://music.163.com/weapi/djradio/category/excludehot`, {},
{crypto: 'weapi', cookie: query.cookie, proxy: query.proxy}
)
};
\ No newline at end of file
// dj推荐类型
module.exports = (query, request) => {
return request(
'POST', `http://music.163.com/weapi/djradio/home/category/recommend`, {},
{crypto: 'weapi', cookie: query.cookie, proxy: query.proxy}
)
};
\ No newline at end of file
......@@ -2,7 +2,7 @@
module.exports = (query, request) => {
const data = {
limit: query.limit || 10,
limit: query.limit || 30,
offset: query.offset || 0
}
return request(
......
// dj今日优选
module.exports = (query, request) => {
const data = {
page: query.page || 0
};
return request(
'POST', `http://music.163.com/weapi/djradio/home/today/perfered`, data,
{crypto: 'weapi', cookie: query.cookie, proxy: query.proxy}
)
};
\ No newline at end of file
// 动态
module.exports = (query, request) => {
const data={
"pagesize": query.pagesize || 20,
"lasttime": query.lasttime || -1
}
return request(
'POST', `https://music.163.com/weapi/v1/event/get`, {},
'POST', `https://music.163.com/weapi/v1/event/get`, data,
{crypto: 'weapi', cookie: query.cookie, proxy: query.proxy}
)
}
\ No newline at end of file
// 转发动态
const crypto = require('crypto')
module.exports = (query, request) => {
query.cookie.os = 'osx'
const data = {
forwards: query.forwards,
id: query.id,
eventUserId: query.eventUserId,
checkToken:query.checkToken
}
return request(
'POST', `https://music.163.com/weapi/event/forward`, data,
{crypto: 'weapi', ua: 'pc', cookie: query.cookie, proxy: query.proxy}
)
}
\ No newline at end of file
//热门话题
module.exports = (query, request) => {
const data = {
limit: query.limit || 20,
offset: query.offset || 0
}
return request(
'POST', `http://music.163.com/weapi/act/hot`, data,
{crypto: 'weapi', cookie: query.cookie, proxy: query.proxy}
)
};
\ No newline at end of file
// 歌词
module.exports = (query, request) => {
const data={
id:query.id
}
return request(
'POST', `https://music.163.com/weapi/song/lyric?os=osx&id=${query.id}&lv=-1&kv=-1&tv=-1`, {},
{crypto: 'weapi', cookie: query.cookie, proxy: query.proxy}
'POST', `https://music.163.com/weapi/song/lyric?lv=-1&kv=-1&tv=-1`, data,
{crypto: 'linuxapi', cookie: query.cookie, proxy: query.proxy}
)
}
\ No newline at end of file
// 智能播放
module.exports = (query, request) => {
const data = {
songId: query.id,
type: "fromPlayOne",
playlistId: query.pid,
startMusicId: query.sid || query.id,
count: query.count || 1
};
return request(
"POST",
`http://music.163.com/weapi/playmode/intelligence/list`,
data,
{ crypto: "weapi", cookie: query.cookie, proxy: query.proxy }
);
};
// 云盘歌曲删除
module.exports = (query, request) => {
const data = {
songIds: [query.id]
};
return request("POST", `http://music.163.com/weapi/cloud/del`, data, {
crypto: "weapi",
cookie: query.cookie,
proxy: query.proxy
});
};
{
"name": "NeteaseCloudMusicApi",
"version": "3.8.0",
"version": "3.9.0",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>test</title>
</head>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>test</title>
</head>
<body>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js
"></script>
<script>
$.ajax({
url: "http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD",
success: function (data) {
console.log(data)
$.ajax({
url: "http://localhost:3000/recommend/resource ",
xhrFields: {
withCredentials: true //关键
},
success: function (data) {
console.log(data)
},
error: function (err) {
console.log(err)
}
})
},
error: function (err) {
console.log(err)
}
})
<body>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
$.ajax({
url: "http://localhost:3000/login/cellphone?phone=phone&password=password",
xhrFields: {
withCredentials: true
},
success: function (data) {
console.log(data)
$.ajax({
url: "http://localhost:3000/recommend/songs ",
xhrFields: {
withCredentials: true
},
success: function (data) {
console.log(data)
},
error: function (err) {
console.log(err)
}
})
},
error: function (err) {
console.log(err)
}
})
</script>
</body>
</html>
\ No newline at end of file
axios({
url:
"http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD"
}).then(function(res) {
console.log(res.data);
axios({
url:
"http://localhost:3000/recommend/resource",
withCredentials: true //关键
}).then(function(res) {
console.log(res.data);
});
});
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册