From aeed89828a7342022768b773cce64cc2fc633f2e Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:22:47 +0300 Subject: [PATCH] Revert "Update scripts" This reverts commit 56621f8bdb7dff5ec3fa2ec9cbf9a40751567486. --- scripts/generators/countriesGenerator.ts | 21 ++++++++++++--------- scripts/tables/countryTable.ts | 10 ++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/generators/countriesGenerator.ts b/scripts/generators/countriesGenerator.ts index a03d67096..0b5bc8c11 100644 --- a/scripts/generators/countriesGenerator.ts +++ b/scripts/generators/countriesGenerator.ts @@ -39,36 +39,39 @@ export class CountriesGenerator implements Generator { (subdivision: Subdivision) => subdivision.country === country.code ) + const countrySubdivisionsCodes = countrySubdivisions.map( + (subdivision: Subdivision) => `s/${subdivision.code}` + ) + const countryAreaCodes = regions .filter((region: Region) => region.countries.includes(country.code)) .map((region: Region) => `r/${region.code}`) + .concat(countrySubdivisionsCodes) .add(`c/${country.code}`) const countryStreams = streams.filter(stream => 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) => { const subdivisionStreams = streams.filter(stream => stream.broadcastArea.includes(`s/${subdivision.code}`) ) if (subdivisionStreams.isEmpty()) return - hasSubdivisions = true const playlist = new Playlist(subdivisionStreams, { public: true }) const filepath = `subdivisions/${subdivision.code.toLowerCase()}.m3u` await this.storage.save(filepath, playlist.toString()) 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()) diff --git a/scripts/tables/countryTable.ts b/scripts/tables/countryTable.ts index e83cf79e6..5e167b7fd 100644 --- a/scripts/tables/countryTable.ts +++ b/scripts/tables/countryTable.ts @@ -23,12 +23,10 @@ export class CountryTable implements Table { let data = new Collection() parser .parse(generatorsLog) - .filter((logItem: LogItem) => { - const isCountry = logItem.filepath.includes('countries/') - const isSubdivision = logItem.filepath.includes('subdivisions/') - - if (isCountry || isSubdivision) return true - }) + .filter( + (logItem: LogItem) => + logItem.filepath.includes('countries/') || logItem.filepath.includes('subdivisions/') + ) .forEach((logItem: LogItem) => { const file = new File(logItem.filepath) const code = file.name().toUpperCase()