Update index.js

This commit is contained in:
Aleksandr Statciuk 2021-10-06 18:12:14 +03:00
parent 1e42b106db
commit c09a837868
1 changed files with 4 additions and 3 deletions

View File

@ -14,6 +14,8 @@ const Result = {
module.exports = {
grab: async function (channel, config, cb) {
config = utils.loadConfig(config)
const utcDate = utils.getUTCDate()
const dates = Array.from({ length: config.days }, (_, i) => utcDate.add(i, 'd'))
const queue = []
@ -21,8 +23,6 @@ module.exports = {
queue.push({ date, channel })
})
config = utils.loadConfig(config)
let programs = []
for (let item of queue) {
await utils
@ -35,7 +35,8 @@ module.exports = {
programs = programs.concat(results)
})
.catch(err => {
cb(null, err)
item.programs = []
cb(item, err)
})
await utils.sleep(config.delay)