feat: add Bilibili hot video source and related interfaces (#123)

This commit is contained in:
isomo
2025-04-07 00:23:11 +08:00
committed by GitHub
parent 9efda2ab67
commit a1fe7df520
5 changed files with 96 additions and 1 deletions
+2 -1
View File
@@ -11,4 +11,5 @@ dist/
dev-dist
*.tsbuildinfo
wrangler.toml
imports.app.d.ts
imports.app.d.ts
package-lock.json
+79
View File
@@ -34,6 +34,60 @@ interface WapRes {
total_count: number
}
// Interface for Bilibili Hot Video response
interface HotVideoRes {
code: number
message: string
ttl: number
data: {
list: {
aid: number
videos: number
tid: number
tname: string
copyright: number
pic: string
title: string
pubdate: number
ctime: number
desc: string
state: number
duration: number
owner: {
mid: number
name: string
face: string
}
stat: {
view: number
danmaku: number
reply: number
favorite: number
coin: number
share: number
now_rank: number
his_rank: number
like: number
dislike: number
}
dynamic: string
cid: number
dimension: {
width: number
height: number
rotate: number
}
short_link: string
short_link_v2: string
bvid: string
rcmd_reason: {
content: string
corner_mark: number
}
}[]
}
}
const hotSearch = defineSource(async () => {
const url = "https://s.search.bilibili.com/main/hotword?limit=30"
const res: WapRes = await myFetch(url)
@@ -48,7 +102,32 @@ const hotSearch = defineSource(async () => {
}))
})
const hotVideo = defineSource(async () => {
const url = "https://api.bilibili.com/x/web-interface/popular"
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+`
}
return num.toString()
}
export default defineSource({
"bilibili": hotSearch,
"bilibili-hot-search": hotSearch,
"bilibili-hot-video": hotVideo,
})
+1
View File
@@ -29,6 +29,7 @@
"producthunt": "Product Hunt",
"github-trending-today": "Github-Today",
"bilibili-hot-search": "bilibili-resou",
"bilibili-hot-video": "bilibili-remenshipin",
"kuaishou": "kuaishou",
"kaopu": "kaopuxinwen",
"jin10": "jinshishuju",
+5
View File
@@ -271,6 +271,11 @@ export const originSources = {
column: "china",
type: "hottest",
},
"hot-video": {
title: "热门视频",
column: "china",
type: "hottest",
},
},
},
"kuaishou": {
+9
View File
@@ -345,6 +345,15 @@
"interval": 600000,
"title": "热搜"
},
"bilibili-hot-video": {
"name": "哔哩哔哩",
"type": "hottest",
"column": "china",
"home": "https://www.bilibili.com",
"color": "blue",
"interval": 600000,
"title": "热门视频"
},
"kuaishou": {
"name": "快手",
"type": "hottest",