From a4aa6e7d1e0031f4e4163406d61d61e94436b3be Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 14 Mar 2022 23:32:46 +0300 Subject: [PATCH] Update generate.js --- scripts/commands/playlist/generate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/commands/playlist/generate.js b/scripts/commands/playlist/generate.js index b2fe64c82b..118f64fd78 100644 --- a/scripts/commands/playlist/generate.js +++ b/scripts/commands/playlist/generate.js @@ -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()