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,9 +1,7 @@
const { create: createPlaylist } = require('./playlist')
const generators = require('../generators')
const logger = require('./logger')
const file = require('./file')
const generators = require('../generators')
const _ = require('lodash')
const { orderBy } = require('natural-orderby')
const PUBLIC_DIR = process.env.PUBLIC_DIR || '.gh-pages'
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs/generators'
@ -13,12 +11,6 @@ const generator = {}
generator.generate = async function (name, streams = []) {
if (typeof generators[name] === 'function') {
try {
streams = orderBy(
streams,
['channel_name', 'status.level', 'resolution.height'],
['asc', 'asc', 'desc']
)
streams = _.uniqBy(streams, stream => stream.channel_id || _.uniqueId())
let output = await generators[name].bind()(streams)
output = Array.isArray(output) ? output : [output]
for (const type of output) {