Skip to content

Commit

Permalink
Sort piped instances by uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
OMGDuke committed Apr 9, 2024
1 parent f54d57b commit 7334b5a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/actions/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export async function getAudioUrlFromVideoId(
res.result?.body
)

const audios = audioFormats.audioStreams.filter(
(aud) => aud.mimeType?.includes('audio/webm')
const audios = audioFormats.audioStreams.filter((aud) =>
aud.mimeType?.includes('audio/webm')
)
const audio = audios.reduce((prev, current) => {
return prev.bitrate > current.bitrate ? prev : current
Expand Down Expand Up @@ -149,12 +149,14 @@ export async function getPipedInstances(
}[] = JSON.parse(res.result?.body)

if (instances?.length) {
return instances.map((ins) => ({
name: `${ins.locations} ${ins.name || ins.api_url} ${
ins.uptime_30d ? `| Uptime (30d): ${Math.floor(ins.uptime_30d)}%` : ''
}`,
url: ins.api_url
}))
return instances
.sort((a, b) => b.uptime_30d - a.uptime_30d)
.map((ins) => ({
name: `${ins.locations} ${ins.name || ins.api_url} ${
ins.uptime_30d ? `| Uptime: ${Math.floor(ins.uptime_30d)}%` : ''
}`,
url: ins.api_url
}))
}
return []
}
Expand Down

0 comments on commit 7334b5a

Please sign in to comment.