1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-14 04:17:29 +00:00
cloudtube/background/instances.js
2021-02-06 19:58:43 +13:00

24 lines
509 B
JavaScript

const {request} = require("../utils/request")
let globalList = []
function execute() {
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.replace(/\/+$/, ""))
globalList = list
}).catch(error => {
console.error(error)
})
}
function getInstances() {
return globalList
}
execute()
setInterval(() => {
execute()
}, 60*60*1000)
module.exports.getInstances = getInstances