UNPKG

epg-grabber

Version:

Node.js CLI tool for grabbing EPG from different sites

37 lines (32 loc) 1.2 kB
const { merge } = require('lodash') const { version, homepage } = require('../package.json') module.exports.parse = parse function parse(config) { if (!config.site) throw new Error("The required 'site' property is missing") if (!config.url) throw new Error("The required 'url' property is missing") if (typeof config.url !== 'function' && typeof config.url !== 'string') throw new Error("The 'url' property should return the function or string") 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") if (config.logo && typeof config.logo !== 'function') throw new Error("The 'logo' property should return the function") const defaultConfig = { days: 1, lang: 'en', delay: 3000, output: 'guide.xml', request: { method: 'GET', maxContentLength: 5 * 1024 * 1024, timeout: 5000, withCredentials: true, responseType: 'arraybuffer', cache: false, headers: { 'User-Agent': `EPGGrabber/${version} (${homepage})` } } } return merge(defaultConfig, config) }