Update index.js

This commit is contained in:
freearhey 2021-04-17 12:24:28 +03:00
parent 46483871dc
commit 68c0be6564
1 changed files with 6 additions and 5 deletions

View File

@ -32,7 +32,7 @@ async function main() {
let programs = [] let programs = []
console.log('Parsing:') console.log('Parsing:')
for (let item of queue) { for (let item of queue) {
if (options.debug) console.time(' time') if (options.debug) console.time(' Time')
const progs = await utils const progs = await utils
.fetchData(item, config) .fetchData(item, config)
.then(response => { .then(response => {
@ -56,6 +56,10 @@ async function main() {
return program return program
}) })
}) })
.then(() => {
if (options.debug) console.timeEnd(' Time')
})
.then(utils.sleep(config.delay))
.catch(err => { .catch(err => {
console.log( console.log(
` ${config.site} - ${item.channel.xmltv_id} - ${item.date.format( ` ${config.site} - ${item.channel.xmltv_id} - ${item.date.format(
@ -63,10 +67,7 @@ async function main() {
)} (0 programs)` )} (0 programs)`
) )
console.log(` Error: ${err.message}`) console.log(` Error: ${err.message}`)
}) if (options.debug) console.timeEnd(' Time')
.finally(() => {
if (options.debug) console.timeEnd(' time')
utils.sleep(config.delay)
}) })
programs = programs.concat(progs) programs = programs.concat(progs)