Update playlist/generate.js

This commit is contained in:
Aleksandr Statciuk 2022-02-12 03:11:55 +03:00
parent 0d1ab5dfe9
commit 081fcac929
17 changed files with 273 additions and 274 deletions

View file

@ -1,4 +1,5 @@
const { db, generator, api, logger, file } = require('../../core')
const { orderBy } = require('natural-orderby')
const _ = require('lodash')
async function main() {
@ -31,6 +32,12 @@ main()
async function loadStreams() {
await db.streams.load()
let streams = await db.streams.find({ is_broken: false })
streams = _.orderBy(
streams,
['channel_name', 'status.level', 'resolution.height', 'url'],
['asc', 'asc', 'desc', 'asc']
)
streams = _.uniqBy(streams, stream => stream.channel_id || _.uniqueId())
await api.channels.load()
let channels = await api.channels.all()