fix(route/bilibili/weekly): await all async items before storing in cache (#21365)

This commit is contained in:
Sauce
2026-03-13 00:46:18 +08:00
committed by GitHub
parent d9b9b1ba2d
commit dcbe25be59

View File

@@ -51,23 +51,25 @@ async function handler(ctx) {
title: 'B站每周必看',
link: 'https://www.bilibili.com/h5/weekly-recommend',
description: 'B站每周必看',
item: data.map(async (item) => {
const subtitles = isJsonFeed && !config.bilibili.excludeSubtitles && item.bvid ? await cache.getVideoSubtitleAttachment(item.bvid) : [];
return {
title: item.title,
description: utils.renderUGCDescription(embed, item.cover, `${weekly_name} ${item.title} - ${item.rcmd_reason}`, item.param, undefined, item.bvid),
link: weekly_number > 60 && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.param}`,
attachments: item.bvid
? [
{
url: getVideoUrl(item.bvid),
mime_type: 'text/html',
duration_in_seconds: parseDuration(item.cover_right_text_1),
},
...subtitles,
]
: undefined,
};
}),
item: await Promise.all(
data.map(async (item) => {
const subtitles = isJsonFeed && !config.bilibili.excludeSubtitles && item.bvid ? await cache.getVideoSubtitleAttachment(item.bvid) : [];
return {
title: item.title,
description: utils.renderUGCDescription(embed, item.cover, `${weekly_name} ${item.title} - ${item.rcmd_reason}`, item.param, undefined, item.bvid),
link: weekly_number > 60 && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.param}`,
attachments: item.bvid
? [
{
url: getVideoUrl(item.bvid),
mime_type: 'text/html',
duration_in_seconds: parseDuration(item.cover_right_text_1),
},
...subtitles,
]
: undefined,
};
})
),
};
}