From 6d38e77ba2ad9413d313ff06f642a744bd85e350 Mon Sep 17 00:00:00 2001 From: blaspheme-ship-it Date: Fri, 27 Dec 2024 15:12:44 +0100 Subject: [PATCH] [tagScenesWithPerfTags] add option to exclude a scene from the hook by tag (#477) --- .../tagScenesWithPerfTags.py | 38 +++++++++++++------ .../tagScenesWithPerfTags.yml | 8 +++- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.py b/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.py index ad0aa1f2..07c9add0 100644 --- a/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.py +++ b/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.py @@ -36,23 +36,37 @@ def processAll(): def processScene(scene): tags = [] performersIds = [] - for perf in scene["performers"]: - performersIds.append(perf["id"]) - performers = [] - for perfId in performersIds: - performers.append(stash.find_performer(perfId)) - for perf in performers: - for tag in perf["tags"]: - tags.append(tag["id"]) - stash.update_scenes({"ids": scene["id"], "tag_ids": {"mode": "ADD", "ids": tags}}) - tags = [] - performersIds = [] - performers = [] + should_tag = True + if settings["excludeSceneWithTag"] != "": + for tag in scene["tags"]: + if tag["name"] == settings["excludeSceneWithTag"]: + should_tag = False + break + + if should_tag: + for perf in scene["performers"]: + performersIds.append(perf["id"]) + performers = [] + for perfId in performersIds: + performers.append(stash.find_performer(perfId)) + for perf in performers: + for tag in perf["tags"]: + tags.append(tag["id"]) + stash.update_scenes({"ids": scene["id"], "tag_ids": {"mode": "ADD", "ids": tags}}) + tags = [] + performersIds = [] + performers = [] json_input = json.loads(sys.stdin.read()) FRAGMENT_SERVER = json_input["server_connection"] stash = StashInterface(FRAGMENT_SERVER) +config = stash.get_configuration() +settings = { + "excludeSceneWithTag": "", +} +if "tagScenesWithPerfTags" in config["plugins"]: + settings.update(config["plugins"]["tagScenesWithPerfTags"]) if "mode" in json_input["args"]: PLUGIN_ARGS = json_input["args"]["mode"] diff --git a/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.yml b/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.yml index 90d0a701..1c6d66a5 100644 --- a/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.yml +++ b/plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.yml @@ -1,6 +1,6 @@ name: Tag Scenes From Performer Tags description: tags scenes with performer tags. -version: 0.1 +version: 0.2 exec: - python - "{pluginDir}/tagScenesWithPerfTags.py" @@ -13,6 +13,12 @@ hooks: - Scene.Update.Post - Scene.Create.Post +settings: + excludeSceneWithTag: + displayName: Exclude Scenes with Tag from Hook + description: Do not automatically tag scenes with performer tags if the scene has this tag + type: STRING + tasks: - name: "Tag All Scenes" description: Loops through all performers, finds all of their scenes, then applies the performers tags to each of the scenes they appear in. Can take a long time on large db's.