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