From 93fbf5e7649a7b609e64cf443009b5a526d34ccf Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:30:28 -0600 Subject: [PATCH] Update subgen.py --- subgen/subgen.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/subgen/subgen.py b/subgen/subgen.py index 3d71562..f74b72d 100644 --- a/subgen/subgen.py +++ b/subgen/subgen.py @@ -84,6 +84,7 @@ def receive_tautulli_webhook(): if request.headers.get("Source") == "Tautulli": event = request.json["event"] + logging.debug("Event detected is: " + event) if((event == "added" and procaddedmedia) or (event == "played" and procmediaonplay)): fullpath = request.json["file"] logging.debug("Path of file: " + fullpath) @@ -107,6 +108,7 @@ def receive_plex_webhook(): if "PlexMediaServer" in request.headers.get("User-Agent"): plex_json = json.loads(request.form['payload']) event = plex_json["event"] + logging.debug("Event detected is: " + event) if((event == "library.new" and procaddedmedia) or (event == "media.play" and procmediaonplay)): fullpath = get_plex_file_name(plex_json['Metadata']['ratingKey'], plexserver, plextoken) logging.debug("Path of file: " + fullpath) @@ -129,7 +131,7 @@ def receive_jellyfin_webhook(): if "Jellyfin-Server" in request.headers.get("User-Agent"): event = request.json["NotificationType"] - logging.debug(event) + logging.debug("Event detected is: " + event) if((event == "ItemAdded" and procaddedmedia) or (event == "PlaybackStart" and procmediaonplay)): fullpath = get_jellyfin_file_name(request.json["ItemId"], jellyfinserver, jellyfintoken) logging.debug("Path of file: " + fullpath) @@ -144,6 +146,32 @@ def receive_jellyfin_webhook(): return "" +@app.route("/emby", methods=["POST"]) +def receive_emby_webhook(): + logging.debug("This hook is from Emby webhook!") + logging.debug("Headers: %s", request.headers) + logging.debug("Raw response: %s", request.form) + + if "Emby Server" in request.headers.get("User-Agent"): + data = request.form.get('data') + if data: + data_dict = json.loads(data) + fullpath = data_dict.get('Item', {}).get('Path', '') + event = data_dict.get('Event', '') + logging.debug("Event detected is: " + event) + if((event == "library.new" and procaddedmedia) or (event == "playback.start" and procmediaonplay)): + logging.debug("Path of file: " + fullpath) + + if use_path_mapping: + fullpath = fullpath.replace(path_mapping_from, path_mapping_to) + logging.debug("Updated path: " + fullpath.replace(path_mapping_from, path_mapping_to)) + + add_file_for_transcription(fullpath) + else: + print("This doesn't appear to be a properly configured Emby webhook, please review the instructions again!") + + return "" + def gen_subtitles(video_file_path: str) -> None: try: print(f"Transcribing file: {video_file_path}")