Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0d9596b2e | ||
|
|
45749e5d34 | ||
|
|
703d2a3e04 | ||
|
|
c575bebfdb | ||
|
|
a98ff3a1ff | ||
|
|
bfd3c4eb93 | ||
|
|
a8516a8ce8 | ||
|
|
f72d953483 | ||
|
|
1fe10b8c0a | ||
|
|
aede5d794c | ||
|
|
15437461da | ||
|
|
4bb900745f | ||
|
|
697f4eeed8 | ||
|
|
a1a3fd065d | ||
|
|
b5bd6e88a6 | ||
|
|
be79e862d6 | ||
|
|
f62dfa6a19 |
@@ -1,3 +1,29 @@
|
|||||||
|
interface NewApiVideoItem {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
desc: string;
|
||||||
|
cover: string;
|
||||||
|
author: string;
|
||||||
|
timestamp: number; // 注意这是毫秒时间戳
|
||||||
|
hot: number;
|
||||||
|
url: string;
|
||||||
|
mobileUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NewApiResponse {
|
||||||
|
code: number;
|
||||||
|
name: string;
|
||||||
|
title: string;
|
||||||
|
type: string;
|
||||||
|
description: string;
|
||||||
|
parameData: any; // 可以根据需要细化
|
||||||
|
link: string;
|
||||||
|
total: number;
|
||||||
|
updateTime: string;
|
||||||
|
fromCache: boolean;
|
||||||
|
data: NewApiVideoItem[]; // 核心数据在这里
|
||||||
|
}
|
||||||
|
|
||||||
interface WapRes {
|
interface WapRes {
|
||||||
code: number
|
code: number
|
||||||
exp_str: string
|
exp_str: string
|
||||||
@@ -120,18 +146,56 @@ const hotVideo = defineSource(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const ranking = defineSource(async () => {
|
const ranking = defineSource(async () => {
|
||||||
const url = "https://api.bilibili.com/x/web-interface/ranking/v2"
|
// 1. 使用新接口的 URL
|
||||||
const res: HotVideoRes = await myFetch(url)
|
const newUrl = "https://api-hot.chgr.cc/bilibili?limit=20"; // <--- 替换成新接口的实际地址
|
||||||
|
// 假设 myFetch 可以正确获取并解析新接口的 JSON
|
||||||
|
const newRes: NewApiResponse = await myFetch(newUrl);
|
||||||
|
|
||||||
return res.data.list.map(video => ({
|
// 2. 数据转换适配层:将 NewApiResponse 转换为符合 HotVideoRes['data']['list'] 结构的数组
|
||||||
|
// 注意:我们只需要构建 map 函数需要的部分即可,不需要严格创建完整的 HotVideoRes
|
||||||
|
const adaptedList = newRes.data.map(newItem => {
|
||||||
|
// 创建一个符合 map 函数内部访问 video 对象结构的临时对象
|
||||||
|
return {
|
||||||
|
bvid: newItem.id,
|
||||||
|
title: newItem.title,
|
||||||
|
pubdate: Math.floor(newItem.timestamp / 1000), // 将毫秒转为秒 (整数)
|
||||||
|
owner: {
|
||||||
|
name: newItem.author,
|
||||||
|
// 如果 map 中需要其他 owner 字段,需提供默认值
|
||||||
|
mid: 0,
|
||||||
|
face: '',
|
||||||
|
},
|
||||||
|
stat: {
|
||||||
|
view: newItem.hot, // 使用 hot 作为观看数 (近似值)
|
||||||
|
like: 0, // <--- 新接口没有点赞数,这里设置为 0
|
||||||
|
// 如果 map 中需要其他 stat 字段,需提供默认值
|
||||||
|
danmaku: 0, reply: 0, favorite: 0, coin: 0, share: 0, now_rank: 0, his_rank: 0, dislike: 0,
|
||||||
|
},
|
||||||
|
desc: newItem.desc,
|
||||||
|
pic: newItem.cover,
|
||||||
|
// --- 以下字段如果 map 中没有用到,可以不映射 ---
|
||||||
|
aid: 0, videos: 1, tid: 0, tname: 'N/A', copyright: 1, ctime: Math.floor(newItem.timestamp / 1000),
|
||||||
|
state: 0, duration: 0, dynamic: '', cid: 0, dimension: { width: 0, height: 0, rotate: 0 },
|
||||||
|
short_link: newItem.url, short_link_v2: newItem.url, rcmd_reason: { content: '', corner_mark: 0 },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 使用转换后的 adaptedList 进行 map 操作,这部分代码保持不变
|
||||||
|
// map 函数现在操作的是我们手动适配过的对象数组
|
||||||
|
return adaptedList.map(video => ({
|
||||||
id: video.bvid,
|
id: video.bvid,
|
||||||
title: video.title,
|
title: video.title,
|
||||||
url: `https://www.bilibili.com/video/${video.bvid}`,
|
url: `https://www.bilibili.com/video/${video.bvid}`, // 保持原来的 URL 拼接方式
|
||||||
pubDate: video.pubdate * 1000,
|
// 或者,如果你想用新接口提供的 URL:
|
||||||
|
// url: video.short_link, // short_link 在适配层映射自 newItem.url
|
||||||
|
pubDate: video.pubdate * 1000, // 将秒转换回毫秒
|
||||||
extra: {
|
extra: {
|
||||||
|
// 注意:因为 like 设置为 0,这里的点赞数会显示为 0
|
||||||
info: `${video.owner.name} · ${formatNumber(video.stat.view)}观看 · ${formatNumber(video.stat.like)}点赞`,
|
info: `${video.owner.name} · ${formatNumber(video.stat.view)}观看 · ${formatNumber(video.stat.like)}点赞`,
|
||||||
|
// 如果不想显示点赞数,可以修改 info 的格式:
|
||||||
|
// info: `${video.owner.name} · ${formatNumber(video.stat.view)}观看`,
|
||||||
hover: video.desc,
|
hover: video.desc,
|
||||||
icon: proxyPicture(video.pic),
|
icon: proxyPicture(video.pic), // pic 来源于 newItem.cover
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ interface Res {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hot = defineSource(async () => {
|
const hot = defineSource(async () => {
|
||||||
const res = await myFetch<Res>("https://linux.do/top/daily.json")
|
const res = await myFetch<Res>("https://n8n.chgr.cc/webhook/api?name=linuxdo")
|
||||||
return res.topic_list.topics
|
return res.topic_list.topics
|
||||||
.filter(k => k.visible && !k.archived && !k.pinned)
|
.filter(k => k.visible && !k.archived && !k.pinned)
|
||||||
.map(k => ({
|
.map(k => ({
|
||||||
|
|||||||
+93
-106
@@ -13,6 +13,81 @@ const Time = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const originSources = {
|
export const originSources = {
|
||||||
|
"bilibili": {
|
||||||
|
name: "哔哩哔哩",
|
||||||
|
color: "blue",
|
||||||
|
home: "https://www.bilibili.com",
|
||||||
|
sub: {
|
||||||
|
"hot-search": {
|
||||||
|
title: "热搜",
|
||||||
|
column: "china",
|
||||||
|
type: "hottest",
|
||||||
|
},
|
||||||
|
"ranking": {
|
||||||
|
title: "排行榜",
|
||||||
|
column: "china",
|
||||||
|
disable: "cf",
|
||||||
|
type: "hottest",
|
||||||
|
interval: Time.Common,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"linuxdo": {
|
||||||
|
name: "LINUX DO",
|
||||||
|
column: "tech",
|
||||||
|
color: "slate",
|
||||||
|
home: "https://linux.do/",
|
||||||
|
disable: "cf",
|
||||||
|
sub: {
|
||||||
|
latest: {
|
||||||
|
title: "最新",
|
||||||
|
home: "https://linux.do/latest",
|
||||||
|
},
|
||||||
|
hot: {
|
||||||
|
title: "今日最热",
|
||||||
|
type: "hottest",
|
||||||
|
interval: Time.Common,
|
||||||
|
home: "https://linux.do/hot",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"github": {
|
||||||
|
name: "Github",
|
||||||
|
color: "gray",
|
||||||
|
home: "https://github.com/",
|
||||||
|
column: "tech",
|
||||||
|
sub: {
|
||||||
|
"trending-today": {
|
||||||
|
title: "Today",
|
||||||
|
type: "hottest",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"douyin": {
|
||||||
|
name: "抖音",
|
||||||
|
type: "hottest",
|
||||||
|
column: "china",
|
||||||
|
color: "gray",
|
||||||
|
home: "https://www.douyin.com",
|
||||||
|
},
|
||||||
|
"kuaishou": {
|
||||||
|
name: "快手",
|
||||||
|
type: "hottest",
|
||||||
|
column: "china",
|
||||||
|
color: "orange",
|
||||||
|
// cloudflare pages cannot access
|
||||||
|
disable: "cf",
|
||||||
|
home: "https://www.kuaishou.com",
|
||||||
|
},
|
||||||
|
"weibo": {
|
||||||
|
name: "微博",
|
||||||
|
title: "实时热搜",
|
||||||
|
type: "hottest",
|
||||||
|
column: "china",
|
||||||
|
color: "red",
|
||||||
|
interval: Time.Realtime,
|
||||||
|
home: "https://weibo.com",
|
||||||
|
},
|
||||||
"v2ex": {
|
"v2ex": {
|
||||||
name: "V2EX",
|
name: "V2EX",
|
||||||
color: "slate",
|
color: "slate",
|
||||||
@@ -31,14 +106,27 @@ export const originSources = {
|
|||||||
color: "blue",
|
color: "blue",
|
||||||
home: "https://www.zhihu.com",
|
home: "https://www.zhihu.com",
|
||||||
},
|
},
|
||||||
"weibo": {
|
"juejin": {
|
||||||
name: "微博",
|
name: "稀土掘金",
|
||||||
title: "实时热搜",
|
column: "tech",
|
||||||
|
color: "blue",
|
||||||
type: "hottest",
|
type: "hottest",
|
||||||
|
home: "https://juejin.cn",
|
||||||
|
},
|
||||||
|
"baidu": {
|
||||||
|
name: "百度热搜",
|
||||||
column: "china",
|
column: "china",
|
||||||
|
color: "blue",
|
||||||
|
type: "hottest",
|
||||||
|
home: "https://www.baidu.com",
|
||||||
|
},
|
||||||
|
"hupu": {
|
||||||
|
name: "虎扑",
|
||||||
|
home: "https://hupu.com",
|
||||||
|
column: "china",
|
||||||
|
title: "主干道热帖",
|
||||||
|
type: "hottest",
|
||||||
color: "red",
|
color: "red",
|
||||||
interval: Time.Realtime,
|
|
||||||
home: "https://weibo.com",
|
|
||||||
},
|
},
|
||||||
"zaobao": {
|
"zaobao": {
|
||||||
name: "联合早报",
|
name: "联合早报",
|
||||||
@@ -93,21 +181,6 @@ export const originSources = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"douyin": {
|
|
||||||
name: "抖音",
|
|
||||||
type: "hottest",
|
|
||||||
column: "china",
|
|
||||||
color: "gray",
|
|
||||||
home: "https://www.douyin.com",
|
|
||||||
},
|
|
||||||
"hupu": {
|
|
||||||
name: "虎扑",
|
|
||||||
home: "https://hupu.com",
|
|
||||||
column: "china",
|
|
||||||
title: "主干道热帖",
|
|
||||||
type: "hottest",
|
|
||||||
color: "red",
|
|
||||||
},
|
|
||||||
"tieba": {
|
"tieba": {
|
||||||
name: "百度贴吧",
|
name: "百度贴吧",
|
||||||
title: "热议",
|
title: "热议",
|
||||||
@@ -250,52 +323,6 @@ export const originSources = {
|
|||||||
type: "hottest",
|
type: "hottest",
|
||||||
home: "https://www.producthunt.com/",
|
home: "https://www.producthunt.com/",
|
||||||
},
|
},
|
||||||
"github": {
|
|
||||||
name: "Github",
|
|
||||||
color: "gray",
|
|
||||||
home: "https://github.com/",
|
|
||||||
column: "tech",
|
|
||||||
sub: {
|
|
||||||
"trending-today": {
|
|
||||||
title: "Today",
|
|
||||||
type: "hottest",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"bilibili": {
|
|
||||||
name: "哔哩哔哩",
|
|
||||||
color: "blue",
|
|
||||||
home: "https://www.bilibili.com",
|
|
||||||
sub: {
|
|
||||||
"hot-search": {
|
|
||||||
title: "热搜",
|
|
||||||
column: "china",
|
|
||||||
type: "hottest",
|
|
||||||
},
|
|
||||||
"hot-video": {
|
|
||||||
title: "热门视频",
|
|
||||||
disable: "cf",
|
|
||||||
column: "china",
|
|
||||||
type: "hottest",
|
|
||||||
},
|
|
||||||
"ranking": {
|
|
||||||
title: "排行榜",
|
|
||||||
column: "china",
|
|
||||||
disable: "cf",
|
|
||||||
type: "hottest",
|
|
||||||
interval: Time.Common,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"kuaishou": {
|
|
||||||
name: "快手",
|
|
||||||
type: "hottest",
|
|
||||||
column: "china",
|
|
||||||
color: "orange",
|
|
||||||
// cloudflare pages cannot access
|
|
||||||
disable: "cf",
|
|
||||||
home: "https://www.kuaishou.com",
|
|
||||||
},
|
|
||||||
"kaopu": {
|
"kaopu": {
|
||||||
name: "靠谱新闻",
|
name: "靠谱新闻",
|
||||||
column: "world",
|
column: "world",
|
||||||
@@ -311,45 +338,12 @@ export const originSources = {
|
|||||||
type: "realtime",
|
type: "realtime",
|
||||||
home: "https://www.jin10.com",
|
home: "https://www.jin10.com",
|
||||||
},
|
},
|
||||||
"baidu": {
|
|
||||||
name: "百度热搜",
|
|
||||||
column: "china",
|
|
||||||
color: "blue",
|
|
||||||
type: "hottest",
|
|
||||||
home: "https://www.baidu.com",
|
|
||||||
},
|
|
||||||
"linuxdo": {
|
|
||||||
name: "LINUX DO",
|
|
||||||
column: "tech",
|
|
||||||
color: "slate",
|
|
||||||
home: "https://linux.do/",
|
|
||||||
disable: "cf",
|
|
||||||
sub: {
|
|
||||||
latest: {
|
|
||||||
title: "最新",
|
|
||||||
home: "https://linux.do/latest",
|
|
||||||
},
|
|
||||||
hot: {
|
|
||||||
title: "今日最热",
|
|
||||||
type: "hottest",
|
|
||||||
interval: Time.Common,
|
|
||||||
home: "https://linux.do/hot",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"ghxi": {
|
"ghxi": {
|
||||||
name: "果核剥壳",
|
name: "果核剥壳",
|
||||||
column: "china",
|
column: "china",
|
||||||
color: "yellow",
|
color: "yellow",
|
||||||
home: "https://www.ghxi.com/",
|
home: "https://www.ghxi.com/",
|
||||||
},
|
},
|
||||||
"smzdm": {
|
|
||||||
name: "什么值得买",
|
|
||||||
column: "china",
|
|
||||||
color: "red",
|
|
||||||
type: "hottest",
|
|
||||||
home: "https://www.smzdm.com",
|
|
||||||
},
|
|
||||||
"nowcoder": {
|
"nowcoder": {
|
||||||
name: "牛客",
|
name: "牛客",
|
||||||
column: "china",
|
column: "china",
|
||||||
@@ -364,13 +358,6 @@ export const originSources = {
|
|||||||
type: "hottest",
|
type: "hottest",
|
||||||
home: "https://sspai.com",
|
home: "https://sspai.com",
|
||||||
},
|
},
|
||||||
"juejin": {
|
|
||||||
name: "稀土掘金",
|
|
||||||
column: "tech",
|
|
||||||
color: "blue",
|
|
||||||
type: "hottest",
|
|
||||||
home: "https://juejin.cn",
|
|
||||||
},
|
|
||||||
"ifeng": {
|
"ifeng": {
|
||||||
name: "凤凰网",
|
name: "凤凰网",
|
||||||
column: "china",
|
column: "china",
|
||||||
|
|||||||
+1
-19
@@ -353,16 +353,6 @@
|
|||||||
"interval": 600000,
|
"interval": 600000,
|
||||||
"title": "热搜"
|
"title": "热搜"
|
||||||
},
|
},
|
||||||
"bilibili-hot-video": {
|
|
||||||
"name": "哔哩哔哩",
|
|
||||||
"type": "hottest",
|
|
||||||
"disable": "cf",
|
|
||||||
"column": "china",
|
|
||||||
"home": "https://www.bilibili.com",
|
|
||||||
"color": "blue",
|
|
||||||
"interval": 600000,
|
|
||||||
"title": "热门视频"
|
|
||||||
},
|
|
||||||
"bilibili-ranking": {
|
"bilibili-ranking": {
|
||||||
"name": "哔哩哔哩",
|
"name": "哔哩哔哩",
|
||||||
"type": "hottest",
|
"type": "hottest",
|
||||||
@@ -442,14 +432,6 @@
|
|||||||
"color": "yellow",
|
"color": "yellow",
|
||||||
"interval": 600000
|
"interval": 600000
|
||||||
},
|
},
|
||||||
"smzdm": {
|
|
||||||
"name": "什么值得买",
|
|
||||||
"type": "hottest",
|
|
||||||
"column": "china",
|
|
||||||
"home": "https://www.smzdm.com",
|
|
||||||
"color": "red",
|
|
||||||
"interval": 600000
|
|
||||||
},
|
|
||||||
"nowcoder": {
|
"nowcoder": {
|
||||||
"name": "牛客",
|
"name": "牛客",
|
||||||
"type": "hottest",
|
"type": "hottest",
|
||||||
@@ -509,4 +491,4 @@
|
|||||||
"interval": 1800000,
|
"interval": 1800000,
|
||||||
"title": "最热"
|
"title": "最热"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user