From fe0c2280450c20707ede2442b9e9e955b4ce2ea2 Mon Sep 17 00:00:00 2001 From: David Maisonave <47364845+David-Maisonave@users.noreply.github.com> Date: Wed, 27 Nov 2024 03:54:27 -0500 Subject: [PATCH] In the report, made icon colors for tags, performers, galleries, and groups with different colors if they don't match. ### 1.0.0.2 - In the report, made icon colors for tags, performers, galleries, and groups with different colors if they don't match. In other words, use different color icons if **candidate to delete** doesn't match **duplicate to keep** associated icon data. - If data for associated icon are the same, then both icons are black or blue (the default color). - If [**duplicate to keep**] is missing data that is in [**candidate to delete**], than [**candidate to delete**] gets a yellow icon. - If [**candidate to delete**] is missing data that is in [**duplicate to keep**], than [**duplicate to keep**] gets a pink icon. --- plugins/DupFileManager/DupFileManager.py | 93 ++++++++++++++++--- plugins/DupFileManager/DupFileManager.yml | 2 +- plugins/DupFileManager/README.md | 6 +- plugins/DupFileManager/StashPluginHelper.py | 21 ++++- .../DupFileManager/version_history/README.md | 5 + 5 files changed, 106 insertions(+), 21 deletions(-) diff --git a/plugins/DupFileManager/DupFileManager.py b/plugins/DupFileManager/DupFileManager.py index b86f5ce..0260df8 100644 --- a/plugins/DupFileManager/DupFileManager.py +++ b/plugins/DupFileManager/DupFileManager.py @@ -557,6 +557,39 @@ def getSceneID(scene): def fileNameClassID(scene): return f" class=\"FN_ID_{scene['id']}\" " +def doesDelCandidateHaveMetadataNotInDupToKeep(DupFile, DupFileToKeep, listName, itemName = 'name'): + DelCandidateItems = [] + DupToKeepItems = [] + DupToKeepMissingItem = False + DelCandidateMissingItem = False + for item in DupFileToKeep[listName]: + if listName != 'tags' or not item['ignore_auto_tag']: + if listName == "groups": + DupToKeepItems += [item['group']['name']] + elif listName == "galleries": + item = stash.getGalleryName(item['id']) + DupToKeepItems += [item[itemName]] + else: + DupToKeepItems += [item[itemName]] + for item in DupFile[listName]: + if listName != 'tags' or not item['ignore_auto_tag']: + if listName == "groups": + name = item['group'][itemName] + elif listName == "galleries": + item = stash.getGalleryName(item['id']) + name = item[itemName] + else: + name = item[itemName] + DelCandidateItems += [name] + if name not in DupToKeepItems: + DupToKeepMissingItem = True + for name in DupToKeepItems: + if name not in DelCandidateItems: + DelCandidateMissingItem = True + break + return DupToKeepMissingItem, DelCandidateMissingItem + + htmlReportNameFolder = f"{stash.PLUGINS_PATH}{os.sep}DupFileManager{os.sep}report" htmlReportName = f"{htmlReportNameFolder}{os.sep}{stash.Setting('htmlReportName')}" htmlReportTableRow = stash.Setting('htmlReportTableRow') @@ -568,10 +601,14 @@ htmlPreviewOrStream = "stream" if stash.Setting('streamOverPreview') els def writeRowToHtmlReport(fileHtmlReport, DupFile, DupFileToKeep, QtyTagForDel = "?", tagDuplicates = False): fileDoesNotExistStr = "[File NOT Exist]" - htmlTagPrefix = '") if len(DupFileToKeep['groups']) > 0: - fileHtmlReport.write(htmlGroupPrefix) + if DelCandidateMissingGroup: + fileHtmlReport.write(htmlGroupPrefix.replace(defaultColorGroup, "PinkGroup.png")) + else: + fileHtmlReport.write(htmlGroupPrefix) for group in DupFileToKeep['groups']: fileHtmlReport.write(f"
{group['group']['name']}
") fileHtmlReport.write("") diff --git a/plugins/DupFileManager/DupFileManager.yml b/plugins/DupFileManager/DupFileManager.yml index cdcb265..e133e24 100644 --- a/plugins/DupFileManager/DupFileManager.yml +++ b/plugins/DupFileManager/DupFileManager.yml @@ -1,6 +1,6 @@ name: DupFileManager description: Manages duplicate files. -version: 1.0.0.1 +version: 1.0.0.2 url: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/DupFileManager ui: javascript: diff --git a/plugins/DupFileManager/README.md b/plugins/DupFileManager/README.md index 0bef1ad..e67718a 100644 --- a/plugins/DupFileManager/README.md +++ b/plugins/DupFileManager/README.md @@ -1,4 +1,4 @@ -# DupFileManager: Ver 1.0.0.1 (By David Maisonave) +# DupFileManager: Ver 1.0.0.2 (By David Maisonave) DupFileManager is a [Stash](https://github.com/stashapp/stash) plugin which manages duplicate files in the Stash system. It has both **task** and **tools-UI** components. @@ -102,8 +102,8 @@ That's it!!! - ![Screenshot 2024-11-22 232208](https://github.com/user-attachments/assets/bf1f3021-3a8c-4875-9737-60ee3d7fe675) ### Future Planned Features -- Add logic to merge performers and galaries seperatly from tag merging on report. Planned for 1.1.0 Version. -- Add logic to merge group metadata when selecting merge option on report. Planned for 1.2.0 Version. +- Add logic to merge performers and galaries seperatly from tag merging on report. Planned for 1.5.0 Version. +- Add logic to merge group metadata when selecting merge option on report. Planned for 2.0.0 Version. - Add advanced menu directly to the Settings->Tools menu. Planned for 2.0.0 Version. - Add report directly to the Settings->Tools menu. Planned for 2.0.0 Version. diff --git a/plugins/DupFileManager/StashPluginHelper.py b/plugins/DupFileManager/StashPluginHelper.py index dedc858..27bfae8 100644 --- a/plugins/DupFileManager/StashPluginHelper.py +++ b/plugins/DupFileManager/StashPluginHelper.py @@ -92,6 +92,7 @@ class StashPluginHelper(StashInterface): stopProcessBarSpin = True updateProgressbarOnIter = 0 currentProgressbarIteration = 0 + galleryNamesCache = {} class OS_Type(IntEnum): WINDOWS = 1 @@ -773,6 +774,14 @@ class StashPluginHelper(StashInterface): errMsg = f"Exception calling [updateScene]. Will retry; count({i}); Error: {e}\nTraceBack={tb}" time.sleep(sleepSecondsBetweenRetry) + # getGalleryName uses a cache so it doesn't have to hit the server for the same ID. + def getGalleryName(self, gallery_id, refreshCache=False): + if refreshCache: + self.galleryNamesCache = {} + if gallery_id not in self.galleryNamesCache: + self.galleryNamesCache[gallery_id] = self.find_gallery(gallery_id) + return self.galleryNamesCache[gallery_id] + def runPlugin(self, plugin_id, task_mode=None, args:dict={}, asyn=False): """Runs a plugin operation. The operation is run immediately and does not use the job queue. @@ -986,6 +995,8 @@ class mergeMetadata: # A class to merge scene metadata from source scene to dest self.mergeItems('tags', 'tag_ids', [], excludeName=self.excludeMergeTags) self.mergeItems('performers', 'performer_ids', []) self.mergeItems('galleries', 'gallery_ids', []) + # ToDo: Firgure out how to merge groups + # self.mergeItems('groups', 'group_ids') # Looks like movies has been removed from new Stash version # self.mergeItems('movies', 'movies', []) self.mergeItems('urls', listToAdd=self.destData['urls'], NotStartWith=self.stash.STASH_URL) @@ -1020,9 +1031,13 @@ class mergeMetadata: # A class to merge scene metadata from source scene to dest if item not in self.destData[fieldName]: if NotStartWith == None or not item.startswith(NotStartWith): if excludeName == None or item['name'] not in excludeName: - if fieldName == 'movies': - listToAdd += [{"movie_id" : item['movie']['id'], "scene_index" : item['scene_index']}] - dataAdded += f"{item['movie']['id']} " + if fieldName == 'groups': + # listToAdd += [{"group_id" : item['group']['id'], "group_name" : item['group']['name']}] + listToAdd += [item['group']['id']] + dataAdded += f"{item['group']['id']} " + # elif fieldName == 'movies': + # listToAdd += [{"movie_id" : item['movie']['id'], "scene_index" : item['scene_index']}] + # dataAdded += f"{item['movie']['id']} " elif updateFieldName == None: listToAdd += [item] dataAdded += f"{item} " diff --git a/plugins/DupFileManager/version_history/README.md b/plugins/DupFileManager/version_history/README.md index 55ad055..b0e2402 100644 --- a/plugins/DupFileManager/version_history/README.md +++ b/plugins/DupFileManager/version_history/README.md @@ -31,3 +31,8 @@ - Added report option to delete by flags set on the report. ### 1.0.0.1 - Fixed bug with report delete scene request. +### 1.0.0.2 +- In the report, made icon colors for tags, performers, galleries, and groups with different colors if they don't match. In other words, use different color icons if **candidate to delete** doesn't match **duplicate to keep** associated icon data. + - If data for associated icon are the same, then both icons are black or blue (the default color). + - If [**duplicate to keep**] is missing data that is in [**candidate to delete**], than [**candidate to delete**] gets a yellow icon. + - If [**candidate to delete**] is missing data that is in [**duplicate to keep**], than [**duplicate to keep**] gets a pink icon.