diff --git a/.gitignore b/.gitignore index 902fa91..41280a1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ dist/ dev-dist *.tsbuildinfo wrangler.toml -imports.app.d.ts \ No newline at end of file +imports.app.d.ts +package-lock.json \ No newline at end of file diff --git a/server/sources/bilibili.ts b/server/sources/bilibili.ts index 26fb026..57c4f32 100644 --- a/server/sources/bilibili.ts +++ b/server/sources/bilibili.ts @@ -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, }) diff --git a/shared/pinyin.json b/shared/pinyin.json index 00f7177..ae1032b 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -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", diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index 79ccd63..4fe4530 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -271,6 +271,11 @@ export const originSources = { column: "china", type: "hottest", }, + "hot-video": { + title: "热门视频", + column: "china", + type: "hottest", + }, }, }, "kuaishou": { diff --git a/shared/sources.json b/shared/sources.json index e2edf60..d5ad0ec 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -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",