Update grab.js

This commit is contained in:
Aleksandr Statciuk 2021-10-06 16:38:30 +03:00
parent 970c0d40ea
commit 1c654e3b96

View file

@ -31,8 +31,10 @@ async function main() {
for (let channel of channels) { for (let channel of channels) {
const configPath = `sites/${channel.site}.config.js` const configPath = `sites/${channel.site}.config.js`
const config = require(path.resolve(configPath)) const config = require(path.resolve(configPath))
await grabber.grab(channel, config, result => { await grabber.grab(channel, config, (item, err) => {
result.on('data', function (item) { if (err) {
console.log(` Error: ${err.message}`)
} else {
console.log( console.log(
` ${item.channel.site} - ${item.channel.xmltv_id} - ${item.date.format( ` ${item.channel.site} - ${item.channel.xmltv_id} - ${item.date.format(
'MMM D, YYYY' 'MMM D, YYYY'
@ -40,11 +42,7 @@ async function main() {
) )
programs = programs.concat(item.programs) programs = programs.concat(item.programs)
}) }
result.on('error', function (err) {
console.log(` Error: ${err.message}`)
})
}) })
} }