From 3f31c61e03056b2163f4e296085ab0c0e55a7d28 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 9 Jul 2023 16:49:52 +0300 Subject: [PATCH] Update epg-grabber.js --- bin/epg-grabber.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/epg-grabber.js b/bin/epg-grabber.js index 684ea85..11536cf 100755 --- a/bin/epg-grabber.js +++ b/bin/epg-grabber.js @@ -22,7 +22,7 @@ program .description(description) .requiredOption('-c, --config ', 'Path to [site].config.js file') .option('-o, --output ', 'Path to output file') - .option('--channels ', 'Path to channels.xml file') + .option('--channels ', 'Path to list of channels') .option('--lang ', 'Set default language for all programs') .option('--days ', 'Number of days for which to grab the program', parseNumber) .option('--delay ', 'Delay between requests (in milliseconds)', parseNumber) @@ -70,23 +70,24 @@ async function main() { let parsedChannels = [] if (config.channels) { + const dir = file.dirname(options.config) + let files = [] if (Array.isArray(config.channels)) { - files = config.channels + files = config.channels.map(path => file.join(dir, path)) } else if (typeof config.channels === 'string') { files = await file.list(config.channels) } else { throw new Error('The "channels" attribute must be of type array or string') } - const dir = file.dirname(options.config) for (let filepath of files) { logger.info(`Loading '${filepath}'...`) const channelsXML = file.read(filepath) const { channels } = parseChannels(channelsXML) parsedChannels = parsedChannels.concat(channels) } - } else throw new Error('Path to [site].channels.xml is missing') + } else throw new Error('Path to "channels" is missing') const grabber = new EPGGrabber(config)