feat: add bilibili video ranking

This commit is contained in:
Ou
2025-04-07 00:46:15 +08:00
parent a1fe7df520
commit 13e300ccbc
4 changed files with 34 additions and 0 deletions
+18
View File
@@ -119,6 +119,23 @@ const hotVideo = defineSource(async () => {
}))
})
const ranking = defineSource(async () => {
const url = "https://api.bilibili.com/x/web-interface/ranking/v2"
const res: HotVideoRes = await myFetch(url)
return res.data.list.map(video => ({
id: video.bvid,
title: video.title,
url: `https://www.bilibili.com/video/${video.bvid}`,
pubDate: video.pubdate * 1000,
extra: {
info: `${video.owner.name} · ${formatNumber(video.stat.view)}观看 · ${formatNumber(video.stat.like)}点赞`,
hover: video.desc,
icon: proxyPicture(video.pic),
},
}))
})
function formatNumber(num: number): string {
if (num >= 10000) {
return `${Math.floor(num / 10000)}w+`
@@ -130,4 +147,5 @@ export default defineSource({
"bilibili": hotSearch,
"bilibili-hot-search": hotSearch,
"bilibili-hot-video": hotVideo,
"bilibili-ranking": ranking,
})