Code Duplication    Length = 12-12 lines in 2 locations

ColleXions.py 1 location

@@ 112-123 (lines=12) @@
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."""
114
    try:
115
        logging.info("Connecting to Plex server...")
116
        plex_url, plex_token = config.get('plex_url'), config.get('plex_token')
117
        if not isinstance(plex_url, str) or not plex_url or not isinstance(plex_token, str) or not plex_token:
118
            raise ValueError("Missing/invalid 'plex_url'/'plex_token'")
119
        plex = PlexServer(plex_url, plex_token, timeout=60)
120
        logging.info(f"Connected to Plex server '{plex.friendlyName}' successfully.")
121
        return plex
122
    except ValueError as e: logging.error(f"Config error for Plex: {e}"); return None
123
    except Exception as e: logging.error(f"Failed to connect to Plex: {e}"); return None
124
125
def get_collections_from_all_libraries(plex, library_names):
126
    """Fetches all collection objects from the specified library names."""

collexions.py 1 location

@@ 112-123 (lines=12) @@
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."""
114
    try:
115
        logging.info("Connecting to Plex server...")
116
        plex_url, plex_token = config.get('plex_url'), config.get('plex_token')
117
        if not isinstance(plex_url, str) or not plex_url or not isinstance(plex_token, str) or not plex_token:
118
            raise ValueError("Missing/invalid 'plex_url'/'plex_token'")
119
        plex = PlexServer(plex_url, plex_token, timeout=60)
120
        logging.info(f"Connected to Plex server '{plex.friendlyName}' successfully.")
121
        return plex
122
    except ValueError as e: logging.error(f"Config error for Plex: {e}"); return None
123
    except Exception as e: logging.error(f"Failed to connect to Plex: {e}"); return None
124
125
def get_collections_from_all_libraries(plex, library_names):
126
    """Fetches all collection objects from the specified library names."""