mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Update generate-playlists.js
This commit is contained in:
parent
96403d463e
commit
62ce78bbdf
32 changed files with 187 additions and 117 deletions
|
@ -3,22 +3,23 @@ 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'
|
||||
|
||||
const generator = {}
|
||||
|
||||
generator.generate = async function (name, items = []) {
|
||||
generator.generate = async function (name, streams = []) {
|
||||
if (typeof generators[name] === 'function') {
|
||||
try {
|
||||
items = _.orderBy(
|
||||
items,
|
||||
streams = orderBy(
|
||||
streams,
|
||||
['channel_name', 'status.level', 'resolution.height'],
|
||||
['asc', 'asc', 'desc']
|
||||
)
|
||||
items = _.uniqBy(items, s => s.channel_id || _.uniqueId())
|
||||
let output = await generators[name].bind()(items)
|
||||
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) {
|
||||
const playlist = createPlaylist(type.items, { public: true })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue