iptv/scripts/generators/index_language_m3u.js

30 lines
663 B
JavaScript
Raw Permalink Normal View History

2022-02-07 03:53:30 +01:00
const _ = require('lodash')
module.exports = async function (streams = []) {
2022-02-11 17:56:11 +01:00
streams = _.filter(streams, stream => stream.is_nsfw === false)
2022-02-07 23:11:47 +01:00
2022-02-07 03:53:30 +01:00
let items = []
streams.forEach(stream => {
2022-02-11 17:56:11 +01:00
if (!stream.languages.length) {
2022-02-07 23:11:47 +01:00
const item = _.cloneDeep(stream)
2022-02-11 17:56:11 +01:00
item.group_title = 'Undefined'
items.push(item)
2022-02-07 23:11:47 +01:00
return
}
2022-02-07 03:53:30 +01:00
2022-02-11 17:56:11 +01:00
stream.languages.forEach(language => {
2022-02-07 03:53:30 +01:00
const item = _.cloneDeep(stream)
2022-02-11 17:56:11 +01:00
item.group_title = language.name
2022-02-07 03:53:30 +01:00
items.push(item)
})
})
2022-02-11 17:56:11 +01:00
2022-02-07 03:53:30 +01:00
items = _.sortBy(items, i => {
2022-02-11 17:56:11 +01:00
if (i.group_title === 'Undefined') return ''
2022-02-07 03:53:30 +01:00
return i.group_title
})
return { filepath: 'index.language.m3u', items }
}