From e891287f1a99c948321494fa8de0542ef8bb50c4 Mon Sep 17 00:00:00 2001 From: imsyy Date: Sat, 28 Feb 2026 14:42:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/comment_info_list.js | 30 ++++++++++++++++++++++++++++++ public/docs/home.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 module/comment_info_list.js diff --git a/module/comment_info_list.js b/module/comment_info_list.js new file mode 100644 index 0000000..2c25d99 --- /dev/null +++ b/module/comment_info_list.js @@ -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'), + ) +} diff --git a/public/docs/home.md b/public/docs/home.md index f3ce57f..b552ddf 100644 --- a/public/docs/home.md +++ b/public/docs/home.md @@ -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 可获得对应资源热门评论 ( 不需要登录 )