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(
new Option(
'-c, --channels <path>', '-c, --channels <path>',
'Path to *.channels.xml file (required if the "--site" attribute is not specified)' 'Path to *.channels.xml file (required if the "--site" attribute is not specified)'
) )
.option('-o, --output <path>', 'Path to output file', 'guide.xml') )
.option('-l, --lang <code>', 'Filter channels by language (ISO 639-2 code)') .addOption(new Option('-o, --output <path>', 'Path to output file').default('guide.xml'))
.option('-t, --timeout <milliseconds>', 'Override the default timeout for each request') .addOption(new Option('-l, --lang <code>', 'Filter channels by language (ISO 639-2 code)'))
.option('-d, --delay <milliseconds>', 'Override the default delay between request') .addOption(
.option( new Option('-t, --timeout <milliseconds>', 'Override the default timeout for each request').env(
'TIMEOUT'
)
)
.addOption(
new Option('-d, --delay <milliseconds>', 'Override the default delay between request').env(
'DELAY'
)
)
.addOption(
new Option(
'--days <days>', '--days <days>',
'Override the number of days for which the program will be loaded (defaults to the value from the site config)', 'Override the number of days for which the program will be loaded (defaults to the value from the site config)'
value => parseInt(value)
) )
.option( .argParser(value => parseInt(value))
'--maxConnections <number>', .env('DAYS')
'Limit on the number of concurrent requests', )
value => parseInt(value), .addOption(
1 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 = {