From ed9433ead13fa3ecd18923ce669884de2780b80d Mon Sep 17 00:00:00 2001 From: Nirvana Date: Sun, 14 Dec 2025 14:25:26 +0100 Subject: [PATCH] Add web config --- resources/web/epg_mapping.js | 3 +++ service.py | 32 ++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/resources/web/epg_mapping.js b/resources/web/epg_mapping.js index 8e50fa4..0c2b3a6 100644 --- a/resources/web/epg_mapping.js +++ b/resources/web/epg_mapping.js @@ -23,6 +23,9 @@ class EPGMappingManager { } async loadProviders() { + // Only load once + if (this.initialized) return; + try { const response = await fetch(`${this.apiBase}/api/providers`); if (!response.ok) throw new Error('Failed to load providers'); diff --git a/service.py b/service.py index a2c4f01..88138cf 100644 --- a/service.py +++ b/service.py @@ -81,7 +81,7 @@ class UltimateService: css_path = os.path.join(web_dir, 'config.css') js_path = os.path.join(web_dir, 'config.js') - # NEW: EPG mapping files + # EPG mapping files epg_css_path = os.path.join(web_dir, 'epg_mapping.css') epg_js_path = os.path.join(web_dir, 'epg_mapping.js') fuzzyset_path = os.path.join(web_dir, 'lib', 'fuzzyset.js') @@ -96,7 +96,7 @@ class UltimateService: with open(css_path, 'r', encoding='utf-8') as f: css = f.read() - # NEW: Load EPG CSS + # Load EPG CSS with open(epg_css_path, 'r', encoding='utf-8') as f: epg_css = f.read() @@ -104,7 +104,7 @@ class UltimateService: with open(js_path, 'r', encoding='utf-8') as f: js = f.read() - # NEW: Load EPG JS and libraries + # Load EPG JS and libraries with open(epg_js_path, 'r', encoding='utf-8') as f: epg_js = f.read() @@ -118,30 +118,34 @@ class UltimateService: combined_css = f"{css}\n\n/* EPG Mapping CSS */\n{epg_css}" # Combine all JS (with proper order) - combined_js = f"""{debounce_js} + combined_js = f""" + /* Debounce Utility */ + {debounce_js} + /* FuzzySet Library */ {fuzzyset_js} - + /* Main Config JS */ {js} - + /* EPG Mapping JS */ {epg_js} """ - # Replace in HTML + # Replace CSS in HTML html = html.replace('', f'') - html = html.replace('', - f'') + # Inject JavaScript before tag since ' - # Remove the additional script tags we added (they're now embedded) - html = html.replace('', '') - html = html.replace('', '') - html = html.replace('', '') - html = html.replace('', '') + # Check if script tag exists in HTML (for backward compatibility) + if '' in html: + html = html.replace('', script_tag) + else: + # Script tag was removed, inject before + html = html.replace('', f'{script_tag}\n') return html