Update countries.js

This commit is contained in:
Aleksandr Statciuk 2022-09-12 07:18:17 +03:00
parent 464169e597
commit b0a81c21c8
1 changed files with 15 additions and 4 deletions

View File

@ -16,10 +16,8 @@ module.exports = async function (streams = []) {
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 countrySubdivisionCodes = _.filter(subdivisions, { country: country.code}).map( const countrySubdivisions = _.filter(subdivisions, { country: country.code })
r => `s/${r.code}` const countryAreaCodes = countryRegionCodes.concat(countrySubdivisions.map(s => `s/${s.code}`))
)
const countryAreaCodes = countryRegionCodes.concat(countrySubdivisionCodes)
countryAreaCodes.push(`c/${country.code}`) countryAreaCodes.push(`c/${country.code}`)
let items = _.filter(streams, stream => { let items = _.filter(streams, stream => {
@ -27,6 +25,19 @@ module.exports = async function (streams = []) {
}) })
output.push({ filepath: `countries/${country.code.toLowerCase()}.m3u`, items }) output.push({ filepath: `countries/${country.code.toLowerCase()}.m3u`, items })
for (let subdivision of countrySubdivisions) {
let subdivisionItems = _.filter(streams, stream => {
return stream.broadcast_area.includes(`s/${subdivision.code}`)
})
if (subdivisionItems.length) {
output.push({
filepath: `countries/${subdivision.code.toLowerCase()}.m3u`,
items: subdivisionItems
})
}
}
} }
let items = _.filter(streams, stream => !stream.broadcast_area.length) let items = _.filter(streams, stream => !stream.broadcast_area.length)