mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update grab.js
This commit is contained in:
parent
e4ff3e48f4
commit
0ab7f71d88
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue