Update grab.js

This commit is contained in:
Aleksandr Statciuk 2021-10-06 17:52:30 +03:00
parent 1c654e3b96
commit 1a0b12dc99

View file

@ -31,19 +31,21 @@ async function main() {
for (let channel of channels) {
const configPath = `sites/${channel.site}.config.js`
const config = require(path.resolve(configPath))
await grabber.grab(channel, config, (item, err) => {
if (err) {
console.log(` Error: ${err.message}`)
} else {
await grabber
.grab(channel, config, (item, err) => {
console.log(
` ${item.channel.site} - ${item.channel.xmltv_id} - ${item.date.format(
'MMM D, YYYY'
)} (${item.programs.length} programs)`
)
programs = programs.concat(item.programs)
}
})
if (err) {
console.log(` Error: ${err.message}`)
}
})
.then(results => {
programs = programs.concat(results)
})
}
const xml = grabber.convertToXMLTV({ channels, programs })