Update generate-playlists.js
This commit is contained in:
@@ -2,6 +2,8 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, s => !s.channel || s.channel.is_nsfw === false)
|
||||
|
||||
await api.regions.load()
|
||||
let regions = await api.regions.all()
|
||||
regions = _.keyBy(regions, 'code')
|
||||
@@ -10,10 +12,14 @@ module.exports = async function (streams = []) {
|
||||
let countries = await api.countries.all()
|
||||
countries = _.keyBy(countries, 'code')
|
||||
|
||||
streams = _.filter(streams, s => !s.channel || s.channel.is_nsfw === false)
|
||||
let items = []
|
||||
streams.forEach(stream => {
|
||||
if (!stream.channel) return items.push(stream)
|
||||
if (!stream.channel || !stream.channel.broadcast_area.length) {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = null
|
||||
items.push(item)
|
||||
return
|
||||
}
|
||||
|
||||
getBroadcastCountries(stream.channel, { countries, regions }).forEach(country => {
|
||||
const item = _.cloneDeep(stream)
|
||||
@@ -21,9 +27,10 @@ module.exports = async function (streams = []) {
|
||||
items.push(item)
|
||||
})
|
||||
})
|
||||
items = _.sortBy(items, i => {
|
||||
if (i.group_title === 'Undefined') return '_'
|
||||
return i.group_title
|
||||
|
||||
items = _.sortBy(items, item => {
|
||||
if (!item.group_title) return false
|
||||
return item.group_title
|
||||
})
|
||||
|
||||
return { filepath: 'index.country.m3u', items }
|
||||
|
Reference in New Issue
Block a user