1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-10 02:27:29 +00:00
cloudtube/background/instances.js

24 lines
489 B
JavaScript
Raw Normal View History

const {request} = require("../utils/request")
let globalList = []
function execute() {
2021-01-23 08:58:30 +00:00
return request("https://api.invidious.io/instances.json?sort_by=health").then(res => res.json()).then(list => {
list = list.filter(i => i[1].type === "https").map(i => i[1].uri)
globalList = list
}).catch(error => {
console.error(error)
})
}
function getInstances() {
return globalList
}
execute()
setInterval(() => {
execute()
}, 60*60*1000)
module.exports.getInstances = getInstances