Skip to content

Commit

Permalink
Adds option to change the delay between requests
Browse files Browse the repository at this point in the history
  • Loading branch information
freearhey committed Oct 19, 2023
1 parent 5478aa2 commit b1bcc08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Options:
-o, --output <path> Path to output file (default: "guide.xml")
-l, --lang <code> Filter channels by language (ISO 639-2 code)
-t, --timeout <milliseconds> Override the default timeout for each request
-d, --delay <milliseconds> Override the default delay between request
--days <days> Override the number of days for which the program will be loaded
(defaults to the value from the site config)
--maxConnections <number> Limit on the number of concurrent requests (default: 1)
Expand Down
2 changes: 2 additions & 0 deletions scripts/commands/epg/grab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ program
.option('-o, --output <path>', 'Path to output file', 'guide.xml')
.option('-l, --lang <code>', 'Filter channels by language (ISO 639-2 code)')
.option('-t, --timeout <milliseconds>', 'Override the default timeout for each request')
.option('-d, --delay <milliseconds>', 'Override the default delay between request')
.option(
'--days <days>',
'Override the number of days for which the program will be loaded (defaults to the value from the site config)',
Expand All @@ -37,6 +38,7 @@ export type GrabOptions = {
gzip: boolean
maxConnections: number
timeout?: string
delay?: string
lang?: string
days?: number
cron?: string
Expand Down
5 changes: 5 additions & 0 deletions scripts/core/grabber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b1bcc08

Please sign in to comment.