mirror of
https://github.com/iptv-org/iptv
synced 2025-12-17 02:47:33 -05:00
wip
This commit is contained in:
@@ -2,12 +2,6 @@ const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
streams = _.orderBy(
|
||||
streams,
|
||||
['channel.name', 'status.level', 'resolution.height'],
|
||||
['asc', 'asc', 'desc']
|
||||
)
|
||||
streams = _.uniqBy(streams, s => s.channel_id || _.uniqueId())
|
||||
const output = []
|
||||
await api.categories.load()
|
||||
const categories = await api.categories.all()
|
||||
@@ -17,11 +11,7 @@ module.exports = async function (streams = []) {
|
||||
}
|
||||
|
||||
let items = _.filter(streams, s => !s.categories.length)
|
||||
items = items.map(item => {
|
||||
item.group_title = 'Other'
|
||||
return item
|
||||
})
|
||||
output.push({ id: 'other', items })
|
||||
output.push({ id: 'undefined', items })
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
21
scripts/generators/countries.js
Normal file
21
scripts/generators/countries.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
const output = []
|
||||
await api.countries.load()
|
||||
const countries = await api.countries.all()
|
||||
await api.regions.load()
|
||||
const regions = await api.regions.all()
|
||||
for (const country of countries) {
|
||||
const areaCodes = _.filter(regions, { countries: [country.code] }).map(r => r.code)
|
||||
areaCodes.push(country.code)
|
||||
let items = _.filter(streams, s => _.intersection(areaCodes, s.broadcast_area).length)
|
||||
output.push({ id: country.code.toLowerCase(), items })
|
||||
}
|
||||
|
||||
let items = _.filter(streams, s => !s.broadcast_area.length)
|
||||
output.push({ id: 'undefined', items })
|
||||
|
||||
return output
|
||||
}
|
||||
@@ -1 +1,4 @@
|
||||
exports.categories = require('./categories')
|
||||
exports.countries = require('./countries')
|
||||
exports.languages = require('./languages')
|
||||
exports.regions = require('./regions')
|
||||
|
||||
20
scripts/generators/languages.js
Normal file
20
scripts/generators/languages.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
const output = []
|
||||
await api.languages.load()
|
||||
let languages = await api.languages.all()
|
||||
languages = _.uniqBy(languages, 'code')
|
||||
for (const language of languages) {
|
||||
let items = _.filter(streams, { channel: { languages: [language.code] } })
|
||||
if (items.length) {
|
||||
output.push({ id: language.code, items })
|
||||
}
|
||||
}
|
||||
|
||||
let items = _.filter(streams, s => !s.languages.length)
|
||||
output.push({ id: 'undefined', items })
|
||||
|
||||
return output
|
||||
}
|
||||
19
scripts/generators/regions.js
Normal file
19
scripts/generators/regions.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const api = require('../core/api')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = async function (streams = []) {
|
||||
const output = []
|
||||
await api.regions.load()
|
||||
const regions = await api.regions.all()
|
||||
for (const region of regions) {
|
||||
const areaCodes = region.countries
|
||||
areaCodes.push(region.code)
|
||||
let items = _.filter(streams, s => _.intersection(areaCodes, s.broadcast_area).length)
|
||||
output.push({ id: region.code.toLowerCase(), items })
|
||||
}
|
||||
|
||||
let items = _.filter(streams, s => !s.broadcast_area.length)
|
||||
output.push({ id: 'undefined', items })
|
||||
|
||||
return output
|
||||
}
|
||||
Reference in New Issue
Block a user