mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 18:10:04 -04:00
Update generate-playlists.js
This commit is contained in:
parent
96403d463e
commit
62ce78bbdf
32 changed files with 187 additions and 117 deletions
|
@ -3,18 +3,28 @@ const _ = require('lodash')
|
|||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, s => !s.channel || s.channel.is_nsfw === false)
|
||||
|
||||
await api.languages.load()
|
||||
let languages = await api.languages.all()
|
||||
languages = _.keyBy(languages, 'code')
|
||||
|
||||
let items = []
|
||||
streams.forEach(stream => {
|
||||
if (!stream.languages.length) return items.push(stream)
|
||||
|
||||
stream.languages.forEach(language => {
|
||||
if (!stream.channel || !stream.channel.languages.length) {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = language.name
|
||||
item.group_title = null
|
||||
items.push(stream)
|
||||
return
|
||||
}
|
||||
|
||||
stream.channel.languages.forEach(code => {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = languages[code] ? languages[code].name : null
|
||||
items.push(item)
|
||||
})
|
||||
})
|
||||
items = _.sortBy(items, i => {
|
||||
if (i.group_title === 'Undefined') return '_'
|
||||
if (!i.group_title) return ''
|
||||
return i.group_title
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue