Update grab.ts

This commit is contained in:
freearhey 2025-01-05 15:12:16 +03:00
parent 2db99a538e
commit 67bd130763

View file

@ -1,32 +1,48 @@
import { Logger, Timer, Storage, Collection } from '@freearhey/core' import { Logger, Timer, Storage, Collection } from '@freearhey/core'
import { program } from 'commander' import { Option, program } from 'commander'
import { QueueCreator, Job, ChannelsParser } from '../../core' import { QueueCreator, Job, ChannelsParser } from '../../core'
import { Channel } from 'epg-grabber' import { Channel } from 'epg-grabber'
import path from 'path' import path from 'path'
import { SITES_DIR } from '../../constants' import { SITES_DIR } from '../../constants'
program program
.option('-s, --site <name>', 'Name of the site to parse') .addOption(new Option('-s, --site <name>', 'Name of the site to parse'))
.option( .addOption(
'-c, --channels <path>', new Option(
'Path to *.channels.xml file (required if the "--site" attribute is not specified)' '-c, --channels <path>',
'Path to *.channels.xml file (required if the "--site" attribute is not specified)'
)
) )
.option('-o, --output <path>', 'Path to output file', 'guide.xml') .addOption(new Option('-o, --output <path>', 'Path to output file').default('guide.xml'))
.option('-l, --lang <code>', 'Filter channels by language (ISO 639-2 code)') .addOption(new Option('-l, --lang <code>', 'Filter channels by language (ISO 639-2 code)'))
.option('-t, --timeout <milliseconds>', 'Override the default timeout for each request') .addOption(
.option('-d, --delay <milliseconds>', 'Override the default delay between request') new Option('-t, --timeout <milliseconds>', 'Override the default timeout for each request').env(
.option( 'TIMEOUT'
'--days <days>', )
'Override the number of days for which the program will be loaded (defaults to the value from the site config)',
value => parseInt(value)
) )
.option( .addOption(
'--maxConnections <number>', new Option('-d, --delay <milliseconds>', 'Override the default delay between request').env(
'Limit on the number of concurrent requests', 'DELAY'
value => parseInt(value), )
1 )
.addOption(
new Option(
'--days <days>',
'Override the number of days for which the program will be loaded (defaults to the value from the site config)'
)
.argParser(value => parseInt(value))
.env('DAYS')
)
.addOption(
new Option('--maxConnections <number>', 'Limit on the number of concurrent requests')
.default(1)
.env('MAX_CONNECTIONS')
)
.addOption(
new Option('--gzip', 'Create a compressed version of the guide as well')
.default(false)
.env('GZIP')
) )
.option('--gzip', 'Create a compressed version of the guide as well', false)
.parse(process.argv) .parse(process.argv)
export type GrabOptions = { export type GrabOptions = {