Update epg-grabber.js
This commit is contained in:
parent
0a83492b76
commit
19d206c11c
|
@ -68,8 +68,24 @@ async function main() {
|
||||||
const grabber = new EPGGrabber(config)
|
const grabber = new EPGGrabber(config)
|
||||||
|
|
||||||
const channelsXML = file.read(config.channels)
|
const channelsXML = file.read(config.channels)
|
||||||
const { channels } = parseChannels(channelsXML)
|
const { channels: parsedChannels } = parseChannels(channelsXML)
|
||||||
|
|
||||||
|
let template = options.output || config.output
|
||||||
|
const variables = file.templateVariables(template)
|
||||||
|
|
||||||
|
const groups = _.groupBy(parsedChannels, channel => {
|
||||||
|
let groupId = ''
|
||||||
|
for (let key in channel) {
|
||||||
|
if (variables.includes(key)) {
|
||||||
|
groupId += channel[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupId
|
||||||
|
})
|
||||||
|
|
||||||
|
for (let groupId in groups) {
|
||||||
|
const channels = groups[groupId]
|
||||||
let programs = []
|
let programs = []
|
||||||
let i = 1
|
let i = 1
|
||||||
let days = config.days || 1
|
let days = config.days || 1
|
||||||
|
@ -103,7 +119,7 @@ async function main() {
|
||||||
programs = _.uniqBy(programs, p => p.start + p.channel)
|
programs = _.uniqBy(programs, p => p.start + p.channel)
|
||||||
|
|
||||||
const xml = generateXMLTV({ channels, programs })
|
const xml = generateXMLTV({ channels, programs })
|
||||||
let outputPath = options.output || config.output
|
let outputPath = file.templateFormat(template, channels[0])
|
||||||
if (options.gzip) {
|
if (options.gzip) {
|
||||||
outputPath = outputPath || 'guide.xml.gz'
|
outputPath = outputPath || 'guide.xml.gz'
|
||||||
const compressed = await gzip(xml)
|
const compressed = await gzip(xml)
|
||||||
|
@ -114,6 +130,8 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`File '${outputPath}' successfully saved`)
|
logger.info(`File '${outputPath}' successfully saved`)
|
||||||
|
}
|
||||||
|
|
||||||
logger.info('Finish')
|
logger.info('Finish')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue