mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-03-21 11:03:15 +00:00
feat: 添加评论统计数据
This commit is contained in:
parent
b027aca40a
commit
e891287f1a
30
module/comment_info_list.js
Normal file
30
module/comment_info_list.js
Normal file
@ -0,0 +1,30 @@
|
||||
// 评论统计数据
|
||||
// type: 0=歌曲 1=MV 2=歌单 3=专辑 4=电台节目 5=视频 6=动态 7=电台
|
||||
// ids: 资源 ID 列表,多个用逗号分隔,如 "123,456"
|
||||
const { resourceTypeMap } = require('../util/config.json')
|
||||
const createOption = require('../util/option.js')
|
||||
|
||||
// 从 resourceTypeMap 的前缀值中提取网易云内部资源类型编号
|
||||
// 例如 "R_SO_4_" -> "4", "A_DR_14_" -> "14"
|
||||
const resourceTypeIdMap = Object.fromEntries(
|
||||
Object.entries(resourceTypeMap).map(([key, prefix]) => [
|
||||
key,
|
||||
prefix.replace(/_$/, '').split('_').pop(),
|
||||
]),
|
||||
)
|
||||
|
||||
module.exports = (query, request) => {
|
||||
const ids = String(query.ids || query.id || '')
|
||||
.split(',')
|
||||
.map((id) => id.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
return request(
|
||||
`/api/resource/commentInfo/list`,
|
||||
{
|
||||
resourceType: resourceTypeIdMap[String(query.type || 0)],
|
||||
resourceIds: JSON.stringify(ids),
|
||||
},
|
||||
createOption(query, 'weapi'),
|
||||
)
|
||||
}
|
||||
@ -1686,6 +1686,38 @@ tags: 歌单标签
|
||||
|
||||
**调用例子 :** `/comment/video?id=89ADDE33C0AAE8EC14B99F6750DB954D`
|
||||
|
||||
### 评论统计数据
|
||||
|
||||
说明 : 调用此接口 , 传入资源类型和资源 id 列表 , 可批量获取对应资源的评论统计数据 ( 不需要登录 )
|
||||
|
||||
**必选参数 :**
|
||||
|
||||
`type`: 数字 , 资源类型 , 对应以下类型
|
||||
|
||||
```
|
||||
0: 歌曲
|
||||
|
||||
1: mv
|
||||
|
||||
2: 歌单
|
||||
|
||||
3: 专辑
|
||||
|
||||
4: 电台节目
|
||||
|
||||
5: 视频
|
||||
|
||||
6: 动态
|
||||
|
||||
7: 电台
|
||||
```
|
||||
|
||||
`ids`: 资源 id 列表 , 多个 id 用逗号分隔 , 如 `123,456`
|
||||
|
||||
**接口地址 :** `/comment/info/list`
|
||||
|
||||
**调用例子 :** `/comment/info/list?type=0&ids=186016,347230`
|
||||
|
||||
### 热门评论
|
||||
|
||||
说明 : 调用此接口 , 传入 type, 资源 id 可获得对应资源热门评论 ( 不需要登录 )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user