Skip to content

Commit

Permalink
[tagScenesWithPerfTags] add option to exclude a scene from the hook b…
Browse files Browse the repository at this point in the history
…y tag (#477)
  • Loading branch information
blaspheme-ship-it authored Dec 27, 2024
1 parent 6fb9b1c commit 6d38e77
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
38 changes: 26 additions & 12 deletions plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 7 additions & 1 deletion plugins/tagScenesWithPerfTags/tagScenesWithPerfTags.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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.
Expand Down

0 comments on commit 6d38e77

Please sign in to comment.