Update epg-grabber.js
This commit is contained in:
parent
ac4b124f79
commit
3130e557b2
|
@ -4,7 +4,7 @@ const { Command } = require('commander')
|
||||||
const program = new Command()
|
const program = new Command()
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const grabber = require('../src/index')
|
const EPGGrabber = require('../src/index')
|
||||||
const utils = require('../src/utils')
|
const utils = require('../src/utils')
|
||||||
const { name, version, description } = require('../package.json')
|
const { name, version, description } = require('../package.json')
|
||||||
const { merge } = require('lodash')
|
const { merge } = require('lodash')
|
||||||
|
@ -23,6 +23,11 @@ program
|
||||||
.option('--days <days>', 'Number of days for which to grab the program', parseInteger, 1)
|
.option('--days <days>', 'Number of days for which to grab the program', parseInteger, 1)
|
||||||
.option('--delay <delay>', 'Delay between requests (in mileseconds)', parseInteger)
|
.option('--delay <delay>', 'Delay between requests (in mileseconds)', parseInteger)
|
||||||
.option('--timeout <timeout>', 'Set a timeout for each request (in mileseconds)', parseInteger)
|
.option('--timeout <timeout>', 'Set a timeout for each request (in mileseconds)', parseInteger)
|
||||||
|
.option(
|
||||||
|
'--cache-max-age <cacheMaxAge>',
|
||||||
|
'Maximum time for storing each request (in milliseconds)',
|
||||||
|
parseInteger
|
||||||
|
)
|
||||||
.option('--gzip', 'Compress the output', false)
|
.option('--gzip', 'Compress the output', false)
|
||||||
.option('--debug', 'Enable debug mode', false)
|
.option('--debug', 'Enable debug mode', false)
|
||||||
.option('--curl', 'Display request as CURL', false)
|
.option('--curl', 'Display request as CURL', false)
|
||||||
|
@ -72,7 +77,10 @@ async function main() {
|
||||||
lang: options.lang,
|
lang: options.lang,
|
||||||
delay: options.delay,
|
delay: options.delay,
|
||||||
request: {
|
request: {
|
||||||
timeout: options.timeout
|
timeout: options.timeout,
|
||||||
|
cache: {
|
||||||
|
maxAge: options.cacheMaxAge
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -92,10 +100,11 @@ async function main() {
|
||||||
const total = channels.length * days
|
const total = channels.length * days
|
||||||
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 grabber = new EPGGrabber(config)
|
||||||
for (let channel of channels) {
|
for (let channel of channels) {
|
||||||
for (let date of dates) {
|
for (let date of dates) {
|
||||||
await grabber
|
await grabber
|
||||||
.grab(channel, date, config, (data, err) => {
|
.grab(channel, date, (data, err) => {
|
||||||
logger.info(
|
logger.info(
|
||||||
`[${i}/${total}] ${config.site} - ${data.channel.xmltv_id} - ${data.date.format(
|
`[${i}/${total}] ${config.site} - ${data.channel.xmltv_id} - ${data.date.format(
|
||||||
'MMM D, YYYY'
|
'MMM D, YYYY'
|
||||||
|
|
Loading…
Reference in New Issue