mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update load.js
This commit is contained in:
parent
e6312535a5
commit
ef4c11a144
1 changed files with 19 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
const _ = require('lodash')
|
||||
const grabber = require('epg-grabber')
|
||||
const EPGGrabber = require('epg-grabber')
|
||||
const { program } = require('commander')
|
||||
const { db, logger, timer, file, parser } = require('../../core')
|
||||
|
||||
|
@ -11,6 +11,11 @@ const options = program
|
|||
'Set a timeout for each request (in mileseconds)',
|
||||
parser.parseNumber
|
||||
)
|
||||
.option(
|
||||
'--cache-max-age',
|
||||
'Maximum time for storing each request (in milliseconds)',
|
||||
parser.parseNumber
|
||||
)
|
||||
.option('--debug', 'Enable debug mode', false)
|
||||
.parse(process.argv)
|
||||
.opts()
|
||||
|
@ -33,18 +38,20 @@ async function main() {
|
|||
logger.info('Loading...')
|
||||
const results = {}
|
||||
let i = 1
|
||||
for (const item of items) {
|
||||
let config = require(file.resolve(item.configPath))
|
||||
|
||||
config = _.merge(config, {
|
||||
debug: options.debug,
|
||||
delay: options.delay,
|
||||
request: {
|
||||
timeout: options.timeout
|
||||
let config = require(file.resolve(items[0].configPath))
|
||||
config = _.merge(config, {
|
||||
debug: options.debug,
|
||||
delay: options.delay,
|
||||
request: {
|
||||
timeout: options.timeout,
|
||||
cache: {
|
||||
maxAge: options.cacheMaxAge
|
||||
}
|
||||
})
|
||||
|
||||
await grabber.grab(item.channel, item.date, config, async (data, err) => {
|
||||
}
|
||||
})
|
||||
const grabber = new EPGGrabber(config)
|
||||
for (const item of items) {
|
||||
await grabber.grab(item.channel, item.date, async (data, err) => {
|
||||
logger.info(
|
||||
`[${i}/${total}] ${item.channel.site} (${item.channel.lang}) - ${
|
||||
item.channel.xmltv_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue