mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -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 _ = require('lodash')
|
||||||
const grabber = require('epg-grabber')
|
const EPGGrabber = require('epg-grabber')
|
||||||
const { program } = require('commander')
|
const { program } = require('commander')
|
||||||
const { db, logger, timer, file, parser } = require('../../core')
|
const { db, logger, timer, file, parser } = require('../../core')
|
||||||
|
|
||||||
|
@ -11,6 +11,11 @@ const options = program
|
||||||
'Set a timeout for each request (in mileseconds)',
|
'Set a timeout for each request (in mileseconds)',
|
||||||
parser.parseNumber
|
parser.parseNumber
|
||||||
)
|
)
|
||||||
|
.option(
|
||||||
|
'--cache-max-age',
|
||||||
|
'Maximum time for storing each request (in milliseconds)',
|
||||||
|
parser.parseNumber
|
||||||
|
)
|
||||||
.option('--debug', 'Enable debug mode', false)
|
.option('--debug', 'Enable debug mode', false)
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
.opts()
|
.opts()
|
||||||
|
@ -33,18 +38,20 @@ async function main() {
|
||||||
logger.info('Loading...')
|
logger.info('Loading...')
|
||||||
const results = {}
|
const results = {}
|
||||||
let i = 1
|
let i = 1
|
||||||
for (const item of items) {
|
let config = require(file.resolve(items[0].configPath))
|
||||||
let config = require(file.resolve(item.configPath))
|
config = _.merge(config, {
|
||||||
|
debug: options.debug,
|
||||||
config = _.merge(config, {
|
delay: options.delay,
|
||||||
debug: options.debug,
|
request: {
|
||||||
delay: options.delay,
|
timeout: options.timeout,
|
||||||
request: {
|
cache: {
|
||||||
timeout: options.timeout
|
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(
|
logger.info(
|
||||||
`[${i}/${total}] ${item.channel.site} (${item.channel.lang}) - ${
|
`[${i}/${total}] ${item.channel.site} (${item.channel.lang}) - ${
|
||||||
item.channel.xmltv_id
|
item.channel.xmltv_id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue