fix(bilibili/ranking): update handler to await item mapping for correct item resolution

This commit is contained in:
DIYgod 2025-09-22 17:07:57 +08:00
parent d632b82c4b
commit 5f67726699
No known key found for this signature in database
1 changed files with 23 additions and 21 deletions

View File

@ -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,
};
})
),
};
}