Fix merge polluting default config.

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha
2025-11-11 15:34:00 +07:00
parent 746c538165
commit 71aa72afb4

View File

@@ -80,10 +80,10 @@ async function main() {
const logger = new Logger({ level: options.debug ? LOG_LEVELS['debug'] : LOG_LEVELS['info'] }) const logger = new Logger({ level: options.debug ? LOG_LEVELS['debug'] : LOG_LEVELS['info'] })
logger.info('starting...') logger.info('starting...')
let globalConfig: epgGrabber.Types.SiteConfig = {} const globalConfig: epgGrabber.Types.SiteConfig = {}
if (typeof options.timeout === 'number') if (typeof options.timeout === 'number')
globalConfig = merge(globalConfig, { request: { timeout: options.timeout } }) merge(globalConfig, { request: { timeout: options.timeout } })
if (options.proxy !== undefined) { if (options.proxy !== undefined) {
const proxy = parseProxy(options.proxy) const proxy = parseProxy(options.proxy)
if ( if (
@@ -91,11 +91,11 @@ async function main() {
['socks', 'socks5', 'socks5h', 'socks4', 'socks4a'].includes(String(proxy.protocol)) ['socks', 'socks5', 'socks5h', 'socks4', 'socks4a'].includes(String(proxy.protocol))
) { ) {
const socksProxyAgent = new SocksProxyAgent(options.proxy) const socksProxyAgent = new SocksProxyAgent(options.proxy)
globalConfig = merge(globalConfig, { merge(globalConfig, {
request: { httpAgent: socksProxyAgent, httpsAgent: socksProxyAgent } request: { httpAgent: socksProxyAgent, httpsAgent: socksProxyAgent }
}) })
} else { } else {
globalConfig = merge(globalConfig, { request: { proxy } }) merge(globalConfig, { request: { proxy } })
} }
} }
@@ -194,8 +194,7 @@ async function main() {
channel.index = index++ channel.index = index++
if (!channel.site || !channel.site_id || !channel.name) continue if (!channel.site || !channel.site_id || !channel.name) continue
let config = await loadJs(channel.getConfigPath()) const config = merge({}, defaultConfig, await loadJs(channel.getConfigPath()))
config = merge(defaultConfig, config)
if (!channel.xmltv_id) channel.xmltv_id = channel.site_id if (!channel.xmltv_id) channel.xmltv_id = channel.site_id