[tagScenesWithPerfTags] add option to exclude a scene from the hook by tag (#477)

This commit is contained in:
blaspheme-ship-it
2024-12-27 15:12:44 +01:00
committed by GitHub
parent 6fb9b1c40c
commit 6d38e77ba2
2 changed files with 33 additions and 13 deletions

View File

@@ -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"]

View File

@@ -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.