making it so instances with a bad status are filtered out

This commit is contained in:
localhost 2023-09-05 15:28:28 +02:00
parent 3a5a086cee
commit b4b62fd314
1 changed files with 1 additions and 1 deletions

View File

@ -3,7 +3,7 @@ const maxRetries = 5
async function getInstance() { async function getInstance() {
const instances = await (await fetch('https://api.invidious.io/instances.json?pretty=1')).json() const instances = await (await fetch('https://api.invidious.io/instances.json?pretty=1')).json()
const sorted = instances.filter(o => o[1].type == 'https') const sorted = instances.filter(o => o[1].type == 'https' && o[1].monitor.statusClass == 'success')
return `https://${sorted[Math.floor(Math.random() * sorted.length)][0]}` return `https://${sorted[Math.floor(Math.random() * sorted.length)][0]}`
} }