diff --git a/README.md b/README.md index 932e87d7..2578f10f 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Options: -o, --output Path to output file (default: "guide.xml") -l, --lang Filter channels by language (ISO 639-2 code) -t, --timeout Override the default timeout for each request + -d, --delay Override the default delay between request --days Override the number of days for which the program will be loaded (defaults to the value from the site config) --maxConnections Limit on the number of concurrent requests (default: 1) diff --git a/scripts/commands/epg/grab.ts b/scripts/commands/epg/grab.ts index cc0d03f2..54ba114c 100644 --- a/scripts/commands/epg/grab.ts +++ b/scripts/commands/epg/grab.ts @@ -15,6 +15,7 @@ program .option('-o, --output ', 'Path to output file', 'guide.xml') .option('-l, --lang ', 'Filter channels by language (ISO 639-2 code)') .option('-t, --timeout ', 'Override the default timeout for each request') + .option('-d, --delay ', 'Override the default delay between request') .option( '--days ', 'Override the number of days for which the program will be loaded (defaults to the value from the site config)', @@ -37,6 +38,7 @@ export type GrabOptions = { gzip: boolean maxConnections: number timeout?: string + delay?: string lang?: string days?: number cron?: string diff --git a/scripts/core/grabber.ts b/scripts/core/grabber.ts index c91d66ff..5729d11b 100644 --- a/scripts/core/grabber.ts +++ b/scripts/core/grabber.ts @@ -43,6 +43,11 @@ export class Grabber { config.request = { ...config.request, ...{ timeout } } } + if (this.options.delay !== undefined) { + const delay = parseInt(this.options.delay) + config.delay = delay + } + const grabber = process.env.NODE_ENV === 'test' ? new EPGGrabberMock(config) : new EPGGrabber(config) const _programs = await grabber.grab(