mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 01:50:04 -04:00
Update countries.js
This commit is contained in:
parent
4ae4213010
commit
43a6fa42e2
1 changed files with 41 additions and 32 deletions
|
@ -2,43 +2,52 @@ const api = require('../core/api')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
|
||||||
module.exports = async function (streams = []) {
|
module.exports = async function (streams = []) {
|
||||||
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
streams = _.filter(streams, stream => stream.is_nsfw === false)
|
||||||
|
|
||||||
await api.countries.load()
|
await api.countries.load()
|
||||||
const countries = await api.countries.all()
|
const countries = await api.countries.all()
|
||||||
await api.regions.load()
|
await api.regions.load()
|
||||||
const regions = await api.regions.all()
|
let regions = await api.regions.all()
|
||||||
await api.subdivisions.load()
|
regions = regions.filter(r => r.code !== 'INT')
|
||||||
const subdivisions = await api.subdivisions.all()
|
await api.subdivisions.load()
|
||||||
|
const subdivisions = await api.subdivisions.all()
|
||||||
|
|
||||||
const output = []
|
let output = []
|
||||||
for (const country of countries) {
|
for (const country of countries) {
|
||||||
let countryRegionCodes = _.filter(regions, { countries: [country.code] }).map(
|
let countryRegionCodes = _.filter(regions, { countries: [country.code] }).map(
|
||||||
r => `r/${r.code}`
|
r => `r/${r.code}`
|
||||||
)
|
)
|
||||||
const countrySubdivisions = _.filter(subdivisions, { country: country.code })
|
const countrySubdivisions = _.filter(subdivisions, { country: country.code })
|
||||||
const countryAreaCodes = countryRegionCodes.concat(countrySubdivisions.map(s => `s/${s.code}`))
|
const countryAreaCodes = countryRegionCodes.concat(countrySubdivisions.map(s => `s/${s.code}`))
|
||||||
countryAreaCodes.push(`c/${country.code}`)
|
countryAreaCodes.push(`c/${country.code}`)
|
||||||
|
|
||||||
let items = _.filter(streams, stream => {
|
let items = _.filter(streams, stream => {
|
||||||
return _.intersection(stream.broadcast_area, countryAreaCodes).length
|
return _.intersection(stream.broadcast_area, countryAreaCodes).length
|
||||||
})
|
})
|
||||||
|
|
||||||
output.push({ filepath: `countries/${country.code.toLowerCase()}.m3u`, items })
|
output.push({ filepath: `countries/${country.code.toLowerCase()}.m3u`, items })
|
||||||
|
|
||||||
for (let subdivision of countrySubdivisions) {
|
for (let subdivision of countrySubdivisions) {
|
||||||
let subdivisionItems = _.filter(streams, stream => {
|
let subdivisionItems = _.filter(streams, stream => {
|
||||||
return stream.broadcast_area.includes(`s/${subdivision.code}`)
|
return stream.broadcast_area.includes(`s/${subdivision.code}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (subdivisionItems.length) {
|
if (subdivisionItems.length) {
|
||||||
output.push({
|
output.push({
|
||||||
filepath: `subdivisions/${subdivision.code.toLowerCase()}.m3u`,
|
filepath: `subdivisions/${subdivision.code.toLowerCase()}.m3u`,
|
||||||
items: subdivisionItems
|
items: subdivisionItems
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output
|
let intItems = _.filter(streams, stream => stream.broadcast_area.includes('r/INT'))
|
||||||
|
output.push({
|
||||||
|
filepath: `countries/int.m3u`,
|
||||||
|
items: intItems
|
||||||
|
})
|
||||||
|
|
||||||
|
output = output.filter(f => f.items.length > 0)
|
||||||
|
|
||||||
|
return output
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue