This commit is contained in:
Aleksandr Statciuk 2022-01-10 22:16:18 +03:00
parent f8981e478e
commit 043d738c95
14 changed files with 134 additions and 9 deletions

View file

@ -12,6 +12,7 @@ async function main() {
await setUp()
await generateMainXML()
await generateCountries()
}
main()
@ -32,6 +33,32 @@ async function generateMainXML() {
await file.create(`${GUIDES_DIR}/epg.xml`, xml.create(output))
}
async function generateCountries() {
logger.info(`Generating countries/...`)
const countryCodes = ['US', 'ZA']
for (let code of countryCodes) {
const output = {
channels: [],
programs: []
}
output.channels = channels
.filter(c => c.country === code)
.map(c => {
c.site = sources[c.id]
return c
})
for (let channel of output.channels) {
output.programs = output.programs.concat(programs[channel.id])
}
await file.create(`${GUIDES_DIR}/countries/${code.toLowerCase()}.epg.xml`, xml.create(output))
}
}
async function setUp() {
channels = await loadChannels()
programs = await loadPrograms()