feat(source): add bilbil (#4)
* feat(source): add bilbil * Delete server/utils/format.ts 热度没有意义,用 icon 好一点 * Update sources.ts * Update bilibili.ts close #5 --------- Co-authored-by: Ou <[email protected]>
This commit is contained in:
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
|
||||
declare module 'glob:./sources/{*.ts,**/index.ts}' {
|
||||
export const _36kr: typeof import('./sources/_36kr')
|
||||
export const bilibili: typeof import('./sources/bilibili')
|
||||
export const cankaoxiaoxi: typeof import('./sources/cankaoxiaoxi')
|
||||
export const cls: typeof import('./sources/cls/index')
|
||||
export const coolapk: typeof import('./sources/coolapk/index')
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
interface Res {
|
||||
code: number
|
||||
message: string
|
||||
ttl: number
|
||||
data: {
|
||||
trending: {
|
||||
title: string
|
||||
trackid: string
|
||||
list: {
|
||||
keyword: string
|
||||
show_name: string
|
||||
icon: string
|
||||
uri: string
|
||||
goto: string
|
||||
heat_score: number
|
||||
}[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const hotSearch = defineSource(async () => {
|
||||
const url = "https://api.bilibili.com/x/web-interface/wbi/search/square?limit=30"
|
||||
|
||||
const res: Res = await $fetch(url, {
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
||||
// "Cookie": "your_cookie_here"
|
||||
},
|
||||
})
|
||||
|
||||
return res.data.trending.list.map(k => ({
|
||||
id: k.keyword,
|
||||
title: k.show_name,
|
||||
url: `https://search.bilibili.com/all?keyword=${encodeURIComponent(k.keyword)}`,
|
||||
extra: {
|
||||
icon: k.icon && `/api/proxy?img=${encodeURIComponent(k.icon)}`,
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
export default defineSource({
|
||||
"bilibili": hotSearch,
|
||||
"bilibili-hot-search": hotSearch,
|
||||
})
|
||||
@@ -214,6 +214,17 @@ export const originSources = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"bilibili": {
|
||||
name: "哔哩哔哩",
|
||||
color: "blue",
|
||||
home: "https://www.bilibili.com",
|
||||
sub: {
|
||||
"hot-search": {
|
||||
title: "热搜",
|
||||
type: "hottest",
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const satisfies Record<string, OriginSource>
|
||||
|
||||
export const sources = genSources()
|
||||
|
||||
Reference in New Issue
Block a user