FreeTube/_scripts/getInstances.js
ChunkyProgrammer ccbf7e2155
Use script to create Invidious instance list file (#3545)
* Use script to create static instance list

* save cors, filter out cors when not electron
2023-05-20 15:07:04 +02:00

17 lines
522 B
JavaScript

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))
})