diff options
author | Ajay <[email protected]> | 2024-11-26 02:29:22 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2024-11-26 02:29:22 -0500 |
commit | dbd51d026bd65e287bad8570f61b7bd08f0aa6a1 (patch) | |
tree | 95d2b66c52c994267af33cd46697a8c856d84dd4 /ci/invidiousCI.ts | |
parent | 61f1a8918c4bd92f722c7cfa048f82a18fd0edb5 (diff) | |
parent | 842f7b33b8afbc41a45753c539a4e09fe27d1fdf (diff) | |
download | SponsorBlock-dbd51d026bd65e287bad8570f61b7bd08f0aa6a1.tar.gz SponsorBlock-dbd51d026bd65e287bad8570f61b7bd08f0aa6a1.zip |
Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into pr/Acors24/2086
Diffstat (limited to 'ci/invidiousCI.ts')
-rw-r--r-- | ci/invidiousCI.ts | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/ci/invidiousCI.ts b/ci/invidiousCI.ts index d27a3a4e..d97250d0 100644 --- a/ci/invidiousCI.ts +++ b/ci/invidiousCI.ts @@ -1,31 +1,34 @@ -import { InvidiousInstance, instanceMap } from "./invidiousType" +import { InvidiousInstance, monitor } from "./invidiousType" import * as data from "../ci/invidious_instances.json"; // only https servers -const mapped: instanceMap = data - .filter((i: InvidiousInstance) => i[1]?.type === "https") - .map((instance: InvidiousInstance) => { +const mapped = (data as InvidiousInstance[]) + .filter((i) => + i[1]?.type === "https" + && i[1]?.monitor?.enabled + ) + .map((instance) => { + const monitor = instance[1].monitor as monitor; return { name: instance[0], url: instance[1].uri, - dailyRatios: instance[1].monitor.dailyRatios, - thirtyDayUptime: instance[1]?.monitor["30dRatio"].ratio, + uptime: monitor.uptime || 0, + down: monitor.down ?? false, + created_at: monitor.created_at, } }); // reliability and sanity checks const reliableCheck = mapped .filter(instance => { - // 30d uptime >= 90% - const thirtyDayUptime = Number(instance.thirtyDayUptime) >= 90; - // available for at least 80/90 days - const dailyRatioCheck = instance.dailyRatios.filter(status => status.label !== "black"); - return thirtyDayUptime && dailyRatioCheck.length >= 80; + const uptime = instance.uptime > 80 && !instance.down; + const nameIncluded = instance.url.includes(instance.name); + const ninetyDays = 90 * 24 * 60 * 60 * 1000; + const ninetyDaysAgo = new Date(Date.now() - ninetyDays); + const createdAt = new Date(instance.created_at).getTime() < ninetyDaysAgo.getTime(); + return uptime && nameIncluded && createdAt; }) - // url includes name - .filter(instance => instance.url.includes(instance.name)); -export function getInvidiousList(): string[] { - return reliableCheck.map(instance => instance.name).sort() -}
\ No newline at end of file +export const getInvidiousList = (): string[] => + reliableCheck.map(instance => instance.name).sort()
\ No newline at end of file |