mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-11 17:40:03 -04:00
18 lines
556 B
JavaScript
18 lines
556 B
JavaScript
const api = require('../core/api')
|
|
const _ = require('lodash')
|
|
|
|
module.exports = async function (streams = []) {
|
|
await api.categories.load()
|
|
const categories = await api.categories.all()
|
|
|
|
const output = []
|
|
for (const category of categories) {
|
|
let items = _.filter(streams, { categories: [{ id: category.id }] })
|
|
output.push({ filepath: `categories/${category.id}.m3u`, items })
|
|
}
|
|
|
|
let items = _.filter(streams, stream => !stream.categories.length)
|
|
output.push({ filepath: 'categories/undefined.m3u', items })
|
|
|
|
return output
|
|
}
|