aboutsummaryrefslogtreecommitdiffhomepage
path: root/ci
diff options
context:
space:
mode:
authorMichael C <[email protected]>2021-11-30 16:44:42 -0500
committerMichael C <[email protected]>2021-11-30 18:17:28 -0500
commitdc47b9ffd2049e8a11e566dbf2753fbe59e17465 (patch)
tree842914e8fd12dfb2ec21b9f84e623482ac08e084 /ci
parente4e453a11c776bb4127e07252f868c3e54e3e386 (diff)
downloadSponsorBlock-dc47b9ffd2049e8a11e566dbf2753fbe59e17465.tar.gz
SponsorBlock-dc47b9ffd2049e8a11e566dbf2753fbe59e17465.zip
appease CI/ webpack
move to ci/ change triggers
Diffstat (limited to 'ci')
-rw-r--r--ci/invidiousCI.ts55
-rw-r--r--ci/invidiouslist.json1
2 files changed, 56 insertions, 0 deletions
diff --git a/ci/invidiousCI.ts b/ci/invidiousCI.ts
new file mode 100644
index 00000000..05cf8f8f
--- /dev/null
+++ b/ci/invidiousCI.ts
@@ -0,0 +1,55 @@
+/*
+This file is only ran by GitHub Actions in order to populate the Invidious instances list
+
+This file should not be shipped with the extension
+*/
+
+import { writeFile, existsSync } from 'fs';
+import { join } from 'path';
+
+// import file from https://api.invidious.io/instances.json
+if (!existsSync('./data.json')) {
+ process.exit(1);
+}
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import * as data from "./data.json";
+
+type instanceMap = {
+ name: string,
+ url: string,
+ dailyRatios: {ratio: string, label: string }[],
+ thirtyDayUptime: string
+}[]
+
+// only https servers
+const mapped: instanceMap = data
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ .filter((i: any) => i[1]?.type === 'https')
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ .map((instance: any) => {
+ return {
+ name: instance[0],
+ url: instance[1].uri,
+ dailyRatios: instance[1].monitor.dailyRatios,
+ thirtyDayUptime: instance[1]?.monitor['30dRatio'].ratio,
+ }
+ })
+
+// 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)
+ })
+ // url includes name
+ .filter(instance => instance.url.includes(instance.name))
+
+// finally map to array
+const result: string[] = reliableCheck.map(instance => instance.name)
+writeFile(join(__dirname, "./invidiouslist.json"), JSON.stringify(result), (err) => {
+ if (err) return console.log(err);
+}) \ No newline at end of file
diff --git a/ci/invidiouslist.json b/ci/invidiouslist.json
new file mode 100644
index 00000000..905605d8
--- /dev/null
+++ b/ci/invidiouslist.json
@@ -0,0 +1 @@
+["yewtu.be","invidious.snopyta.org","vid.puffyan.us","invidious.kavin.rocks","invidio.xamh.de","invidious-us.kavin.rocks","inv.riverside.rocks","vid.mint.lgbt","youtube.076.ne.jp","invidious.namazso.eu"] \ No newline at end of file