From 0e1c7eec3d2da795cafb566d40f8801f76d549f3 Mon Sep 17 00:00:00 2001 From: binaryify Date: Sat, 7 Nov 2020 17:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A7=81=E4=BF=A1=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E6=8E=A5=E5=8F=A3=20#1016,=E6=B7=BB=E5=8A=A0=E6=9C=80?= =?UTF-8?q?=E8=BF=91=E8=81=94=E7=B3=BB=E4=BA=BA=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7=E5=8A=A8=E6=80=81=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E4=B8=8D=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98=20#1010,?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20cloudsearch=20=E6=8E=A5=E5=8F=A3=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E9=97=AE=E9=A2=98=20#1015?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.MD | 9 +++++++ README.MD | 2 ++ docs/README.md | 52 ++++++++++++++++++++++++++----------- module/cloudsearch.js | 18 +++++-------- module/msg_recentcontact.js | 16 ++++++++++++ module/send_song.js | 17 ++++++++++++ module/user_event.js | 6 +++-- package.json | 2 +- 8 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 module/msg_recentcontact.js create mode 100644 module/send_song.js diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 22e697c..086e260 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,4 +1,13 @@ # 更新日志 +### 3.46.0 | 2020.11.7 +- 添加私信音乐接口 [#1016](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1016) + +- 添加最近联系人接口 + +- 修复用户动态数量不准确问题 [#1010](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1010) + +- 修复 cloudsearch 接口分页问题 [#1015](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1015) + ### 3.45.3 | 2020.11.1 - `相似歌手`,`首页-发现-圆形图标入口列表`接口增加匿名token[#877](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/877) [#988](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/988) diff --git a/README.MD b/README.MD index 679cf3e..f961f6b 100644 --- a/README.MD +++ b/README.MD @@ -289,6 +289,8 @@ banner({ type:0 }).then(res=>{ 187. 云贝支出 188. 云贝账户信息 189. 账号信息 +190. 最近联系人 +191. 私信音乐 ## 更新日志 diff --git a/docs/README.md b/docs/README.md index e14e077..cb5206c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -205,6 +205,8 @@ 187. 云贝支出 188. 云贝账户信息 189. 账号信息 +190. 最近联系人 +191. 私信音乐 ## 安装 @@ -2771,6 +2773,41 @@ type='1009' 获取其 id, 如`/search?keywords= 代码时间 &type=1009` **调用例子 :** `/send/text?user_ids=32953014&msg=test`,`/send/text?user_ids=32953014,475625142&msg=test` +### 发送私信音乐 + +说明 : 登录后调用此接口 , 传入用户 id 和要发送的信息,音乐id, 可以发送音乐私信,返回内容为历史私信 + +**必选参数 :** + +`user_ids` : 用户 id,多个需用逗号隔开 + +`msg` : 要发送的信息 + +**接口地址 :** `/send/song` + +**调用例子 :** `/send/song?user_ids=1&id=351318&msg=测试` + + +### 发送私信(带歌单) + +说明 : 登录后调用此接口 , 传入用户 id 和要发送的信息和歌单 id, 可以发送带歌单的私信(注:不能发送重复的歌单) + +**必选参数 :** + +`user_ids` : 用户 id,多个需用逗号隔开 + +`msg` : 要发送的信息 + +**接口地址 :** `/send/playlist` + +**调用例子 :** `/send/playlist?msg=test&user_ids=475625142&playlist=705123491`,`/send/playlist?msg=test2&user_ids=475625142,32953014&playlist=705123493` + +### 最近联系人 +说明 : 登录后调用此接口 ,可获取最接近联系人 + +**接口地址 :** `/msg/recentcontact` + +**调用例子 :** `/msg/recentcontact` ### 私信内容 说明 : 登录后调用此接口 , 可获取私信内容 @@ -2789,21 +2826,6 @@ type='1009' 获取其 id, 如`/search?keywords= 代码时间 &type=1009` **调用例子 :** `/msg/private/history?uid=9003` (云音乐小秘书) -### 发送私信(带歌单) - -说明 : 登录后调用此接口 , 传入用户 id 和要发送的信息和歌单 id, 可以发送带歌单的私信(注:不能发送重复的歌单) - -**必选参数 :** - -`user_ids` : 用户 id,多个需用逗号隔开 - -`msg` : 要发送的信息 - -**接口地址 :** `/send/playlist` - -**调用例子 :** `/send/playlist?msg=test&user_ids=475625142&playlist=705123491`,`/send/playlist?msg=test2&user_ids=475625142,32953014&playlist=705123493` - - ### 通知 - 评论 说明 : 登录后调用此接口 ,可获取评论 diff --git a/module/cloudsearch.js b/module/cloudsearch.js index b6e2c26..e768e85 100644 --- a/module/cloudsearch.js +++ b/module/cloudsearch.js @@ -6,16 +6,12 @@ module.exports = (query, request) => { type: query.type || 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频 limit: query.limit || 30, offset: query.offset || 0, + total: true, } - return request( - 'POST', - `https://music.163.com/weapi/cloudsearch/get/web`, - data, - { - crypto: 'weapi', - cookie: query.cookie, - proxy: query.proxy, - realIP: query.realIP, - }, - ) + return request('POST', `https://music.163.com/api/cloudsearch/pc`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }) } diff --git a/module/msg_recentcontact.js b/module/msg_recentcontact.js new file mode 100644 index 0000000..cb17c3a --- /dev/null +++ b/module/msg_recentcontact.js @@ -0,0 +1,16 @@ +// 最近联系 + +module.exports = (query, request) => { + const data = {} + return request( + 'POST', + `https://music.163.com/api/msg/recentcontact/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ) +} diff --git a/module/send_song.js b/module/send_song.js new file mode 100644 index 0000000..fc439aa --- /dev/null +++ b/module/send_song.js @@ -0,0 +1,17 @@ +// 私信歌曲 + +module.exports = (query, request) => { + // query.cookie.os = 'pc' + const data = { + id: query.id, + msg: query.msg || '', + type: 'song', + userIds: '[' + query.user_ids + ']', + } + return request('POST', `https://music.163.com/api/msg/private/send`, data, { + crypto: 'api', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }) +} diff --git a/module/user_event.js b/module/user_event.js index c64e0ca..224626d 100644 --- a/module/user_event.js +++ b/module/user_event.js @@ -1,6 +1,8 @@ // 用户动态 module.exports = (query, request) => { + query.cookie.os = 'ios' + query.cookie.appver = '7.3.27' const data = { getcounts: true, time: query.lasttime || -1, @@ -9,10 +11,10 @@ module.exports = (query, request) => { } return request( 'POST', - `https://music.163.com/weapi/event/get/${query.uid}`, + `https://music.163.com/api/event/get/${query.uid}`, data, { - crypto: 'weapi', + crypto: 'api', cookie: query.cookie, proxy: query.proxy, realIP: query.realIP, diff --git a/package.json b/package.json index 7fff8c5..852de50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "NeteaseCloudMusicApi", - "version": "3.45.3", + "version": "3.46.0", "description": "网易云音乐 NodeJS 版 API", "scripts": { "start": "node app.js",