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

View file

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