From 5c5fe8d11405c6b9d378dc78b6e3e1ffb8e1604d Mon Sep 17 00:00:00 2001 From: Rikiar Date: Tue, 19 Dec 2023 11:55:54 +0100 Subject: [PATCH] Improve webhook error handling and URL building Adjusted indentation in the webhook receiver to correctly fall back to a warning message when receiving a misconfigured webhook. Also, updated metadata refresh function to construct the request URL dynamically, allowing for more robust handling of server addresses, including those served over HTTPS. These changes ensure better user feedback and improve compatibility with secure Plex server configurations. --- .gitignore | 5 +++++ subgen/subgen.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f40bb1c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +subgen/tmp27tjle0a +subgen/.locks/* +subgen/__pycache__/subgen.cpython-310.pyc +subgen/models--Systran--faster-whisper-medium/* + diff --git a/subgen/subgen.py b/subgen/subgen.py index 82d0dc0..1e7469c 100644 --- a/subgen/subgen.py +++ b/subgen/subgen.py @@ -133,8 +133,8 @@ def receive_plex_webhook( logging.info(f"Metadata for item {plex_json['Metadata']['ratingKey']} refreshed successfully.") except Exception as e: logging.error(f"Failed to refresh metadata for item {plex_json['Metadata']['ratingKey']}: {e}") - else: - print("This doesn't appear to be a properly configured Plex webhook, please review the instructions again!") + else: + print("This doesn't appear to be a properly configured Plex webhook, please review the instructions again!") return "" @@ -374,7 +374,7 @@ def refresh_plex_metadata(itemid: str, server_ip: str, plex_token: str) -> None: """ # Plex API endpoint to refresh metadata for a specific item - url = f"http://{server_ip}:32400/library/metadata/{itemid}/refresh" + url = f"{server_ip}/library/metadata/{itemid}/refresh" # Headers to include the Plex token for authentication headers = {