Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading