mirror of
https://github.com/iptv-org/iptv.git
synced 2024-12-27 10:07:10 +00:00
parent
667b14f806
commit
aeed89828a
|
@ -39,36 +39,39 @@ export class CountriesGenerator implements Generator {
|
||||||
(subdivision: Subdivision) => subdivision.country === country.code
|
(subdivision: Subdivision) => subdivision.country === country.code
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const countrySubdivisionsCodes = countrySubdivisions.map(
|
||||||
|
(subdivision: Subdivision) => `s/${subdivision.code}`
|
||||||
|
)
|
||||||
|
|
||||||
const countryAreaCodes = regions
|
const countryAreaCodes = regions
|
||||||
.filter((region: Region) => region.countries.includes(country.code))
|
.filter((region: Region) => region.countries.includes(country.code))
|
||||||
.map((region: Region) => `r/${region.code}`)
|
.map((region: Region) => `r/${region.code}`)
|
||||||
|
.concat(countrySubdivisionsCodes)
|
||||||
.add(`c/${country.code}`)
|
.add(`c/${country.code}`)
|
||||||
|
|
||||||
const countryStreams = streams.filter(stream =>
|
const countryStreams = streams.filter(stream =>
|
||||||
stream.broadcastArea.intersects(countryAreaCodes)
|
stream.broadcastArea.intersects(countryAreaCodes)
|
||||||
)
|
)
|
||||||
|
|
||||||
let hasSubdivisions = false
|
if (countryStreams.isEmpty()) return
|
||||||
|
|
||||||
|
const playlist = new Playlist(countryStreams, { public: true })
|
||||||
|
const filepath = `countries/${country.code.toLowerCase()}.m3u`
|
||||||
|
await this.storage.save(filepath, playlist.toString())
|
||||||
|
this.logger.info(JSON.stringify({ filepath, count: playlist.streams.count() }))
|
||||||
|
|
||||||
countrySubdivisions.forEach(async (subdivision: Subdivision) => {
|
countrySubdivisions.forEach(async (subdivision: Subdivision) => {
|
||||||
const subdivisionStreams = streams.filter(stream =>
|
const subdivisionStreams = streams.filter(stream =>
|
||||||
stream.broadcastArea.includes(`s/${subdivision.code}`)
|
stream.broadcastArea.includes(`s/${subdivision.code}`)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (subdivisionStreams.isEmpty()) return
|
if (subdivisionStreams.isEmpty()) return
|
||||||
hasSubdivisions = true
|
|
||||||
|
|
||||||
const playlist = new Playlist(subdivisionStreams, { public: true })
|
const playlist = new Playlist(subdivisionStreams, { public: true })
|
||||||
const filepath = `subdivisions/${subdivision.code.toLowerCase()}.m3u`
|
const filepath = `subdivisions/${subdivision.code.toLowerCase()}.m3u`
|
||||||
await this.storage.save(filepath, playlist.toString())
|
await this.storage.save(filepath, playlist.toString())
|
||||||
this.logger.info(JSON.stringify({ filepath, count: playlist.streams.count() }))
|
this.logger.info(JSON.stringify({ filepath, count: playlist.streams.count() }))
|
||||||
})
|
})
|
||||||
|
|
||||||
if (countryStreams.count() > 0 || hasSubdivisions) {
|
|
||||||
const playlist = new Playlist(countryStreams, { public: true })
|
|
||||||
const filepath = `countries/${country.code.toLowerCase()}.m3u`
|
|
||||||
await this.storage.save(filepath, playlist.toString())
|
|
||||||
this.logger.info(JSON.stringify({ filepath, count: playlist.streams.count() }))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const internationalStreams = streams.filter(stream => stream.isInternational())
|
const internationalStreams = streams.filter(stream => stream.isInternational())
|
||||||
|
|
|
@ -23,12 +23,10 @@ export class CountryTable implements Table {
|
||||||
let data = new Collection()
|
let data = new Collection()
|
||||||
parser
|
parser
|
||||||
.parse(generatorsLog)
|
.parse(generatorsLog)
|
||||||
.filter((logItem: LogItem) => {
|
.filter(
|
||||||
const isCountry = logItem.filepath.includes('countries/')
|
(logItem: LogItem) =>
|
||||||
const isSubdivision = logItem.filepath.includes('subdivisions/')
|
logItem.filepath.includes('countries/') || logItem.filepath.includes('subdivisions/')
|
||||||
|
)
|
||||||
if (isCountry || isSubdivision) return true
|
|
||||||
})
|
|
||||||
.forEach((logItem: LogItem) => {
|
.forEach((logItem: LogItem) => {
|
||||||
const file = new File(logItem.filepath)
|
const file = new File(logItem.filepath)
|
||||||
const code = file.name().toUpperCase()
|
const code = file.name().toUpperCase()
|
||||||
|
|
Loading…
Reference in a new issue