Update generate-playlist.js

This commit is contained in:
Aleksandr Statciuk 2022-02-11 19:56:11 +03:00
parent 442916d130
commit 5ec8619268
65 changed files with 246 additions and 156 deletions

View file

@ -2,15 +2,16 @@ const api = require('../core/api')
const _ = require('lodash')
module.exports = async function (streams = []) {
const output = []
await api.categories.load()
const categories = await api.categories.all()
const output = []
for (const category of categories) {
let items = _.filter(streams, { channel: { categories: [category.id] } })
let items = _.filter(streams, { categories: [{ id: category.id }] })
output.push({ filepath: `categories/${category.id}.m3u`, items })
}
let items = _.filter(streams, stream => !stream.channel || !stream.channel.categories.length)
let items = _.filter(streams, stream => !stream.categories.length)
output.push({ filepath: 'categories/undefined.m3u', items })
return output