iptv/scripts/generators/categories.js
Aleksandr Statciuk 86e0c2f7da wip
2022-02-07 02:27:15 +03:00

18 lines
549 B
JavaScript

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()
for (const category of categories) {
let items = _.filter(streams, { channel: { categories: [category.id] } })
output.push({ filepath: `categories/${category.id}.m3u`, items })
}
let items = _.filter(streams, s => !s.categories.length)
output.push({ filepath: 'categories/undefined.m3u', items })
return output
}