diff --git a/plugins/dupeMarker/dupeMarker.py b/plugins/dupeMarker/dupeMarker.py index 2584e45f..8b115017 100644 --- a/plugins/dupeMarker/dupeMarker.py +++ b/plugins/dupeMarker/dupeMarker.py @@ -1,10 +1,6 @@ import json import sys -import re -import datetime as dt import stashapi.log as log -from stashapi.tools import human_bytes -from stashapi.stash_types import PhashDistance from stashapi.stashapp import StashInterface FRAGMENT = json.loads(sys.stdin.read()) @@ -12,7 +8,6 @@ stash = StashInterface(FRAGMENT["server_connection"]) dupe_marker_tag = stash.find_tag("[Marker: Duplicate]", create=True).get("id") - def findScenesWithMarkers(): totalDupes = 0 scenes = stash.find_scenes(f={"has_markers": "true"}, fragment="id") @@ -20,7 +15,6 @@ def findScenesWithMarkers(): totalDupes += checkScene(scene) log.info("Found %d duplicate markers across %d scenes" % (totalDupes, len(scenes))) - def addMarkerTag(marker): query = """ mutation SceneMarkerUpdate($input:SceneMarkerUpdateInput!) { @@ -59,15 +53,18 @@ def checkScene(scene): if dupes: log.debug("Found %d duplicate markers in scene %s" % (len(dupes), scene["id"])) for dupe in dupes: - addMarkerTag(dupe) + if MODE == "delete": + stash.destroy_scene_marker(dupe["id"]) + else: + addMarkerTag(dupe) return len(dupes) - def main(): - if MODE == "search": + if MODE == "mark": + findScenesWithMarkers() + elif MODE == "delete": findScenesWithMarkers() log.exit("Plugin exited normally.") - if __name__ == "__main__": main() diff --git a/plugins/dupeMarker/dupeMarker.yml b/plugins/dupeMarker/dupeMarker.yml index 8df1d14e..6ccf236b 100644 --- a/plugins/dupeMarker/dupeMarker.yml +++ b/plugins/dupeMarker/dupeMarker.yml @@ -1,13 +1,17 @@ name: Dupe Marker Detector description: Finds and marks duplicate markers -version: 0.1 +version: 0.2 url: https://github.com/stashapp/CommunityScripts/ exec: - python - "{pluginDir}/dupeMarker.py" interface: raw tasks: - - name: "Search" - description: Search for duplicate markers + - name: "Mark" + description: Mark duplicate markers defaultArgs: - mode: search + mode: mark + - name: "Delete" + description: "Delete duplicate markers" + defaultArgs: + mode: delete