From c91beb4aa60e25b1b859a22c97e7cb4e362e43ca Mon Sep 17 00:00:00 2001 From: binaryify Date: Sat, 22 Sep 2018 14:52:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=83=AD=E9=97=A8=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=92=8C=E8=A7=86=E9=A2=91=E8=AF=84=E8=AE=BA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3,=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3=20v2.20.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.MD | 3 ++ docs/README.md | 106 +++++++++++++++++----------------------- package.json | 2 +- router/comment.js | 3 +- router/comment_hot.js | 30 ++++++++++++ router/comment_like.js | 5 +- router/comment_video.js | 21 ++++++++ 7 files changed, 104 insertions(+), 66 deletions(-) create mode 100644 router/comment_hot.js create mode 100644 router/comment_video.js diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d4ab20b..d47afcd 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,8 @@ # 更新日志 +### 2.20.2 | 2018.09.22 +增加热门评论和视频评论接口,更新文档 + ### 2.20.1 | 2018.09.17 优化版本检查功能 diff --git a/docs/README.md b/docs/README.md index 682cdc3..606916f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,65 +14,6 @@ 跨站请求伪造 (CSRF), 伪造请求头 , 调用官方 API -## 版本新特性 - -### 2.19.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. 登录 @@ -151,6 +92,8 @@ banner 接口 , 增加刷新登录接口 , 增加电台相关接口 , 补充评 74. 登录状态 75. 获取视频数据 76. 发送/删除评论 +77. 热门评论 +78. 视频评论 ## 安装 @@ -822,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 即可给对 @@ -833,7 +812,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 `t` : 是否点赞 ,1 为点赞 ,0 为取消点赞 -`tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台对应以下类型 +`tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台, 视频对应以下类型 ``` 0: 歌曲 @@ -841,6 +820,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 2: 歌单 3: 专辑 4: 电台 +5: 视频 ``` **接口地址 :** `comment/like` @@ -859,7 +839,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 **必选参数** `action`:1 发送 - `tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台对应以下类型 + `tpye`: 数字,资源类型,对应歌曲,mv,专辑,歌单,电台,视频对应以下类型 ``` 0: 歌曲 @@ -867,6 +847,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 2: 歌单 3: 专辑 4: 电台 + 5: 视频 ``` `id`:对应资源 id @@ -880,7 +861,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 **必选参数** `action`:0 删除 - `tpye`: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台对应以下类型 + `tpye`: 数字,资源类型,对应歌曲,mv,专辑,歌单,电台,视频对应以下类型 ``` 0: 歌曲 @@ -888,6 +869,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 2: 歌单 3: 专辑 4: 电台 + 5: 视频 ``` `id`:对应资源 id diff --git a/package.json b/package.json index df941af..63bcdd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "NeteaseCloudMusicApi", - "version": "2.20.1", + "version": "2.20.2", "description": "网易云音乐 NodeJS 版 API", "scripts": { "start": "node app.js", diff --git a/router/comment.js b/router/comment.js index 8651ede..336712d 100644 --- a/router/comment.js +++ b/router/comment.js @@ -7,7 +7,8 @@ module.exports = (req, res, createWebAPIRequest, request) => { 1: 'R_MV_5_', //mv 2: 'A_PL_0_', //歌单 3: 'R_AL_3_', //专辑 - 4: 'A_DJ_1_' //电台 + 4: 'A_DJ_1_', //电台 + 5: 'R_VI_62_' // 视频 } const type = typeMap[req.query.type] diff --git a/router/comment_hot.js b/router/comment_hot.js new file mode 100644 index 0000000..4977a52 --- /dev/null +++ b/router/comment_hot.js @@ -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') + ) +} diff --git a/router/comment_like.js b/router/comment_like.js index e3f491a..ff5706e 100644 --- a/router/comment_like.js +++ b/router/comment_like.js @@ -2,13 +2,14 @@ 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 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_' //电台 + 4: 'A_DJ_1_', //电台 + 5: 'R_VI_62_' // 视频 } const type = typeMap[req.query.type] const data = { diff --git a/router/comment_video.js b/router/comment_video.js new file mode 100644 index 0000000..730b382 --- /dev/null +++ b/router/comment_video.js @@ -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') + ) +} -- GitLab