Code Duplication    Length = 10-10 lines in 2 locations

collexions.py 1 location

@@ 156-165 (lines=10) @@
153
            if webhook_url: send_discord_message(webhook_url, message)
154
        except Exception as e: logging.error(f"Error pinning '{coll_title}': {e}")
155
156
def send_discord_message(webhook_url, message):
157
    """Sends a message to the specified Discord webhook URL."""
158
    if not webhook_url or not isinstance(webhook_url, str): return
159
    data = {"content": message}
160
    try:
161
        response = requests.post(webhook_url, json=data, timeout=10)
162
        response.raise_for_status()
163
        logging.info(f"Discord msg sent (Status: {response.status_code})")
164
    except requests.exceptions.RequestException as e: logging.error(f"Failed send to Discord: {e}")
165
    except Exception as e: logging.error(f"Discord message error: {e}")
166
167
def unpin_collections(plex, library_names, exclusion_list):
168
    """Unpins currently promoted collections, respecting exclusions, with enhanced error logging."""

ColleXions.py 1 location

@@ 156-165 (lines=10) @@
153
            if webhook_url: send_discord_message(webhook_url, message)
154
        except Exception as e: logging.error(f"Error pinning '{coll_title}': {e}")
155
156
def send_discord_message(webhook_url, message):
157
    """Sends a message to the specified Discord webhook URL."""
158
    if not webhook_url or not isinstance(webhook_url, str): return
159
    data = {"content": message}
160
    try:
161
        response = requests.post(webhook_url, json=data, timeout=10)
162
        response.raise_for_status()
163
        logging.info(f"Discord msg sent (Status: {response.status_code})")
164
    except requests.exceptions.RequestException as e: logging.error(f"Failed send to Discord: {e}")
165
    except Exception as e: logging.error(f"Discord message error: {e}")
166
167
def unpin_collections(plex, library_names, exclusion_list):
168
    """Unpins currently promoted collections, respecting exclusions, with enhanced error logging."""