| @@ 101-110 (lines=10) @@ | ||
| 98 | except Exception as e: logging.error(f"Regex error for '{title}', pattern '{pattern}': {e}"); return False |
|
| 99 | return False |
|
| 100 | ||
| 101 | def load_config(): |
|
| 102 | """Loads configuration from config.json, exits on critical errors.""" |
|
| 103 | if os.path.exists(CONFIG_PATH): |
|
| 104 | try: |
|
| 105 | with open(CONFIG_PATH, 'r', encoding='utf-8') as f: # Use f |
|
| 106 | config_data = json.load(f) # Use f |
|
| 107 | if not isinstance(config_data, dict): raise ValueError("Config not JSON object.") |
|
| 108 | return config_data |
|
| 109 | except Exception as e: logging.critical(f"CRITICAL: Error load/parse {CONFIG_PATH}: {e}. Exit."); sys.exit(1) |
|
| 110 | else: logging.critical(f"CRITICAL: Config not found {CONFIG_PATH}. Exit."); sys.exit(1) |
|
| 111 | ||
| 112 | def connect_to_plex(config): |
|
| 113 | """Connects to Plex server, returns PlexServer object or None.""" |
|
| @@ 101-110 (lines=10) @@ | ||
| 98 | except Exception as e: logging.error(f"Regex error for '{title}', pattern '{pattern}': {e}"); return False |
|
| 99 | return False |
|
| 100 | ||
| 101 | def load_config(): |
|
| 102 | """Loads configuration from config.json, exits on critical errors.""" |
|
| 103 | if os.path.exists(CONFIG_PATH): |
|
| 104 | try: |
|
| 105 | with open(CONFIG_PATH, 'r', encoding='utf-8') as f: # Use f |
|
| 106 | config_data = json.load(f) # Use f |
|
| 107 | if not isinstance(config_data, dict): raise ValueError("Config not JSON object.") |
|
| 108 | return config_data |
|
| 109 | except Exception as e: logging.critical(f"CRITICAL: Error load/parse {CONFIG_PATH}: {e}. Exit."); sys.exit(1) |
|
| 110 | else: logging.critical(f"CRITICAL: Config not found {CONFIG_PATH}. Exit."); sys.exit(1) |
|
| 111 | ||
| 112 | def connect_to_plex(config): |
|
| 113 | """Connects to Plex server, returns PlexServer object or None.""" |
|