mirror of
https://github.com/iptv-org/epg
synced 2025-12-18 19:36:58 -05:00
Update grab.js
This commit is contained in:
@@ -10,6 +10,7 @@ const convert = require('xml-js')
|
|||||||
program
|
program
|
||||||
.option('--channels <channels>', 'Path to channels.xml file')
|
.option('--channels <channels>', 'Path to channels.xml file')
|
||||||
.option('--output <output>', 'Path to output file', 'guide.xml')
|
.option('--output <output>', 'Path to output file', 'guide.xml')
|
||||||
|
.option('--days <days>', 'Number of days for which to grab the program', parseInteger, 1)
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
const options = program.opts()
|
const options = program.opts()
|
||||||
@@ -32,6 +33,7 @@ async function main() {
|
|||||||
for (let channel of channels) {
|
for (let channel of channels) {
|
||||||
const configPath = `sites/${channel.site}.config.js`
|
const configPath = `sites/${channel.site}.config.js`
|
||||||
const config = require(path.resolve(configPath))
|
const config = require(path.resolve(configPath))
|
||||||
|
config.days = options.days
|
||||||
await grabber
|
await grabber
|
||||||
.grab(channel, config, (item, err) => {
|
.grab(channel, config, (item, err) => {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -90,3 +92,7 @@ function writeToFile(filename, data) {
|
|||||||
|
|
||||||
fs.writeFileSync(path.resolve(filename), data)
|
fs.writeFileSync(path.resolve(filename), data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseInteger(val) {
|
||||||
|
return val ? parseInt(val) : null
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user