mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-23 16:17:30 +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 {request} = require("../utils/request")
|
||||||
|
const {log} = require("pinski/util/common")
|
||||||
|
|
||||||
class InstancesList {
|
class InstancesList {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -16,9 +17,13 @@ class InstancesList {
|
|||||||
*/
|
*/
|
||||||
update() {
|
update() {
|
||||||
return this.inflight = request("https://api.invidious.io/instances.json?sort_by=health").then(res => res.json()).then(list => {
|
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(/\/+$/, ""))
|
return list.filter(i => i[1].type === "https").map(i => i[1].uri.replace(/\/+$/, ""))
|
||||||
this.list = list
|
}).catch(e => {
|
||||||
|
log(`[background/instances] ${e.message}`, "warning")
|
||||||
|
return []
|
||||||
|
}).then(list => {
|
||||||
this.inflight = null
|
this.inflight = null
|
||||||
|
this.list = list
|
||||||
return this.list
|
return this.list
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user