From 5f6772669937f3b9954d2db29922b14fcec6b949 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 22 Sep 2025 17:07:57 +0800 Subject: [PATCH] fix(bilibili/ranking): update handler to await item mapping for correct item resolution --- lib/routes/bilibili/ranking.ts | 44 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/routes/bilibili/ranking.ts b/lib/routes/bilibili/ranking.ts index c7b5f967f..cf5e8be52 100644 --- a/lib/routes/bilibili/ranking.ts +++ b/lib/routes/bilibili/ranking.ts @@ -214,26 +214,28 @@ async function handler(ctx) { return { title: `bilibili 排行榜-${ridChinese}`, link, - item: list.map(async (item) => { - const subtitles = !config.bilibili.excludeSubtitles && item.bvid ? await cache.getVideoSubtitleAttachment(item.bvid) : []; - return { - title: item.title, - description: utils.renderUGCDescription(embed, item.pic, item.description || item.title, item.aid, undefined, item.bvid), - pubDate: item.create && new Date(item.create).toUTCString(), - author: item.author, - link: !item.create || (new Date(item.create).getTime() / 1000 > utils.bvidTime && item.bvid) ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`, - image: item.pic, - attachments: item.bvid - ? [ - { - url: getVideoUrl(item.bvid), - mime_type: 'text/html', - duration_in_seconds: parseDuration(item.duration), - }, - ...subtitles, - ] - : undefined, - }; - }), + item: await Promise.all( + list.map(async (item) => { + const subtitles = !config.bilibili.excludeSubtitles && item.bvid ? await cache.getVideoSubtitleAttachment(item.bvid) : []; + return { + title: item.title, + description: utils.renderUGCDescription(embed, item.pic, item.description || item.title, item.aid, undefined, item.bvid), + pubDate: item.create && new Date(item.create).toUTCString(), + author: item.author, + link: !item.create || (new Date(item.create).getTime() / 1000 > utils.bvidTime && item.bvid) ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`, + image: item.pic, + attachments: item.bvid + ? [ + { + url: getVideoUrl(item.bvid), + mime_type: 'text/html', + duration_in_seconds: parseDuration(item.duration), + }, + ...subtitles, + ] + : undefined, + }; + }) + ), }; }