mirror of
https://github.com/iptv-org/iptv
synced 2026-04-06 03:02:05 -04:00
Update generate-playlist.js
This commit is contained in:
@@ -2,15 +2,16 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
const output = []
|
||||
await api.categories.load()
|
||||
const categories = await api.categories.all()
|
||||
|
||||
const output = []
|
||||
for (const category of categories) {
|
||||
let items = _.filter(streams, { channel: { categories: [category.id] } })
|
||||
let items = _.filter(streams, { categories: [{ id: category.id }] })
|
||||
output.push({ filepath: `categories/${category.id}.m3u`, items })
|
||||
}
|
||||
|
||||
let items = _.filter(streams, stream => !stream.channel || !stream.channel.categories.length)
|
||||
let items = _.filter(streams, stream => !stream.categories.length)
|
||||
output.push({ filepath: 'categories/undefined.m3u', items })
|
||||
|
||||
return output
|
||||
|
||||
@@ -2,7 +2,7 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, stream => !stream.channel || stream.channel.is_nsfw === false)
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
await api.countries.load()
|
||||
const countries = await api.countries.all()
|
||||
@@ -15,15 +15,15 @@ module.exports = async function (streams = []) {
|
||||
r => `r/${r.code}`
|
||||
)
|
||||
countryAreaCodes.push(`c/${country.code}`)
|
||||
let items = _.filter(
|
||||
streams,
|
||||
stream =>
|
||||
stream.channel && _.intersection(stream.channel.broadcast_area, countryAreaCodes).length
|
||||
)
|
||||
|
||||
let items = _.filter(streams, stream => {
|
||||
return _.intersection(stream.broadcast_area, countryAreaCodes).length
|
||||
})
|
||||
|
||||
output.push({ filepath: `countries/${country.code.toLowerCase()}.m3u`, items })
|
||||
}
|
||||
|
||||
let items = _.filter(streams, stream => !stream.channel || !stream.channel.broadcast_area.length)
|
||||
let items = _.filter(streams, stream => !stream.broadcast_area.length)
|
||||
output.push({ filepath: 'countries/undefined.m3u', items })
|
||||
|
||||
return output
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
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.categories.load()
|
||||
let categories = await api.categories.all()
|
||||
categories = _.keyBy(categories, 'id')
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
let items = []
|
||||
streams.forEach(stream => {
|
||||
if (!stream.channel || !stream.channel.categories.length) {
|
||||
if (!stream.categories.length) {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = null
|
||||
item.group_title = 'Undefined'
|
||||
items.push(item)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
stream.channel.categories.forEach(id => {
|
||||
stream.categories.forEach(category => {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = categories[id] ? categories[id].name : null
|
||||
item.group_title = category.name
|
||||
items.push(item)
|
||||
})
|
||||
})
|
||||
|
||||
items = _.sortBy(items, item => {
|
||||
if (!item.group_title) return ''
|
||||
if (item.group_title === 'Undefined') return ''
|
||||
|
||||
return item.group_title
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, s => !s.channel || s.channel.is_nsfw === false)
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
await api.regions.load()
|
||||
let regions = await api.regions.all()
|
||||
@@ -14,14 +14,14 @@ module.exports = async function (streams = []) {
|
||||
|
||||
let items = []
|
||||
streams.forEach(stream => {
|
||||
if (!stream.channel || !stream.channel.broadcast_area.length) {
|
||||
if (!stream.broadcast_area.length) {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = null
|
||||
item.group_title = 'Undefined'
|
||||
items.push(item)
|
||||
return
|
||||
}
|
||||
|
||||
getBroadcastCountries(stream.channel, { countries, regions }).forEach(country => {
|
||||
getBroadcastCountries(stream, { countries, regions }).forEach(country => {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = country.name
|
||||
items.push(item)
|
||||
@@ -29,15 +29,16 @@ module.exports = async function (streams = []) {
|
||||
})
|
||||
|
||||
items = _.sortBy(items, item => {
|
||||
if (!item.group_title) return false
|
||||
if (item.group_title === 'Undefined') return ''
|
||||
|
||||
return item.group_title
|
||||
})
|
||||
|
||||
return { filepath: 'index.country.m3u', items }
|
||||
}
|
||||
|
||||
function getBroadcastCountries(channel, { countries, regions }) {
|
||||
let codes = channel.broadcast_area.reduce((acc, item) => {
|
||||
function getBroadcastCountries(stream, { countries, regions }) {
|
||||
let codes = stream.broadcast_area.reduce((acc, item) => {
|
||||
const [type, code] = item.split('/')
|
||||
switch (type) {
|
||||
case 'c':
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
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.languages.load()
|
||||
let languages = await api.languages.all()
|
||||
languages = _.keyBy(languages, 'code')
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
let items = []
|
||||
streams.forEach(stream => {
|
||||
if (!stream.channel || !stream.channel.languages.length) {
|
||||
if (!stream.languages.length) {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = null
|
||||
item.group_title = 'Undefined'
|
||||
items.push(stream)
|
||||
return
|
||||
}
|
||||
|
||||
stream.channel.languages.forEach(code => {
|
||||
stream.languages.forEach(language => {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = languages[code] ? languages[code].name : null
|
||||
item.group_title = language.name
|
||||
items.push(item)
|
||||
})
|
||||
})
|
||||
|
||||
items = _.sortBy(items, i => {
|
||||
if (!i.group_title) return ''
|
||||
if (i.group_title === 'Undefined') return ''
|
||||
|
||||
return i.group_title
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, s => !s.channel || s.channel.is_nsfw === false)
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
return { filepath: 'index.m3u', items: streams }
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, stream => !stream.channel || stream.channel.is_nsfw === false)
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
await api.regions.load()
|
||||
let regions = await api.regions.all()
|
||||
@@ -10,14 +10,14 @@ module.exports = async function (streams = []) {
|
||||
|
||||
let items = []
|
||||
streams.forEach(stream => {
|
||||
if (!stream.channel || !stream.channel.broadcast_area.length) {
|
||||
if (!stream.broadcast_area.length) {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = null
|
||||
item.group_title = 'Undefined'
|
||||
items.push(item)
|
||||
return
|
||||
}
|
||||
|
||||
getChannelRegions(stream.channel, { regions }).forEach(region => {
|
||||
getChannelRegions(stream, { regions }).forEach(region => {
|
||||
const item = _.cloneDeep(stream)
|
||||
item.group_title = region.name
|
||||
items.push(item)
|
||||
@@ -25,15 +25,16 @@ module.exports = async function (streams = []) {
|
||||
})
|
||||
|
||||
items = _.sortBy(items, i => {
|
||||
if (!i.group_title) return ''
|
||||
if (i.group_title === 'Undefined') return ''
|
||||
|
||||
return i.group_title
|
||||
})
|
||||
|
||||
return { filepath: 'index.region.m3u', items }
|
||||
}
|
||||
|
||||
function getChannelRegions(channel, { regions }) {
|
||||
return channel.broadcast_area
|
||||
function getChannelRegions(stream, { regions }) {
|
||||
return stream.broadcast_area
|
||||
.reduce((acc, item) => {
|
||||
const [type, code] = item.split('/')
|
||||
switch (type) {
|
||||
|
||||
@@ -2,7 +2,7 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.filter(streams, s => !s.channel || s.channel.is_nsfw === false)
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
await api.languages.load()
|
||||
let languages = await api.languages.all()
|
||||
@@ -10,13 +10,13 @@ module.exports = async function (streams = []) {
|
||||
|
||||
const output = []
|
||||
for (const language of languages) {
|
||||
let items = _.filter(streams, { channel: { languages: [language.code] } })
|
||||
let items = _.filter(streams, { languages: [{ code: language.code }] })
|
||||
if (items.length) {
|
||||
output.push({ filepath: `languages/${language.code}.m3u`, items })
|
||||
}
|
||||
}
|
||||
|
||||
let items = _.filter(streams, stream => !stream.channel || !stream.channel.languages.length)
|
||||
let items = _.filter(streams, stream => !stream.languages.length)
|
||||
output.push({ filepath: 'languages/undefined.m3u', items })
|
||||
|
||||
return output
|
||||
|
||||
@@ -2,21 +2,21 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
const output = []
|
||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||
|
||||
await api.regions.load()
|
||||
const regions = await api.regions.all()
|
||||
streams = _.filter(streams, stream => !stream.channel || stream.channel.is_nsfw === false)
|
||||
|
||||
const output = []
|
||||
for (const region of regions) {
|
||||
const areaCodes = region.countries.map(code => `c/${code}`)
|
||||
areaCodes.push(`r/${region.code}`)
|
||||
let items = _.filter(
|
||||
streams,
|
||||
stream => stream.channel && _.intersection(stream.channel.broadcast_area, areaCodes).length
|
||||
)
|
||||
|
||||
let items = _.filter(streams, stream => _.intersection(stream.broadcast_area, areaCodes).length)
|
||||
output.push({ filepath: `regions/${region.code.toLowerCase()}.m3u`, items })
|
||||
}
|
||||
|
||||
let items = _.filter(streams, stream => !stream.channel || !stream.channel.broadcast_area.length)
|
||||
let items = _.filter(streams, stream => !stream.broadcast_area.length)
|
||||
output.push({ filepath: 'regions/undefined.m3u', items })
|
||||
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user