-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversions.ts
More file actions
93 lines (80 loc) · 2.57 KB
/
Copy pathversions.ts
File metadata and controls
93 lines (80 loc) · 2.57 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
const MANIFEST_BASE_URL =
"https://cdn.jsdelivr.net/gh/intro-skipper/manifest@master";
interface ManifestPlugin {
guid: string;
name: string;
overview: string;
versions: {
version: string;
targetAbi: string;
timestamp: string;
}[];
}
interface SupportedVersion {
jellyfinVersion: string;
pluginVersion: string;
targetAbi: string;
lastUpdated: string;
}
// Cache the versions for 1 hour
let cachedVersions: SupportedVersion[] | null = null;
let lastFetch = 0;
const CACHE_TTL = 60 * 60 * 1000; // 1 hour
async function fetchManifest(
jellyfinMajor: string
): Promise<ManifestPlugin[] | null> {
try {
const response = await fetch(`${MANIFEST_BASE_URL}/${jellyfinMajor}/manifest.json`);
if (!response.ok) return null;
return (await response.json()) as ManifestPlugin[];
} catch {
return null;
}
}
export async function getSupportedVersions(): Promise<SupportedVersion[]> {
// Return cached versions if still valid
if (cachedVersions && Date.now() - lastFetch < CACHE_TTL) {
return cachedVersions;
}
const versions: SupportedVersion[] = [];
const jellyfinVersions = ["10.11", "10.10"];
for (const jellyfinMajor of jellyfinVersions) {
const manifest = await fetchManifest(jellyfinMajor);
if (!manifest) continue;
// Find the Intro Skipper plugin by name
const introSkipper = manifest.find(
(plugin) => plugin.name === "Intro Skipper"
);
if (introSkipper && introSkipper.versions.length > 0) {
// Get the latest version (first in the array)
const latest = introSkipper.versions[0];
if (latest) {
versions.push({
jellyfinVersion: jellyfinMajor,
pluginVersion: latest.version,
targetAbi: latest.targetAbi,
lastUpdated: latest.timestamp,
});
}
}
}
cachedVersions = versions;
lastFetch = Date.now();
return versions;
}
export function formatSupportedVersions(versions: SupportedVersion[]): string {
if (versions.length === 0) {
return "Unable to fetch version information. Please check https://github.com/intro-skipper/intro-skipper for the latest requirements.";
}
const lines = versions.map((v) => {
const date = new Date(v.lastUpdated).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
// Remove trailing .0 from version (e.g., 10.11.6.0 -> 10.11.6)
const targetAbi = v.targetAbi.replace(/\.0$/, "");
return `- **Jellyfin ${v.jellyfinVersion}**: Requires ${targetAbi}+ (Plugin v${v.pluginVersion}, updated ${date})`;
});
return lines.join("\n");
}