Skip to content

Commit

Permalink
Update DupeMarker (#302)
Browse files Browse the repository at this point in the history
* fix dupeMarker deprecation, add delete mode

* prettify

---------

Co-authored-by: feederbox826 <[email protected]>
  • Loading branch information
feederbox826 and feederbox826 authored May 13, 2024
1 parent f2f8808 commit f899a56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
17 changes: 7 additions & 10 deletions plugins/dupeMarker/dupeMarker.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
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())
MODE = FRAGMENT["args"]["mode"]
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")
for scene in scenes:
totalDupes += checkScene(scene)
log.info("Found %d duplicate markers across %d scenes" % (totalDupes, len(scenes)))


def addMarkerTag(marker):
query = """
mutation SceneMarkerUpdate($input:SceneMarkerUpdateInput!) {
Expand Down Expand Up @@ -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()
12 changes: 8 additions & 4 deletions plugins/dupeMarker/dupeMarker.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f899a56

Please sign in to comment.