mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-10 02:27:29 +00:00
24 lines
509 B
JavaScript
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
|