mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
33 lines
843 B
TypeScript
33 lines
843 B
TypeScript
import { SiteConfig } from 'epg-grabber'
|
|
import _ from 'lodash'
|
|
import { pathToFileURL } from 'url'
|
|
|
|
export class ConfigLoader {
|
|
async load(filepath: string): Promise<SiteConfig> {
|
|
const fileUrl = pathToFileURL(filepath).toString()
|
|
const config = (await import(fileUrl)).default
|
|
const defaultConfig = {
|
|
days: 1,
|
|
delay: 0,
|
|
output: 'guide.xml',
|
|
request: {
|
|
method: 'GET',
|
|
maxContentLength: 5242880,
|
|
timeout: 30000,
|
|
withCredentials: true,
|
|
jar: null,
|
|
responseType: 'arraybuffer',
|
|
cache: false,
|
|
headers: null,
|
|
data: null
|
|
},
|
|
maxConnections: 1,
|
|
site: undefined,
|
|
url: undefined,
|
|
parser: undefined,
|
|
channels: undefined
|
|
}
|
|
|
|
return _.merge(defaultConfig, config)
|
|
}
|
|
}
|