-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuduo-List.js
More file actions
102 lines (88 loc) · 3.04 KB
/
Copy pathGuduo-List.js
File metadata and controls
102 lines (88 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
WidgetMetadata = {
id: "guduo_hot_list_makka",
title: "骨朵热度指数榜",
description: "每日更新的CN剧集、动漫、综艺、电影全网热度排行",
author: "𝙈𝙖𝙠𝙠𝙖𝙋𝙖𝙠𝙠𝙖",
version: "1.0.1",
requiredVersion: "0.0.1",
modules: [
{
title: "骨朵热榜",
description: "查看每日各大平台影视热度榜",
functionName: "loadGuduoRank",
requiresWebView: false,
cacheDuration: 3600 * 6, // 缓存 6 小时
params: [
{
name: "category",
title: "榜单分类",
type: "enumeration",
value: "剧集",
enumOptions: [
{ title: "陸劇", value: "剧集" },
{ title: "國漫", value: "动漫" },
{ title: "綜藝", value: "综艺" },
{ title: "電影", value: "电影" }
]
}
]
}
]
};
/**
* 获取并解析 GitHub Raw JSON 数据
*/
async function loadGuduoRank(params = {}) {
try {
const { category = "剧集" } = params;
// GitHub Raw URL (加一个随机数时间戳防止 GitHub 强缓存)
const baseUrl = "https://raw.githubusercontent.com/MakkaPakka518/List/refs/heads/main/data/guduo-hot.json";
const url = `${baseUrl}?t=${Math.floor(Date.now() / 3600000)}`; // 按小时变动时间戳
console.log(`[骨朵榜单] 开始加载: ${category}`);
const response = await Widget.http.get(url, { decodable: true });
// 安全解析 JSON
let data;
if (typeof response.data === "string") {
try {
data = JSON.parse(response.data);
} catch (e) {
console.error("[骨朵榜单] JSON 解析失败:", e);
data = {};
}
} else {
data = response.data;
}
// 校验数据结构
if (!data || !data.categories || !data.categories[category]) {
console.error(`[骨朵榜单] 数据源中未找到分类: ${category}`);
return [];
}
const items = data.categories[category];
const results = [];
// 遍历数据并转为 Forward 认识的 VideoItem 格式
for (const item of items) {
const coverUrl = item.posterPath
? `https://image.tmdb.org/t/p/w500${item.posterPath}`
: "";
results.push({
id: item.tmdbId ? item.tmdbId.toString() : item.title,
type: "tmdb",
// 纯净的剧名
title: item.tmdbTitle || item.title,
// 把排名 (TOP x) 移到了简介的第一行,旁边跟着热度和评分
description: `🏆 TOP ${item.rank} | 🔥 热度: ${item.heat} | 评分: ${item.rating}\n\n${item.overview}`,
coverUrl: coverUrl,
posterPath: item.posterPath,
releaseDate: item.releaseDate,
mediaType: item.mediaType,
rating: item.rating,
genreTitle: item.genreTitle || category
});
}
console.log(`[骨朵榜单] 成功加载 ${results.length} 条数据`);
return results;
} catch (error) {
console.error("[骨朵榜单] 请求发生错误:", error);
throw error;
}
}