iptv/scripts/generators/index_category_m3u.js
2022-02-12 03:12:00 +03:00

33 lines
705 B
JavaScript

const _ = require('lodash')
module.exports = async function (streams = []) {
streams = _.filter(streams, stream => stream.is_nsfw === false)
let items = []
streams.forEach(stream => {
if (!stream.categories.length) {
const item = _.cloneDeep(stream)
item.group_title = 'Undefined'
items.push(item)
return
}
stream.categories
.filter(c => c)
.forEach(category => {
const item = _.cloneDeep(stream)
item.group_title = category.name
items.push(item)
})
})
items = _.sortBy(items, item => {
if (item.group_title === 'Undefined') return ''
return item.group_title
})
return { filepath: 'index.category.m3u', items }
}