From 02894d1317e859997bbfff1287820be84661d68b Mon Sep 17 00:00:00 2001 From: p0rnb0x <71538354+p0rnb0x@users.noreply.github.com> Date: Wed, 21 Feb 2024 04:37:10 +0000 Subject: [PATCH] Allow disabling scene marker hooks (#255) --- plugins/TPBDMarkers/TPDBMarkers.yml | 5 +++++ plugins/TPBDMarkers/tpdbMarkers.py | 17 +++++++++++++---- plugins/timestampTrade/timestampTrade.py | 15 +++++++++------ plugins/timestampTrade/timestampTrade.yml | 6 ++++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/plugins/TPBDMarkers/TPDBMarkers.yml b/plugins/TPBDMarkers/TPDBMarkers.yml index 68d90185..f0b2807b 100644 --- a/plugins/TPBDMarkers/TPDBMarkers.yml +++ b/plugins/TPBDMarkers/TPDBMarkers.yml @@ -12,6 +12,11 @@ hooks: triggeredBy: - Scene.Update.Post +settings: + disableSceneMarkerHook: + displayName: Disable the Scene Markers hook + type: BOOLEAN + tasks: - name: "Sync" description: Get markers for all scenes with a stashid from metadataapi.net and no markers diff --git a/plugins/TPBDMarkers/tpdbMarkers.py b/plugins/TPBDMarkers/tpdbMarkers.py index 800cd7dd..0f082827 100644 --- a/plugins/TPBDMarkers/tpdbMarkers.py +++ b/plugins/TPBDMarkers/tpdbMarkers.py @@ -95,6 +95,14 @@ def processAll(): FRAGMENT_SERVER = json_input["server_connection"] stash = StashInterface(FRAGMENT_SERVER) +config = stash.get_configuration()["plugins"] +settings = { + "disableSceneMarkerHook": False, +} +if "tPdBmarkers" in config: + settings.update(config["tPdBmarkers"]) +log.debug("settings: %s " % (settings,)) + # Set up the auth token for tpdb if "https://metadataapi.net/graphql" in [ x["endpoint"] for x in stash.get_configuration()["general"]["stashBoxes"] @@ -108,10 +116,11 @@ def processAll(): if "processScene" in PLUGIN_ARGS: processAll() elif "hookContext" in json_input["args"]: - id = json_input["args"]["hookContext"]["id"] - if json_input["args"]["hookContext"]["type"] == "Scene.Update.Post": - scene = stash.find_scene(id) - processScene(scene) + _id = json_input["args"]["hookContext"]["id"] + _type = json_input["args"]["hookContext"]["type"] + if _type == "Scene.Update.Post" and not settings["disableSceneMarkerHook"]: + scene = stash.find_scene(_id) + processScene(scene) else: log.warning("The Porn DB endpoint not configured") diff --git a/plugins/timestampTrade/timestampTrade.py b/plugins/timestampTrade/timestampTrade.py index 059aeebf..1a880654 100644 --- a/plugins/timestampTrade/timestampTrade.py +++ b/plugins/timestampTrade/timestampTrade.py @@ -656,10 +656,12 @@ def getImages(gallery_id): "createGalleryFromScene": False, "createMovieFromScene": False, "extraUrls": False, + "disableSceneMarkersHook": False, + "disableGalleryLookupHook": False, } if "timestampTrade" in config: settings.update(config["timestampTrade"]) -log.debug("config: %s " % (settings,)) +log.debug("settings: %s " % (settings,)) if "mode" in json_input["args"]: @@ -700,10 +702,11 @@ def getImages(gallery_id): processAll() elif "hookContext" in json_input["args"]: - id = json_input["args"]["hookContext"]["id"] - if json_input["args"]["hookContext"]["type"] == "Scene.Update.Post": - scene = stash.find_scene(id) + _id = json_input["args"]["hookContext"]["id"] + _type = json_input["args"]["hookContext"]["type"] + if _type == "Scene.Update.Post" and not settings["disableSceneMarkersHook"]: + scene = stash.find_scene(_id) processScene(scene) - if json_input["args"]["hookContext"]["type"] == "Gallery.Update.Post": - gallery = stash.find_gallery(id) + if _type == "Gallery.Update.Post" and not settings["disableGalleryLookupHook"]: + gallery = stash.find_gallery(_id) processGallery(gallery) diff --git a/plugins/timestampTrade/timestampTrade.yml b/plugins/timestampTrade/timestampTrade.yml index 621ad806..3887534f 100644 --- a/plugins/timestampTrade/timestampTrade.yml +++ b/plugins/timestampTrade/timestampTrade.yml @@ -19,6 +19,12 @@ settings: displayName: Add extra urls if they exist on timestamp.trade description: Extra urls can be submitted to timestamp.trade, add them to the scene if they exist type: BOOLEAN + disableSceneMarkersHook: + displayName: Disable the Scene Markers hook + type: BOOLEAN + disableGalleryLookupHook: + displayName: Disable the Gallery Lookup hook + type: BOOLEAN hooks: - name: Add Marker to Scene