Update generate.js

This commit is contained in:
Aleksandr Statciuk 2022-03-14 23:32:46 +03:00
parent a9e58e0ee3
commit a4aa6e7d1e
1 changed files with 6 additions and 1 deletions

View File

@ -33,7 +33,12 @@ async function loadStreams() {
await db.streams.load()
let streams = await db.streams.find({})
streams = _.filter(streams, stream => stream.status !== 'error')
streams = orderBy(streams, ['channel', 'height', 'url'], ['asc', 'desc', 'asc'])
const levels = { online: 1, blocked: 2, timeout: 3, error: 4, default: 5 }
streams = orderBy(
streams,
['channel', s => levels[s.status] || levels['default'], 'height', 'url'],
['asc', 'asc', 'desc', 'asc']
)
streams = _.uniqBy(streams, stream => stream.channel || _.uniqueId())
await api.channels.load()