Use script to create Invidious instance list file (#3545)

* Use script to create static instance list

* save cors, filter out cors when not electron
This commit is contained in:
ChunkyProgrammer 2023-05-20 09:07:04 -04:00 committed by GitHub
parent d34cf0dd5c
commit ccbf7e2155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 26 deletions

16
_scripts/getInstances.js Normal file
View File

@ -0,0 +1,16 @@
const fs = require('fs/promises')
const invidiousApiUrl = 'https://api.invidious.io/instances.json'
fetch(invidiousApiUrl).then(e => e.json()).then(res => {
const data = res.filter((instance) => {
return !(instance[0].includes('.onion') ||
instance[0].includes('.i2p') ||
!instance[1].api)
}).map((instance) => {
return {
url: instance[1].uri.replace(/\/$/, ''),
cors: instance[1].cors
}
})
fs.writeFile('././static/invidious-instances.json', JSON.stringify(data, null, 2))
})

View File

@ -31,6 +31,7 @@
"dev": "run-s rebuild:electron dev-runner",
"dev:web": "node _scripts/dev-runner.js --web",
"dev-runner": "node _scripts/dev-runner.js",
"get-instances": "node _scripts/getInstances.js",
"lint-all": "run-p lint lint-json lint-style",
"lint-fix": "eslint --fix --ext .js,.vue ./",
"lint": "eslint --ext .js,.vue ./",

View File

@ -44,8 +44,10 @@ const actions = {
if (await pathExists(`${fileLocation}${fileName}`)) {
console.warn('reading static file for invidious instances')
const fileData = await fs.readFile(`${fileLocation}${fileName}`)
instances = JSON.parse(fileData).map((entry) => {
return entry.url
instances = JSON.parse(fileData).filter(e => {
return process.env.IS_ELECTRON || e.cors
}).map(e => {
return e.url
})
}
}

View File

@ -1,25 +1,98 @@
[
{ "url": "https://vid.puffyan.us" },
{ "url": "https://inv.riverside.rocks" },
{ "url": "https://watch.thekitty.zone" },
{ "url": "https://y.com.sb" },
{ "url": "https://invidious.nerdvpn.de" },
{ "url": "https://invidious.tiekoetter.com" },
{ "url": "https://yt.artemislena.eu" },
{ "url": "https://invidious.flokinet.to" },
{ "url": "https://inv.bp.projectsegfau.lt" },
{ "url": "https://inv.odyssey346.dev" },
{ "url": "https://invidious.sethforprivacy.com" },
{ "url": "https://invidious.projectsegfau.lt" },
{ "url": "https://invidious.baczek.me" },
{ "url": "https://yt.funami.tech" },
{ "url": "https://iv.ggtyler.dev" },
{ "url": "https://invidious.lunar.icu" },
{ "url": "https://invidious.privacydev.net" },
{ "url": "https://vid.priv.au" },
{ "url": "https://invidious.0011.lt" },
{ "url": "https://iv.melmac.space" },
{ "url": "https://invidious.esmailelbob.xyz" },
{ "url": "https://invidious.vpsburti.com" },
{ "url": "https://invidious.snopyta.org" }
]
{
"url": "https://vid.puffyan.us",
"cors": true
},
{
"url": "https://inv.riverside.rocks",
"cors": true
},
{
"url": "https://invidious.nerdvpn.de",
"cors": true
},
{
"url": "https://invidious.tiekoetter.com",
"cors": true
},
{
"url": "https://inv.bp.projectsegfau.lt",
"cors": true
},
{
"url": "https://invidious.flokinet.to",
"cors": true
},
{
"url": "https://yt.artemislena.eu",
"cors": true
},
{
"url": "https://inv.pistasjis.net",
"cors": true
},
{
"url": "https://invidious.sethforprivacy.com",
"cors": true
},
{
"url": "https://invidious.projectsegfau.lt",
"cors": true
},
{
"url": "https://invidious.baczek.me",
"cors": true
},
{
"url": "https://yt.funami.tech",
"cors": true
},
{
"url": "https://iv.ggtyler.dev",
"cors": true
},
{
"url": "https://invidious.lunar.icu",
"cors": true
},
{
"url": "https://invidious.privacydev.net",
"cors": true
},
{
"url": "https://vid.priv.au",
"cors": true
},
{
"url": "https://invidious.0011.lt",
"cors": true
},
{
"url": "https://inv.zzls.xyz",
"cors": true
},
{
"url": "https://invidious.slipfox.xyz",
"cors": true
},
{
"url": "https://yt.floss.media",
"cors": false
},
{
"url": "https://invidious.nogafa.org",
"cors": true
},
{
"url": "https://iv.melmac.space",
"cors": true
},
{
"url": "https://invidious.esmailelbob.xyz",
"cors": true
},
{
"url": "https://invidious.snopyta.org",
"cors": true
}
]