@neteasecloudmusicapienhanced/api 4.30.2 → 4.30.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD CHANGED
@@ -210,6 +210,7 @@ pnpm test
210
210
  ## 贡献与社区
211
211
 
212
212
  - 欢迎提交 PR、Issue 参与维护
213
+ - 要贡献新接口, 请参考[这篇文章](https://www.focalors.ltd/post/how-to-contribute-ncm-api)
213
214
 
214
215
  ### 致谢
215
216
 
@@ -0,0 +1,15 @@
1
+ // 对某一首歌曲发表评论
2
+
3
+ const createOption = require('../util/option.js')
4
+ module.exports = (query, request) => {
5
+ const data = {
6
+ threadId: 'R_SO_4_' + query.id,
7
+ content: query.content,
8
+ resourceType: '0',
9
+ resourceId: '0',
10
+ expressionPicId: '-1',
11
+ bubbleId: '-1',
12
+ checkToken: '',
13
+ }
14
+ return request('/api/resource/comments/add', data, createOption(query))
15
+ }
@@ -0,0 +1,10 @@
1
+ // 删除评论
2
+
3
+ const createOption = require('../util/option.js')
4
+ module.exports = (query, request) => {
5
+ const data = {
6
+ commentId: query.cid,
7
+ threadId: 'R_SO_4_' + query.id,
8
+ }
9
+ return request(`/api/resource/comments/delete`, data, createOption(query))
10
+ }
@@ -0,0 +1,13 @@
1
+ // 回复评论
2
+
3
+ const createOption = require('../util/option.js')
4
+ module.exports = (query, request) => {
5
+ const data = {
6
+ threadId: query.id,
7
+ commentId: query.commentId,
8
+ content: query.content,
9
+ resourceType: '0',
10
+ resourceId: '0',
11
+ }
12
+ return request(`/api/v1/resource/comments/reply`, data, createOption(query))
13
+ }
@@ -0,0 +1,13 @@
1
+ // 搜索建议pc端
2
+
3
+ const createOption = require('../util/option.js')
4
+ module.exports = (query, request) => {
5
+ const data = {
6
+ keyword: query.keyword || '',
7
+ }
8
+ return request(
9
+ `/api/search/pc/suggest/keyword/get`,
10
+ data,
11
+ createOption(query),
12
+ )
13
+ }
@@ -0,0 +1,12 @@
1
+ // 喜欢歌曲
2
+
3
+ const createOption = require('../util/option.js')
4
+ module.exports = (query, request) => {
5
+ const like = query.like !== 'false'
6
+ const data = {
7
+ trackId: query.id,
8
+ userid: query.uid,
9
+ like: like,
10
+ }
11
+ return request(`/api/song/like`, data, createOption(query))
12
+ }
@@ -0,0 +1,53 @@
1
+ // 获取客户端歌曲下载链接 - v1
2
+ // 此版本不再采用 br 作为音质区分的标准
3
+ // 而是采用 standard, exhigh, lossless, hires, jyeffect(高清环绕声), sky(沉浸环绕声), jymaster(超清母带) 进行音质判断
4
+
5
+ const createOption = require('../util/option.js')
6
+ module.exports = async (query, request) => {
7
+ const data = {
8
+ id: query.id,
9
+ immerseType: 'c51',
10
+ level: query.level,
11
+ }
12
+ const response = await request(
13
+ `/api/song/enhance/download/url/v1`,
14
+ data,
15
+ createOption(query),
16
+ )
17
+ let url = response?.body?.data?.[0]?.url
18
+
19
+ if (!url) {
20
+ const fallbackData = {
21
+ ids: `[${query.id}]`,
22
+ level: query.level,
23
+ encodeType: 'flac',
24
+ }
25
+ if (query.level === 'sky') {
26
+ fallbackData.immerseType = 'c51'
27
+ }
28
+ const fallback = await request(
29
+ `/api/song/enhance/player/url/v1`,
30
+ fallbackData,
31
+ createOption(query),
32
+ )
33
+ url = fallback?.body?.data?.[0]?.url
34
+
35
+ if (!url) {
36
+ return fallback
37
+ }
38
+
39
+ return {
40
+ status: 302,
41
+ body: '',
42
+ cookie: fallback.cookie || [],
43
+ redirectUrl: url,
44
+ }
45
+ }
46
+
47
+ return {
48
+ status: 302,
49
+ body: '',
50
+ cookie: response.cookie || [],
51
+ redirectUrl: url,
52
+ }
53
+ }
@@ -5,7 +5,7 @@ module.exports = (query, request) => {
5
5
  const data = {
6
6
  userId: query.uid,
7
7
  time: '0',
8
- limit: query.limit || 30,
8
+ limit: query.limit || 20,
9
9
  offset: query.offset || 0,
10
10
  getcounts: 'true',
11
11
  }
@@ -0,0 +1,13 @@
1
+ // 我创建的播客声音
2
+
3
+ const createOption = require('../util/option.js')
4
+ module.exports = (query, request) => {
5
+ const data = {
6
+ limit: query.limit || 20,
7
+ }
8
+ return request(
9
+ `/api/social/my/created/voicelist/v1`,
10
+ data,
11
+ createOption(query, 'weapi'),
12
+ )
13
+ }
@@ -1,14 +1,11 @@
1
1
  const createOption = require('../util/option.js')
2
2
  module.exports = (query, request) => {
3
3
  const data = {
4
- fee: '-1',
5
- limit: query.limit || '200',
6
- offset: query.offset || '0',
7
- podcastName: query.podcastName || '',
4
+ keyword: query.keyword || '',
5
+ scene: 'normal',
6
+ limit: query.limit || '10',
7
+ offset: query.offset || '30',
8
+ e_r: true,
8
9
  }
9
- return request(
10
- `/api/voice/workbench/voicelist/search`,
11
- data,
12
- createOption(query),
13
- )
10
+ return request(`/api/search/voicelist/get`, data, createOption(query))
14
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neteasecloudmusicapienhanced/api",
3
- "version": "4.30.2",
3
+ "version": "4.30.3",
4
4
  "description": "全网最全的网易云音乐API接口 || A revival project for NeteaseCloudMusicApi Node.js Services (Half Refactor & Enhanced) || 网易云音乐 API 备份 + 增强 || 本项目自原版v4.28.0版本后开始自行维护",
5
5
  "scripts": {
6
6
  "dev": "nodemon app.js",
@@ -783,7 +783,7 @@ tags: 歌单标签
783
783
  **必选参数 :** `uid` : 用户 id
784
784
 
785
785
  **可选参数 :**
786
- `limit` : 返回数量 , 默认为 30
786
+ `limit` : 返回数量 , 默认为 20
787
787
 
788
788
  `offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
789
789
 
@@ -1254,6 +1254,21 @@ tags: 歌单标签
1254
1254
 
1255
1255
  说明:`杜比全景声`音质需要设备支持,不同的设备可能会返回不同码率的 url。cookie 需要传入`os=pc`保证返回正常码率的 url。
1256
1256
 
1257
+ ### 302到音乐 url - 新版
1258
+
1259
+ 说明 : 只允许传入单个`id`,会使用302重定向请求到目标url
1260
+
1261
+ **必选参数 :** `id` : 音乐 id
1262
+ `level`: 播放音质等级, 分为 `standard` => `标准`,`higher` => `较高`, `exhigh`=>`极高`,
1263
+ `lossless`=>`无损`, `hires`=>`Hi-Res`, `jyeffect` => `高清环绕声`, `sky` => `沉浸环绕声`, `dolby` => `杜比全景声`, `jymaster` => `超清母带`
1264
+ `unblock`: 是否使用使用歌曲解锁, 分为`true`和`false`
1265
+
1266
+ **接口地址 :** `/song/url/v1/302`
1267
+
1268
+ **调用例子 :** `/song/url/v1/302?id=1969519579&level=exhigh`
1269
+
1270
+ 说明:`杜比全景声`音质需要设备支持,不同的设备可能会返回不同码率的 url。cookie 需要传入`os=pc`保证返回正常码率的 url。
1271
+
1257
1272
  ### 音乐是否可用
1258
1273
 
1259
1274
  说明: 调用此接口,传入歌曲 id, 可获取音乐是否可用,返回 `{ success: true, message: 'ok' }` 或者 `{ success: false, message: '亲爱的,暂无版权' }`
@@ -4103,13 +4118,15 @@ type='1009' 获取其 id, 如`/search?keywords= 代码时间 &type=1009`
4103
4118
 
4104
4119
  **接口地址:** `/voicelist/search`
4105
4120
 
4106
- **可选参数:**
4121
+ **必选参数:**
4107
4122
 
4108
- `limit`: 取出歌单数量 , 默认为 200
4123
+ `keyword`: 搜索关键词
4109
4124
 
4110
- `offset`: 偏移数量 , 用于分页 , 如 :( 评论页数 -1)\*200, 其中 200 为 limit 的值
4125
+ **可选参数:**
4111
4126
 
4112
- `podcastName`: 播客名称
4127
+ `limit`: 取出歌单数量, 默认为 10
4128
+
4129
+ `offset`: 偏移数量 , 用于分页 , 默认为 30
4113
4130
 
4114
4131
  ### 播客声音列表
4115
4132
 
@@ -5050,6 +5067,82 @@ let data = encodeURIComponent(
5050
5067
 
5051
5068
  **调用例子 :** `/user/playlist/collect?uid=32953014`
5052
5069
 
5070
+ ### 搜索建议 - PC端
5071
+
5072
+ 说明 : 调用此接口, 传入搜索关键词, 获取搜索建议
5073
+
5074
+ **必选参数 :**
5075
+
5076
+ `keyword`: 搜索关键词
5077
+
5078
+ **接口地址 :** `/search/suggest/pc`
5079
+
5080
+ **调用例子 :** `/search/suggest/pc?keyword=海阔天空`
5081
+
5082
+ ### 喜欢歌曲 - 新版
5083
+
5084
+ 说明 : 登录后调用此接口, 传入歌曲 id 用户id和喜欢状态, 可喜欢/取消喜欢歌曲
5085
+
5086
+ **必选参数 :**
5087
+
5088
+ `id`: 歌曲 id
5089
+ `uid`: 用户 id
5090
+ `like`: 喜欢状态, true 表示喜欢, false 表示取消喜欢
5091
+
5092
+ **接口地址 :** `/song/like`
5093
+
5094
+ **调用例子 :** `/song/like?id=2058263032&uid=32953014&like=true`
5095
+
5096
+ ### 我创建的播客声音
5097
+
5098
+ 说明 : 登录后调用此接口, 获取我创建的博客声音
5099
+
5100
+ **可选参数 :**
5101
+
5102
+ `limit` : 返回数量 , 默认为 20
5103
+
5104
+ **接口地址 :** `/voicelist/my/created`
5105
+
5106
+ **调用例子 :** `/voicelist/my/created`
5107
+
5108
+ ### 发布评论
5109
+
5110
+ 说明 : 登录后调用此接口, 传入评论线程 id, 评论内容等信息, 发布评论
5111
+
5112
+ **必选参数 :**
5113
+
5114
+ `id`: 歌曲id
5115
+ `content`: 评论内容
5116
+
5117
+ **接口地址 :** `/comment/add`
5118
+
5119
+ **调用例子 :** `/comment/add?id=2058263032&content=这首歌太棒了!`
5120
+
5121
+ ### 删除评论
5122
+
5123
+ 说明 : 登录后调用此接口, 传入评论 id, 删除评论
5124
+
5125
+ **必选参数 :**
5126
+ `cid`: 评论 id
5127
+ `id`: 歌曲id
5128
+
5129
+ **接口地址 :** `/comment/delete`
5130
+
5131
+ **调用例子 :** `/comment/delete?threadId=2058263032&commentId=123456789`
5132
+
5133
+ ### 回复评论
5134
+
5135
+ 说明 : 登录后调用此接口, 传入歌曲 id, 回复内容等信息, 回复评论
5136
+
5137
+ **必选参数 :**
5138
+ `id`: 歌曲id
5139
+ `commentId`: 被回复的评论 id
5140
+ `content`: 回复内容
5141
+
5142
+ **接口地址 :** `/comment/reply`
5143
+
5144
+ **调用例子 :** `/comment/reply?id=2058263032&commentId=123456789&content=我也觉得这首歌很棒!`
5145
+
5053
5146
  ## 离线访问此文档
5054
5147
 
5055
5148
  此文档同时也是 Progressive Web Apps(PWA), 加入了 serviceWorker, 可离线访问
package/server.js CHANGED
@@ -221,7 +221,7 @@ async function consturctServer(moduleDefs) {
221
221
 
222
222
  for (const moduleDef of moduleDefinitions) {
223
223
  // Register the route.
224
- app.use(moduleDef.route, async (req, res) => {
224
+ app.all(moduleDef.route, async (req, res) => {
225
225
  ;[req.query, req.body].forEach((item) => {
226
226
  // item may be undefined (some environments / middlewares).
227
227
  // Guard access to avoid "Cannot read properties of undefined (reading 'cookie')".
@@ -308,6 +308,11 @@ async function consturctServer(moduleDefs) {
308
308
  }
309
309
  }
310
310
  }
311
+ if (moduleResponse.redirectUrl) {
312
+ res.redirect(moduleResponse.status || 302, moduleResponse.redirectUrl)
313
+ return
314
+ }
315
+
311
316
  res.status(moduleResponse.status).send(moduleResponse.body)
312
317
  } catch (/** @type {*} */ moduleResponse) {
313
318
  logger.error(`${decode(req.originalUrl)}`, {