mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
Fetch instance list from instances.invidio.us
This commit is contained in:
parent
c55429ac49
commit
806494f5e0
3 changed files with 27 additions and 7 deletions
23
background/instances.js
Normal file
23
background/instances.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const {request} = require("../utils/request")
|
||||
|
||||
let globalList = []
|
||||
|
||||
function execute() {
|
||||
return request("https://instances.invidio.us/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
|
||||
Loading…
Add table
Add a link
Reference in a new issue