2021-01-13 10:48:18 +00:00
|
|
|
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 => {
|
2021-02-06 06:58:43 +00:00
|
|
|
list = list.filter(i => i[1].type === "https").map(i => i[1].uri.replace(/\/+$/, ""))
|
2021-01-13 10:48:18 +00:00
|
|
|
globalList = list
|
|
|
|
}).catch(error => {
|
|
|
|
console.error(error)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getInstances() {
|
|
|
|
return globalList
|
|
|
|
}
|
|
|
|
|
|
|
|
execute()
|
|
|
|
setInterval(() => {
|
|
|
|
execute()
|
|
|
|
}, 60*60*1000)
|
|
|
|
|
|
|
|
module.exports.getInstances = getInstances
|