Files
epg/scripts/core/configLoader.ts

34 lines
877 B
TypeScript
Raw Normal View History

2023-10-15 14:08:23 +03:00
import { SiteConfig } from 'epg-grabber'
2025-07-16 15:19:12 +02:00
import { deepMerge } from '../functions'
2023-10-15 14:08:23 +03:00
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 = {
2025-01-25 22:21:08 +03:00
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
2023-10-15 14:08:23 +03:00
},
maxConnections: 1,
site: undefined,
url: undefined,
parser: undefined,
channels: undefined
}
return deepMerge(defaultConfig, config) as SiteConfig
2023-10-15 14:08:23 +03:00
}
}