mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
Merge branch 'bandage' of https://github.com/nondanee/NeteaseCloudMusicApi into bandage
This commit is contained in:
commit
f8660cdca6
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,4 +3,6 @@ node_modules
|
||||
*.log
|
||||
|
||||
.idea/
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
|
||||
.vscode
|
33
CHANGELOG.MD
33
CHANGELOG.MD
@ -1,49 +1,76 @@
|
||||
# 更新日志
|
||||
### 2.18.0 | 2018.08.29
|
||||
新增获取视频数据接口,完善文档 #301,感谢 @izhenyuls
|
||||
|
||||
### 2.20.2 | 2018.09.22
|
||||
增加热门评论和视频评论接口,更新文档
|
||||
|
||||
### 2.20.1 | 2018.09.17
|
||||
|
||||
优化版本检查功能
|
||||
|
||||
### 2.20.0 | 2018.09.06
|
||||
|
||||
新增版本检查功能
|
||||
|
||||
### 2.19.0 | 2018.08.29
|
||||
|
||||
新增获取视频数据接口,新增发送/删除评论接口,修复登录状态接口问题,完善文档 #301,感谢 @izhenyuls
|
||||
|
||||
### 2.17.0 | 2018.08.28
|
||||
|
||||
新增登录状态查询接口 #302 ,完善文档,完善路由注册 #297
|
||||
|
||||
### 2.16.0 | 2018.08.09
|
||||
|
||||
- Fixed #288,#289,#290
|
||||
|
||||
解决歌曲URL请求被判 Cheating,修复私信接收异常 #291
|
||||
解决歌曲 URL 请求被判 Cheating,修复私信接收异常 #291
|
||||
|
||||
### 2.15.0 | 2018.07.30
|
||||
|
||||
新增相关歌单推荐和付费精选接口,增加歌手列表接口按首字母索引查找参数
|
||||
|
||||
### 2.14.0 | 2018.07.03
|
||||
|
||||
修复无法使用邮箱问题
|
||||
|
||||
### 2.13.0 | 2018.06.05
|
||||
|
||||
增加自动注册路由的功能,简化路由注册逻辑
|
||||
|
||||
### 2.12.0 | 2018.05.27
|
||||
|
||||
更新文档,优化歌单详情接口
|
||||
|
||||
### 2.11.1 | 2018.05.24
|
||||
|
||||
更新文档,优化`/dj/program`接口
|
||||
|
||||
### 2.11.0 | 2018.05.21
|
||||
|
||||
增加收藏歌手列表&订阅电台列表
|
||||
|
||||
### 2.10.0 | 2018.05.17
|
||||
|
||||
歌单操作调整为批量操作
|
||||
|
||||
### 2.9.9 | 2018.05.16
|
||||
|
||||
Bug 修复
|
||||
|
||||
### 2.9.8 | 2018.05.10
|
||||
|
||||
新增歌手分类列表,收藏/取消收藏歌手接口,新增更新用户信息,更新歌单接口
|
||||
|
||||
### 2.9.6 | 2018.05.08
|
||||
|
||||
新增发送私信相关接口,新增新建歌单,收藏/取消收藏歌单接口
|
||||
|
||||
### 2.9.4 | 2018.05.04
|
||||
|
||||
新增热搜接口,更新 banner 接口
|
||||
|
||||
### 2.9.2 | 2018.02.28
|
||||
|
||||
修复登录失败会崩溃的问题
|
||||
|
||||
### 2.9.1 | 2018.01.26
|
||||
|
@ -95,6 +95,7 @@
|
||||
73. 音乐是否可用检查接口
|
||||
74. 登录状态
|
||||
75. 获取视频数据
|
||||
76. 发送/删除评论
|
||||
|
||||
## 环境要求
|
||||
|
||||
@ -125,7 +126,6 @@ windows 下使用 git-bash 或者 cmder 等终端执行以下命令:
|
||||
$ set PORT=4000 && node app.js
|
||||
```
|
||||
|
||||
|
||||
## 使用文档
|
||||
|
||||
[文档地址](https://binaryify.github.io/NeteaseCloudMusicApi)
|
||||
@ -145,16 +145,12 @@ $ npm test
|
||||

|
||||

|
||||
|
||||
|
||||
## 贡献者
|
||||
|
||||
[<img alt="nujhong" src="https://avatars1.githubusercontent.com/u/23186058?v=4&s=117" width="117">](https://github.com/nujhong)[<img alt="zhangzhengyi12" src="https://avatars1.githubusercontent.com/u/23502338?v=4&s=117" width="117">](https://github.com/zhangzhengyi12)[<img alt="mchome" src="https://avatars1.githubusercontent.com/u/7392658?v=4&s=117" width="117">](https://github.com/mchome)[<img alt="pengx17" src="https://avatars1.githubusercontent.com/u/584378?v=4&s=117" width="117">](https://github.com/pengx17)[<img alt="LengYXin" src="https://avatars1.githubusercontent.com/u/19631404?v=4&s=117" width="117">](https://github.com/LengYXin)[<img alt="rccoder" src="https://avatars3.githubusercontent.com/u/7554325?v=4&s=117" width="117">](https://github.com/rccoder)
|
||||
|
||||
[<img alt="zhixuanziben" src="https://avatars0.githubusercontent.com/u/18346513?v=4&s=117" width="117">](https://github.com/zhixuanziben)[<img alt="LightStrawberry" src="https://avatars3.githubusercontent.com/u/5920513?v=4&s=117" width="117">](https://github.com/LightStrawberry)[<img alt="CeBkCn" src="https://avatars3.githubusercontent.com/u/14861605?v=4&s=117" width="117">](https://github.com/CeBkCn)[<img alt="nondanee" src="https://avatars0.githubusercontent.com/u/26399680?v=4&s=117" width="117">](https://github.com/nondanee)[<img alt="twesix" src="https://avatars1.githubusercontent.com/u/16174733?v=4&s=117" width="117">](https://github.com/twesix)[<img alt="Means88" src="https://avatars1.githubusercontent.com/u/5810331?s=460&v=47" width="117">](https://github.com/Means88)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[The MIT License (MIT)](https://github.com/Binaryify/NeteaseCloudMusicApi/blob/master/LICENSE)
|
||||
|
||||
|
||||
|
122
app.js
122
app.js
@ -1,77 +1,97 @@
|
||||
const express = require("express");
|
||||
const apicache = require("apicache");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const app = express();
|
||||
let cache = apicache.middleware;
|
||||
const express = require('express')
|
||||
const apicache = require('apicache')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const app = express()
|
||||
let cache = apicache.middleware
|
||||
const { exec } = require('child_process');
|
||||
exec('npm info NeteaseCloudMusicApi version', (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
const onlinePackageVersion = stdout.trim();
|
||||
const package = require('./package.json')
|
||||
if (package.version < onlinePackageVersion) {
|
||||
console.log(
|
||||
'最新版:Version:' +
|
||||
onlinePackageVersion +
|
||||
',当前版本:' +
|
||||
package.version +
|
||||
',请及时更新'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
// 跨域设置
|
||||
app.all("*", function(req, res, next) {
|
||||
if (req.path !== "/" && !req.path.includes(".")) {
|
||||
res.header("Access-Control-Allow-Credentials", true);
|
||||
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");
|
||||
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();
|
||||
});
|
||||
next()
|
||||
})
|
||||
|
||||
const onlyStatus200 = (req, res) => res.statusCode === 200;
|
||||
const onlyStatus200 = (req, res) => res.statusCode === 200
|
||||
|
||||
app.use(cache("2 minutes", onlyStatus200));
|
||||
app.use(cache('2 minutes', onlyStatus200))
|
||||
|
||||
app.use(express.static(path.resolve(__dirname, "public")));
|
||||
app.use(express.static(path.resolve(__dirname, 'public')))
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
const proxy = req.query.proxy;
|
||||
const proxy = req.query.proxy
|
||||
if (proxy) {
|
||||
req.headers.cookie = req.headers.cookie + `__proxy__${proxy}`;
|
||||
req.headers.cookie = req.headers.cookie + `__proxy__${proxy}`
|
||||
}
|
||||
next();
|
||||
});
|
||||
next()
|
||||
})
|
||||
|
||||
// 因为这几个文件对外所注册的路由 和 其他文件对外注册的路由规则不一样, 所以专门写个MAP对这些文件做特殊处理
|
||||
const UnusualRouteFileMap = {
|
||||
// key 为文件名, value 为对外注册的路由
|
||||
"daily_signin.js": "/daily_signin",
|
||||
"fm_trash.js": "/fm_trash",
|
||||
"personal_fm.js": "/personal_fm"
|
||||
};
|
||||
'daily_signin.js': '/daily_signin',
|
||||
'fm_trash.js': '/fm_trash',
|
||||
'personal_fm.js': '/personal_fm'
|
||||
}
|
||||
|
||||
// 简化 路由 导出方式, 由这里统一对 router 目录中导出的路由做包装, 路由实际对应的文件只专注做它该做的事情, 不用重复写样板代码
|
||||
const { createWebAPIRequest, request } = require("./util/util");
|
||||
const Wrap = fn => (req, res) => fn(req, res, createWebAPIRequest, request);
|
||||
const { createWebAPIRequest, request } = require('./util/util')
|
||||
const Wrap = fn => (req, res) => fn(req, res, createWebAPIRequest, request)
|
||||
|
||||
// 同步读取 router 目录中的js文件, 根据命名规则, 自动注册路由
|
||||
fs.readdirSync(path.resolve(__dirname, "router")).reverse().forEach(file => {
|
||||
if (/\.js$/i.test(file) === false) {
|
||||
return;
|
||||
}
|
||||
fs.readdirSync(path.resolve(__dirname, 'router'))
|
||||
.reverse()
|
||||
.forEach(file => {
|
||||
if (/\.js$/i.test(file) === false) {
|
||||
return
|
||||
}
|
||||
|
||||
let route;
|
||||
let route
|
||||
|
||||
if (typeof UnusualRouteFileMap[file] !== "undefined") {
|
||||
route = UnusualRouteFileMap[file];
|
||||
} else {
|
||||
route =
|
||||
"/" +
|
||||
file
|
||||
.replace(/\.js$/i, "")
|
||||
.replace(/_/g, "/")
|
||||
.replace(/[A-Z]/g, a => {
|
||||
return "/" + a.toLowerCase();
|
||||
});
|
||||
}
|
||||
if (typeof UnusualRouteFileMap[file] !== 'undefined') {
|
||||
route = UnusualRouteFileMap[file]
|
||||
} else {
|
||||
route =
|
||||
'/' +
|
||||
file
|
||||
.replace(/\.js$/i, '')
|
||||
.replace(/_/g, '/')
|
||||
.replace(/[A-Z]/g, a => {
|
||||
return '/' + a.toLowerCase()
|
||||
})
|
||||
}
|
||||
|
||||
app.use(route, Wrap(require("./router/" + file)));
|
||||
});
|
||||
app.use(route, Wrap(require('./router/' + file)))
|
||||
})
|
||||
|
||||
const port = process.env.PORT || 3000;
|
||||
const port = process.env.PORT || 3000
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`server running @ http://localhost:${port}`);
|
||||
});
|
||||
console.log(`server running @ http://localhost:${port}`)
|
||||
})
|
||||
|
||||
module.exports = app;
|
||||
module.exports = app
|
||||
|
194
docs/README.md
194
docs/README.md
@ -14,55 +14,6 @@
|
||||
|
||||
跨站请求伪造 (CSRF), 伪造请求头 , 调用官方 API
|
||||
|
||||
## 版本新特性
|
||||
### 2.18.0 | 2018.08.29
|
||||
新增获取视频数据接口
|
||||
|
||||
### 2.17.0 | 2018.08.28
|
||||
新增登录状态查询接口
|
||||
|
||||
### 2.15.0 | 2018.07.30
|
||||
新增相关歌单推荐和付费精选接口,增加歌手列表接口按首字母索引查找参数
|
||||
|
||||
### 2.14.0 | 2018.07.03
|
||||
修复无法使用邮箱问题
|
||||
|
||||
### 2.11.0 | 2018.05.21
|
||||
增加收藏歌手列表&订阅电台列表
|
||||
|
||||
### 2.10.0 | 2018.05.17
|
||||
歌单操作调整为批量操作
|
||||
|
||||
### 2.9.8 | 2018.05.10
|
||||
新增歌手分类列表,收藏/取消收藏歌手接口,新增更新用户信息,更新歌单接口
|
||||
|
||||
### 2.9.6 | 2018.05.08
|
||||
新增发送私信相关接口,新增新建歌单,收藏/取消收藏歌单接口
|
||||
|
||||
### 2.9.4 | 2018.05.04
|
||||
新增热搜接口,更新 banner 接口
|
||||
|
||||
### 2.9.0 | 2018.01.26
|
||||
|
||||
docker 构建文件的一些增强以及增加访问日志和调试输出
|
||||
|
||||
### 2.8.1 | 2018.01.04
|
||||
|
||||
添加了 proxy 功能
|
||||
|
||||
### 2.6.4 | 2017.7.16
|
||||
|
||||
添加缓存机制和随机 UA 机制 感谢[@u3u](https://github.com/u3u)
|
||||
[issue:77](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/77) 优化请求
|
||||
代码 感谢 [@huhuime](https://github.com/huhuime)
|
||||
[issue:83](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/83)
|
||||
|
||||
### 2.5.0 | 2017.4.29
|
||||
|
||||
增加 mv/ 专辑 / 歌单评论接口 , 增加云盘相关接口 , 增加获取用户动态 / 信息接口 ,
|
||||
增加关注 / 粉丝列表接口 , 增加收藏歌单接口 , 增加相似 mv/ 歌曲 / 用户接口 , 增加
|
||||
banner 接口 , 增加刷新登录接口 , 增加电台相关接口 , 补充评论接口 , 更新文档
|
||||
|
||||
## 功能特性
|
||||
|
||||
1. 登录
|
||||
@ -140,6 +91,9 @@ banner 接口 , 增加刷新登录接口 , 增加电台相关接口 , 补充评
|
||||
73. 音乐是否可用检查接口
|
||||
74. 登录状态
|
||||
75. 获取视频数据
|
||||
76. 发送/删除评论
|
||||
77. 热门评论
|
||||
78. 视频评论
|
||||
|
||||
## 安装
|
||||
|
||||
@ -214,6 +168,7 @@ $ git clone https://github.com/Binaryify/NeteaseCloudMusicApi && cd NeteaseCloud
|
||||
$ sudo docker build . -t netease-music-api
|
||||
$ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
```
|
||||
|
||||
## 接口文档
|
||||
|
||||
### 调用前须知
|
||||
@ -221,12 +176,12 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
!> 为使用方便,降低门槛,登录接口直接使用了 get 明文请求,请按实际需求对源码修改
|
||||
|
||||
!> 由于接口做了缓存处理 ( 缓存 2 分钟 , 可在 app.js 设置 , 可能会导致登陆后获取不
|
||||
到 cookie), 相同的 url 会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓
|
||||
存结果的接口 , 可在请求 url 后面加一个时间戳参数使 url 不同 , 例子 :
|
||||
`/simi/playlist?id=347230×tamp=1503019930000`
|
||||
到 cookie), 相同的 url 会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓
|
||||
存结果的接口 , 可在请求 url 后面加一个时间戳参数使 url 不同 , 例子 :
|
||||
`/simi/playlist?id=347230×tamp=1503019930000`
|
||||
|
||||
!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` 否则
|
||||
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jQuery, axios 版本也类似
|
||||
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jQuery, axios 版本也类似
|
||||
|
||||
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是等待 2 分钟或者重启服务重新登录后再调用接口
|
||||
|
||||
@ -235,8 +190,8 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
!> 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 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`
|
||||
即可解决
|
||||
在 'util.js' 的 'headers' 处增加 `X-Real-IP':'211.161.244.70' // 任意国内 IP`
|
||||
即可解决
|
||||
|
||||
### 登录
|
||||
|
||||
@ -254,7 +209,6 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
|
||||
~~ 注意 : 此接口被网易和谐了 , 待修复 , 暂时使用手机登录 (2017.05.20)~~
|
||||
|
||||
|
||||
> 更新 : 此接口已经可以正常使用(2018.07.03)
|
||||
|
||||
**必选参数 :** `email`: 163 网易邮箱 `password`: 密码
|
||||
@ -277,11 +231,10 @@ Cookies
|
||||
|
||||
说明 : 调用此接口 , 可刷新登录状态
|
||||
|
||||
|
||||
**调用例子 :** `/login/refresh`
|
||||
|
||||
|
||||
### 登录状态
|
||||
|
||||
说明 : 调用此接口,可获取登录状态
|
||||
|
||||
**接口地址 :** `/login/status`
|
||||
@ -311,6 +264,7 @@ Cookies
|
||||
说明 : 登陆后调用此接口 , 传入相关信息,可以更新用户信息
|
||||
|
||||
**必选参数 :**
|
||||
|
||||
```
|
||||
gender: 性别 0:保密 1:男性 2:女性
|
||||
birthday: 出生日期,时间戳 unix timestamp
|
||||
@ -341,12 +295,14 @@ signature:用户签名
|
||||
|
||||
说明 : 登陆后调用此接口,可以更新用户歌单
|
||||
参数:
|
||||
|
||||
```
|
||||
id:歌单id
|
||||
name:歌单名字
|
||||
desc:歌单描述
|
||||
tags:歌单tag
|
||||
```
|
||||
|
||||
**接口地址 :** `/playlist/update`
|
||||
|
||||
**调用例子 :** `/playlist/update/?id=24381616&name=新歌单&desc=描述&tags=学习`
|
||||
@ -361,7 +317,6 @@ tags:歌单tag
|
||||
|
||||
`msg` : 要发送的信息
|
||||
|
||||
|
||||
**接口地址 :** `/send/text`
|
||||
|
||||
**调用例子 :** `/send/text?user_ids=32953014&msg=test`,`/send/text?user_ids=32953014,475625142&msg=test`
|
||||
@ -378,7 +333,6 @@ tags:歌单tag
|
||||
|
||||
`msg` : 要发送的信息
|
||||
|
||||
|
||||
**接口地址 :** `/send/playlist`
|
||||
|
||||
**调用例子 :** `/send/playlist?msg=test&user_ids=475625142&playlist=705123491`,`/send/playlist?msg=test2&user_ids=475625142,32953014&playlist=705123493`
|
||||
@ -458,6 +412,7 @@ tags:歌单tag
|
||||
**调用例子 :** `/event`
|
||||
|
||||
### 歌手分类列表
|
||||
|
||||
说明 : 调用此接口,可获取歌手分类列表
|
||||
**必选参数 :** `cat` : 即 category Code,歌手类型,默认 1001,返回华语男歌手数据
|
||||
**可选参数 :**
|
||||
@ -465,9 +420,10 @@ tags:歌单tag
|
||||
|
||||
`offset` : 偏移数量,用于分页 , 如
|
||||
: 如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
|
||||
`initial`: 按首字母索引查找参数,如 `/artist/list?cat=1001&initial=b` 返回内容将以 name 字段开头为b或者拼音开头为b为顺序排列
|
||||
`initial`: 按首字母索引查找参数,如 `/artist/list?cat=1001&initial=b` 返回内容将以 name 字段开头为 b 或者拼音开头为 b 为顺序排列
|
||||
|
||||
category Code 取值:
|
||||
|
||||
```
|
||||
入驻歌手 5001
|
||||
华语男歌手 1001
|
||||
@ -489,13 +445,13 @@ category Code 取值:
|
||||
|
||||
**接口地址 :** `/artist/list`
|
||||
|
||||
|
||||
**调用例子 :** `/artist/list?cat=1001`
|
||||
|
||||
返回数据如下图:
|
||||

|
||||
|
||||
### 收藏歌手
|
||||
|
||||
说明 : 调用此接口,可收藏歌手
|
||||
**必选参数 :** `artistId` : 歌手 id
|
||||
|
||||
@ -504,36 +460,36 @@ category Code 取值:
|
||||
**调用例子 :** `/artist/sub?id=6452`
|
||||
|
||||
### 取消收藏歌手
|
||||
|
||||
说明 : 调用此接口,可取消收藏歌手
|
||||
**必选参数 :** `artistId` : 歌手 id
|
||||
|
||||
**接口地址 :** `/artist/unsub`
|
||||
|
||||
|
||||
**调用例子 :** `/artist/unsub?id=6452`
|
||||
|
||||
### 收藏的歌手列表
|
||||
|
||||
说明 : 调用此接口,可获取收藏的歌手列表
|
||||
|
||||
**接口地址 :** `/artist/sublist`
|
||||
|
||||
|
||||
**调用例子 :** `/artist/sublist`
|
||||
|
||||
### 歌单分类
|
||||
|
||||
说明 : 调用此接口,可获取歌单分类,包含 category 信息
|
||||
|
||||
**接口地址 :** `/playlist/catlist`
|
||||
|
||||
|
||||
**调用例子 :** `/playlist/catlist`
|
||||
|
||||
### 热门歌单分类
|
||||
|
||||
说明 : 调用此接口,可获取歌单分类,包含 category 信息
|
||||
|
||||
**接口地址 :** `/playlist/hot`
|
||||
|
||||
|
||||
**调用例子 :** `/playlist/hot`
|
||||
|
||||
### 歌单 ( 网友精选碟 )
|
||||
@ -576,7 +532,7 @@ category Code 取值:
|
||||
|
||||
**必选参数 :** `id` : 歌单 id
|
||||
|
||||
**可选参数 :** `s` : 歌单最近的s个收藏者
|
||||
**可选参数 :** `s` : 歌单最近的 s 个收藏者
|
||||
|
||||
**接口地址 :** `/playlist/detail`
|
||||
|
||||
@ -596,7 +552,7 @@ category Code 取值:
|
||||
|
||||
**必选参数 :** `id` : 音乐 id
|
||||
|
||||
**可选参数 :** `br`: 码率,默认设置了999000即最大码率,如果要 320k 则可设置为 320000,其他类推
|
||||
**可选参数 :** `br`: 码率,默认设置了 999000 即最大码率,如果要 320k 则可设置为 320000,其他类推
|
||||
|
||||
**接口地址 :** `/music/url`
|
||||
|
||||
@ -606,11 +562,12 @@ category Code 取值:
|
||||

|
||||
|
||||
### 音乐是否可用
|
||||
|
||||
说明: 调用此接口,传入歌曲 id, 可获取音乐是否可用,返回 `{ success: true, message: 'ok' }` 或者 `{ success: false, message: '亲爱的,暂无版权' }`
|
||||
|
||||
**必选参数 :** `id` : 歌曲 id
|
||||
|
||||
**可选参数** : `br`: 码率,默认设置了999000即最大码率,如果要 320k 则可设置为 320000,其他类推
|
||||
**可选参数** : `br`: 码率,默认设置了 999000 即最大码率,如果要 320k 则可设置为 320000,其他类推
|
||||
|
||||
**接口地址 :** `/check/music`
|
||||
|
||||
@ -638,6 +595,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||

|
||||
|
||||
### 热搜
|
||||
|
||||
说明 : 调用此接口,可获取热门搜索列表
|
||||
|
||||
**接口地址 :** `/search/hot`
|
||||
@ -678,7 +636,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
|
||||
说明 : 调用此接口 , 传入歌单名字可新建歌单
|
||||
|
||||
**必选参数 :** `name` : 歌单名
|
||||
**必选参数 :** `name` : 歌单名
|
||||
|
||||
**接口地址 :** `/playlist/create`
|
||||
|
||||
@ -692,7 +650,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
说明 : 调用此接口 , 传入类型和歌单 id 可收藏歌单或者取消收藏歌单
|
||||
|
||||
**必选参数 :**
|
||||
`t` : 类型,1:收藏,2:取消收藏
|
||||
`t` : 类型,1:收藏,2:取消收藏
|
||||
`id` : 歌单 id
|
||||
|
||||
**接口地址 :** `/playlist/subscribe`
|
||||
@ -702,7 +660,6 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
返回数据如下图:
|
||||

|
||||
|
||||
|
||||
### 对歌单添加或删除歌曲
|
||||
|
||||
说明 : 调用此接口 , 可以添加歌曲到歌单或者从歌单删除某首歌曲 ( 需要登录 )
|
||||
@ -715,7 +672,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
|
||||
**接口地址 :** `/playlist/tracks`
|
||||
|
||||
**调用例子 :** `/playlist/tracks?op=add&pid=24381616&tracks=347231` ( 对应把歌曲添加到 ' 我 ' 的歌单 , 测试的时候请把这里的 pid 换成你自己的, id 和 tracks 不对可能会报502错误)
|
||||
**调用例子 :** `/playlist/tracks?op=add&pid=24381616&tracks=347231` ( 对应把歌曲添加到 ' 我 ' 的歌单 , 测试的时候请把这里的 pid 换成你自己的, id 和 tracks 不对可能会报 502 错误)
|
||||
|
||||
### 获取歌词
|
||||
|
||||
@ -808,6 +765,42 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
|
||||
**调用例子 :** `/comment/dj?id=794062371`
|
||||
|
||||
### 视频评论
|
||||
|
||||
说明 : 调用此接口 , 传入音乐 id 和 limit 参数 , 可获得该 视频 的所有评论 (
|
||||
不需要登录 )
|
||||
|
||||
**必选参数 :** `id`: 视频的 id
|
||||
|
||||
**可选参数 :** `limit`: 取出评论数量 , 默认为 20
|
||||
|
||||
`offset`: 偏移数量 , 用于分页 , 如 :( 评论页数 -1)\*20, 其中 20 为 limit 的值
|
||||
|
||||
**接口地址 :** `/comment/video`
|
||||
|
||||
**调用例子 :** `/comment/video?id=89ADDE33C0AAE8EC14B99F6750DB954D`
|
||||
|
||||
### 热门评论
|
||||
说明 : 调用此接口 , 传入 type, 资源 id 可获得对应资源热门评论 ( 不需要登录 )
|
||||
|
||||
**必选参数 :**
|
||||
|
||||
`id` : 资源 id
|
||||
|
||||
`tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台, 视频对应以下类型
|
||||
|
||||
```
|
||||
0: 歌曲
|
||||
1: mv
|
||||
2: 歌单
|
||||
3: 专辑
|
||||
4: 电台
|
||||
5: 视频
|
||||
```
|
||||
**接口地址 :** `/comment/hot`
|
||||
|
||||
**调用例子 :** `/comment/hot?id=186016&type=0`
|
||||
|
||||
### 给评论点赞
|
||||
|
||||
说明 : 调用此接口 , 传入 type, 资源 id, 和评论 id cid 和 是否点赞参数 t 即可给对
|
||||
@ -819,7 +812,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
|
||||
`t` : 是否点赞 ,1 为点赞 ,0 为取消点赞
|
||||
|
||||
`tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台对应以下类型
|
||||
`tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台, 视频对应以下类型
|
||||
|
||||
```
|
||||
0: 歌曲
|
||||
@ -827,6 +820,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
2: 歌单
|
||||
3: 专辑
|
||||
4: 电台
|
||||
5: 视频
|
||||
```
|
||||
|
||||
**接口地址 :** `comment/like`
|
||||
@ -834,6 +828,55 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具
|
||||
**调用例子 :** `/comment/like?id=186016&cid=4956438&t=1&type=0` 对应给晴天最热门
|
||||
的那条评论点赞
|
||||
|
||||
### 发送/删除评论
|
||||
|
||||
说明 : 调用此接口,可发送评论或者删除评论
|
||||
|
||||
**接口地址 :** `/comment`
|
||||
|
||||
1. 发送评论
|
||||
|
||||
**必选参数**
|
||||
`action`:1 发送
|
||||
|
||||
`tpye`: 数字,资源类型,对应歌曲,mv,专辑,歌单,电台,视频对应以下类型
|
||||
|
||||
```
|
||||
0: 歌曲
|
||||
1: mv
|
||||
2: 歌单
|
||||
3: 专辑
|
||||
4: 电台
|
||||
5: 视频
|
||||
```
|
||||
|
||||
`id`:对应资源 id
|
||||
|
||||
`content` :要发送的内容
|
||||
|
||||
**调用例子** : `/comment?action=1&type=1&id=5436712&content=test` (往广岛之恋 mv 发送评论: test)
|
||||
|
||||
2. 删除评论
|
||||
|
||||
**必选参数**
|
||||
`action`:0 删除
|
||||
|
||||
`tpye`: 数字,资源类型,对应歌曲,mv,专辑,歌单,电台,视频对应以下类型
|
||||
|
||||
```
|
||||
0: 歌曲
|
||||
1: mv
|
||||
2: 歌单
|
||||
3: 专辑
|
||||
4: 电台
|
||||
5: 视频
|
||||
```
|
||||
|
||||
`id`:对应资源 id
|
||||
`content` :内容 id,可通过 `/comment/mv` 等接口获取
|
||||
|
||||
**调用例子** : `/comment?action=0&type=1&id=5436712&commentId=1535550516319` (在广岛之恋 mv 删除评论)
|
||||
|
||||
### banner
|
||||
|
||||
说明 : 调用此接口 , 可获取 banner( 轮播图 ) 数据注 : 因参数未知 , 只能获取比较旧
|
||||
@ -1184,7 +1227,7 @@ MV 数据 , 数据包含 mv 名字 , 歌手 , 发布时间 , mv 视频地址等
|
||||
说明 : 调用此接口 , 传入视频的 id ( 在搜索音乐的时候传 type=1014 获得 ) , 可获取对应
|
||||
视频数据,其中视频网易做了防盗链处理 , 可能不能直接播放 , 需要播放的话需要调用 ' 播放 mv/视频' 接口
|
||||
|
||||
**必选参数 :** ` id`: 视频 的 id
|
||||
**必选参数 :** `id`: 视频 的 id
|
||||
|
||||
**接口地址 :** `/video`
|
||||
|
||||
@ -1312,7 +1355,6 @@ type='1009' 获取其 id, 如`/search?keywords= 代码时间 &type=1009`
|
||||
|
||||
说明 : 登陆后调用此接口 , 可获取订阅的电台列表
|
||||
|
||||
|
||||
**接口地址 :** `/dj/sublist`
|
||||
|
||||
**调用例子 :** `/dj/sublist`
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "2.18.0",
|
||||
"version": "2.20.2",
|
||||
"description": "网易云音乐 NodeJS 版 API",
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
|
46
router/comment.js
Normal file
46
router/comment.js
Normal file
@ -0,0 +1,46 @@
|
||||
module.exports = (req, res, createWebAPIRequest, request) => {
|
||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
const id = req.query.id
|
||||
const action = req.query.action == 1 ? 'add' : 'delete'
|
||||
const typeMap = {
|
||||
0: 'R_SO_4_', //歌曲
|
||||
1: 'R_MV_5_', //mv
|
||||
2: 'A_PL_0_', //歌单
|
||||
3: 'R_AL_3_', //专辑
|
||||
4: 'A_DJ_1_', //电台
|
||||
5: 'R_VI_62_' // 视频
|
||||
}
|
||||
const type = typeMap[req.query.type]
|
||||
|
||||
let data = {
|
||||
threadId: `${type}${id}`,
|
||||
csrf_token: ''
|
||||
}
|
||||
|
||||
if (action == 'add') {
|
||||
data = {
|
||||
...data,
|
||||
content: req.query.content
|
||||
}
|
||||
}
|
||||
|
||||
if (action == 'delete') {
|
||||
data = {
|
||||
...data,
|
||||
commentId: req.query.commentId
|
||||
}
|
||||
}
|
||||
|
||||
const url = `/weapi/resource/comments/${action}`
|
||||
|
||||
// console.log({ url, data })
|
||||
createWebAPIRequest(
|
||||
'music.163.com',
|
||||
url,
|
||||
'POST',
|
||||
data,
|
||||
cookie,
|
||||
music_req => res.send(music_req),
|
||||
err => res.status(502).send('fetch error')
|
||||
)
|
||||
}
|
30
router/comment_hot.js
Normal file
30
router/comment_hot.js
Normal file
@ -0,0 +1,30 @@
|
||||
module.exports = (req, res, createWebAPIRequest) => {
|
||||
let cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
cookie += ';os=pc;'
|
||||
const rid = req.query.id
|
||||
const typeMap = {
|
||||
0: 'R_SO_4_', // 歌曲
|
||||
1: 'R_MV_5_', // mv
|
||||
2: 'A_PL_0_', // 歌单
|
||||
3: 'R_AL_3_', // 专辑
|
||||
4: 'A_DJ_1_', // 电台,
|
||||
5: 'R_VI_62_' // 视频
|
||||
}
|
||||
const type = typeMap[req.query.type]
|
||||
const data = {
|
||||
offset: req.query.offset || 0,
|
||||
rid: rid,
|
||||
limit: req.query.limit || 20,
|
||||
csrf_token: ''
|
||||
}
|
||||
const url = `/weapi/v1/resource/hotcomments/${type}${rid}`
|
||||
createWebAPIRequest(
|
||||
'music.163.com',
|
||||
url,
|
||||
'POST',
|
||||
data,
|
||||
cookie,
|
||||
music_req => res.send(music_req),
|
||||
err => res.status(502).send('fetch error')
|
||||
)
|
||||
}
|
@ -1,32 +1,32 @@
|
||||
//comment like
|
||||
//未知 api
|
||||
module.exports = (req, res, createWebAPIRequest, request) => {
|
||||
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||
const cid = req.query.cid; //评论 id
|
||||
const id = req.query.id; // 歌曲 id
|
||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
const cid = req.query.cid //评论 id
|
||||
const id = req.query.id
|
||||
const typeMap = {
|
||||
0: "R_SO_4_", //歌曲
|
||||
1: "R_MV_5_", //mv
|
||||
2: "A_PL_0_", //歌单
|
||||
3: "R_AL_3_", //专辑
|
||||
4: "A_DJ_1_" //电台
|
||||
};
|
||||
const type = typeMap[req.query.type];
|
||||
0: 'R_SO_4_', //歌曲
|
||||
1: 'R_MV_5_', //mv
|
||||
2: 'A_PL_0_', //歌单
|
||||
3: 'R_AL_3_', //专辑
|
||||
4: 'A_DJ_1_', //电台
|
||||
5: 'R_VI_62_' // 视频
|
||||
}
|
||||
const type = typeMap[req.query.type]
|
||||
const data = {
|
||||
threadId: `${type}${id}`,
|
||||
commentId: cid,
|
||||
csrf_token: ""
|
||||
};
|
||||
const action = req.query.t == 1 ? "like" : "unlike";
|
||||
csrf_token: ''
|
||||
}
|
||||
const action = req.query.t == 1 ? 'like' : 'unlike'
|
||||
|
||||
const url = `/weapi/v1/comment/${action}`;
|
||||
const url = `/weapi/v1/comment/${action}`
|
||||
createWebAPIRequest(
|
||||
"music.163.com",
|
||||
'music.163.com',
|
||||
url,
|
||||
"POST",
|
||||
'POST',
|
||||
data,
|
||||
cookie,
|
||||
music_req => res.send(music_req),
|
||||
err => res.status(502).send("fetch error")
|
||||
);
|
||||
};
|
||||
err => res.status(502).send('fetch error')
|
||||
)
|
||||
}
|
||||
|
21
router/comment_video.js
Normal file
21
router/comment_video.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports = (req, res, createWebAPIRequest, request) => {
|
||||
const rid = req.query.id
|
||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
const data = {
|
||||
offset: req.query.offset || 0,
|
||||
rid: rid,
|
||||
limit: req.query.limit || 20,
|
||||
csrf_token: ''
|
||||
}
|
||||
createWebAPIRequest(
|
||||
'music.163.com',
|
||||
`/weapi/v1/resource/comments/R_VI_62_${rid}/?csrf_token=`,
|
||||
'POST',
|
||||
data,
|
||||
cookie,
|
||||
music_req => {
|
||||
res.send(music_req)
|
||||
},
|
||||
err => res.status(502).send('fetch error')
|
||||
)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user