wip
This commit is contained in:
parent
a1149e9836
commit
2f00062515
|
@ -4,7 +4,6 @@ const { Command } = require('commander')
|
||||||
const program = new Command()
|
const program = new Command()
|
||||||
const utils = require('./utils')
|
const utils = require('./utils')
|
||||||
const { name, version, description } = require('../package.json')
|
const { name, version, description } = require('../package.json')
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.name(name)
|
.name(name)
|
||||||
|
@ -51,9 +50,9 @@ async function main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
` ${item.channel.site} - ${item.channel.xmltv_id} - ${item.date.format(
|
` ${config.site} - ${item.channel.xmltv_id} - ${item.date.format('MMM D, YYYY')} (${
|
||||||
'MMM D, YYYY'
|
programs.length
|
||||||
)} (${programs.length} programs)`
|
} programs)`
|
||||||
)
|
)
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
|
@ -61,7 +60,7 @@ async function main() {
|
||||||
.then(utils.sleep(config.delay))
|
.then(utils.sleep(config.delay))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(
|
console.log(
|
||||||
` ${item.channel.site} - ${item.channel.xmltv_id} - ${item.date.format(
|
` ${config.site} - ${item.channel.xmltv_id} - ${item.date.format(
|
||||||
'MMM D, YYYY'
|
'MMM D, YYYY'
|
||||||
)} (0 programs)`
|
)} (0 programs)`
|
||||||
)
|
)
|
||||||
|
|
12
src/utils.js
12
src/utils.js
|
@ -18,6 +18,15 @@ utils.loadConfig = function (file) {
|
||||||
const configPath = path.resolve(file)
|
const configPath = path.resolve(file)
|
||||||
const config = require(configPath)
|
const config = require(configPath)
|
||||||
|
|
||||||
|
if (!config.site) throw new Error("The required 'site' property is missing")
|
||||||
|
if (!config.channels) throw new Error("The required 'channels' property is missing")
|
||||||
|
if (!config.url) throw new Error("The required 'url' property is missing")
|
||||||
|
if (typeof config.url !== 'function')
|
||||||
|
throw new Error("The 'url' property should return the function")
|
||||||
|
if (!config.parser) throw new Error("The required 'parser' function is missing")
|
||||||
|
if (typeof config.parser !== 'function')
|
||||||
|
throw new Error("The 'parser' property should return the function")
|
||||||
|
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
|
@ -26,7 +35,8 @@ utils.loadConfig = function (file) {
|
||||||
days: 1,
|
days: 1,
|
||||||
cookie: '',
|
cookie: '',
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
delay: 3000
|
delay: 3000,
|
||||||
|
output: 'guide.xml'
|
||||||
},
|
},
|
||||||
config
|
config
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue