mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
fix(source): bilibili
This commit is contained in:
parent
c65d818245
commit
77f1a887ea
@ -20,11 +20,12 @@ interface Res {
|
|||||||
|
|
||||||
const hotSearch = defineSource(async () => {
|
const hotSearch = defineSource(async () => {
|
||||||
const url = "https://api.bilibili.com/x/web-interface/wbi/search/square?limit=30"
|
const url = "https://api.bilibili.com/x/web-interface/wbi/search/square?limit=30"
|
||||||
|
const cookie = (await $fetch.raw(`https://bilibili.tv`)).headers.getSetCookie()
|
||||||
const res: Res = await $fetch(url, {
|
const res: Res = await $fetch(url, {
|
||||||
headers: {
|
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",
|
"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"
|
"cookie": cookie[0].replace(/.tv/g, ".com"),
|
||||||
|
"referer": "https://www.bilibili.com/",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ export const originSources = {
|
|||||||
color: "blue",
|
color: "blue",
|
||||||
home: "https://www.bilibili.com",
|
home: "https://www.bilibili.com",
|
||||||
// cloudflare pages cannot access
|
// cloudflare pages cannot access
|
||||||
disable: true,
|
// disable: true,
|
||||||
sub: {
|
sub: {
|
||||||
"hot-search": {
|
"hot-search": {
|
||||||
title: "热搜",
|
title: "热搜",
|
||||||
|
@ -26,3 +26,15 @@ export function relativeTime(timestamp: string | number) {
|
|||||||
export function delay(ms: number) {
|
export function delay(ms: number) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
return new Promise(resolve => setTimeout(resolve, ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function randomUUID() {
|
||||||
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
||||||
|
const r = (Math.random() * 16) | 0
|
||||||
|
const v = c === "x" ? r : (r & 0x3) | 0x8
|
||||||
|
return v.toString(16)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function randomItem<T>(arr: T[]) {
|
||||||
|
return arr[Math.floor(Math.random() * arr.length)]
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user