mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-23 08:07:31 +00:00
Don't crash if instances are unavailable
This commit is contained in:
parent
59266a6419
commit
31ba4035b0
@ -1,4 +1,5 @@
|
||||
const {request} = require("../utils/request")
|
||||
const {log} = require("pinski/util/common")
|
||||
|
||||
class InstancesList {
|
||||
constructor() {
|
||||
@ -16,9 +17,13 @@ class InstancesList {
|
||||
*/
|
||||
update() {
|
||||
return this.inflight = 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(/\/+$/, ""))
|
||||
this.list = list
|
||||
return list.filter(i => i[1].type === "https").map(i => i[1].uri.replace(/\/+$/, ""))
|
||||
}).catch(e => {
|
||||
log(`[background/instances] ${e.message}`, "warning")
|
||||
return []
|
||||
}).then(list => {
|
||||
this.inflight = null
|
||||
this.list = list
|
||||
return this.list
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user