Revert "Update scripts"

This reverts commit 56621f8bdb.
This commit is contained in:
freearhey 2023-11-01 22:22:47 +03:00
parent 667b14f806
commit aeed89828a
2 changed files with 16 additions and 15 deletions

View file

@ -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())

View file

@ -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()