diff options
author | Michael C <[email protected]> | 2023-07-07 03:14:49 -0400 |
---|---|---|
committer | Michael C <[email protected]> | 2023-07-07 03:14:49 -0400 |
commit | 21bce341f012e64711b306f504e92f94a36d7287 (patch) | |
tree | 75d0c7ea41754bba881a6e0e9c94947f375c0255 /ci/generateList.ts | |
parent | 0d9c3dc807d52101c7196551921deb8d68c01221 (diff) | |
download | SponsorBlock-21bce341f012e64711b306f504e92f94a36d7287.tar.gz SponsorBlock-21bce341f012e64711b306f504e92f94a36d7287.zip |
support piped instances in invidious list
Diffstat (limited to 'ci/generateList.ts')
-rw-r--r-- | ci/generateList.ts | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ci/generateList.ts b/ci/generateList.ts new file mode 100644 index 00000000..7c0f8882 --- /dev/null +++ b/ci/generateList.ts @@ -0,0 +1,63 @@ +/* +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 +*/ + +/* +Criteria for inclusion: +Invidious +- 30d uptime >= 90% +- available for at least 80/90 days +- must have been up for at least 90 days +- HTTPS only +- url includes name (this is to avoid redirects) + +Piped +- 30d uptime >= 90% +- available for at least 80/90 days +- must have been up for at least 90 days +- must not be a wildcard redirect to piped.video +- must be currently up +- must have a functioning frontend +- must have a functioning API +*/ + +import { writeFile, existsSync } from "fs" +import { join } from "path" +import { getInvidiousList } from "./invidiousCI"; +// import { getPipedList } from "./pipedCI"; + +const checkPath = (path: string) => existsSync(path); +const fixArray = (arr: string[]) => [...new Set(arr)].sort() + +async function generateList() { + // import file from https://api.invidious.io/instances.json + const invidiousPath = join(__dirname, "invidious_instances.json"); + // import file from https://github.com/TeamPiped/piped-uptime/raw/master/history/summary.json + const pipedPath = join(__dirname, "piped_instances.json"); + + // check if files exist + if (!checkPath(invidiousPath) || !checkPath(pipedPath)) { + console.log("Missing files") + process.exit(1); + } + + // static non-invidious instances + const staticInstances = ["www.youtubekids.com"]; + // invidious instances + const invidiousList = fixArray(getInvidiousList()) + // piped instnaces + // const pipedList = fixArray(await getPipedList()) + + console.log([...staticInstances, ...invidiousList]) + + writeFile( + join(__dirname, "./invidiouslist.json"), + JSON.stringify([...staticInstances, ...invidiousList]), + (err) => { + if (err) return console.log(err); + } + ); +} +generateList() |