Skip to content

Commit 97999c1

Browse files
Adding plugin DupFileManager, and updating RenameFile and FileMonitor. (#422)
1 parent 770d9e7 commit 97999c1

20 files changed

+2505
-607
lines changed

plugins/DupFileManager/DupFileManager.py

Lines changed: 463 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: DupFileManager
2+
description: Manages duplicate files.
3+
version: 0.1.2
4+
url: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/DupFileManager
5+
settings:
6+
mergeDupFilename:
7+
displayName: Merge Duplicate Tags
8+
description: Before deletion, merge metadata from duplicate. E.g. Tag names, performers, studios, title, galleries, rating, details, etc...
9+
type: BOOLEAN
10+
permanentlyDelete:
11+
displayName: Permanent Delete
12+
description: Enable to permanently delete files, instead of moving files to trash can.
13+
type: BOOLEAN
14+
whitelistDelDupInSameFolder:
15+
displayName: Whitelist Delete In Same Folder
16+
description: Allow whitelist deletion of duplicates within the same whitelist folder.
17+
type: BOOLEAN
18+
whitelistDoTagLowResDup:
19+
displayName: Whitelist Duplicate Tagging
20+
description: Enable to tag whitelist duplicates of lower resolution or duration or same folder.
21+
type: BOOLEAN
22+
zCleanAfterDel:
23+
displayName: Run Clean After Delete
24+
description: After running a 'Delete Duplicates' task, run Clean, Clean-Generated, and Optimize-Database.
25+
type: BOOLEAN
26+
zSwapHighRes:
27+
displayName: Swap High Resolution
28+
description: If enabled, swap higher resolution duplicate files to preferred path.
29+
type: BOOLEAN
30+
zSwapLongLength:
31+
displayName: Swap Longer Duration
32+
description: If enabled, swap longer duration media files to preferred path. Longer is determine by significantLongerTime field.
33+
type: BOOLEAN
34+
zWhitelist:
35+
displayName: White List
36+
description: A comma seperated list of paths NOT to be deleted. E.g. C:\Favorite\,E:\MustKeep\
37+
type: STRING
38+
zxGraylist:
39+
displayName: Gray List
40+
description: List of preferential paths to determine which duplicate should be the primary. E.g. C:\2nd_Favorite\,H:\ShouldKeep\
41+
type: STRING
42+
zyBlacklist:
43+
displayName: Black List
44+
description: List of LEAST preferential paths to determine primary candidates for deletion. E.g. C:\Downloads\,F:\DeleteMeFirst\
45+
type: STRING
46+
zyMaxDupToProcess:
47+
displayName: Max Dup Process
48+
description: Maximum number of duplicates to process. If 0, infinity
49+
type: NUMBER
50+
zzdebugTracing:
51+
displayName: Debug Tracing
52+
description: (Default=false) [***For Advanced Users***] Enable debug tracing. When enabled, additional tracing logging is added to Stash\plugins\DupFileManager\DupFileManager.log
53+
type: BOOLEAN
54+
exec:
55+
- python
56+
- "{pluginDir}/DupFileManager.py"
57+
interface: raw
58+
tasks:
59+
- name: Tag Duplicates
60+
description: Set tag DuplicateMarkForDeletion to the duplicates with lower resolution, duration, file name length, or black list path.
61+
defaultArgs:
62+
mode: tag_duplicates_task
63+
- name: Delete Tagged Duplicates
64+
description: Only delete scenes having DuplicateMarkForDeletion tag.
65+
defaultArgs:
66+
mode: delete_tagged_duplicates_task
67+
- name: Delete Duplicates
68+
description: Delete duplicate scenes. Performs deletion without first tagging.
69+
defaultArgs:
70+
mode: delete_duplicates_task
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Description: This is a Stash plugin which manages duplicate files.
2+
# By David Maisonave (aka Axter) Jul-2024 (https://www.axter.com/)
3+
# Get the latest developers version from following link: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/DupFileManager
4+
config = {
5+
# If enabled, adds the primary duplicate path to the scene detail.
6+
"addPrimaryDupPathToDetails" : True,
7+
# Alternative path to move duplicate files.
8+
"dup_path": "", #Example: "C:\\TempDeleteFolder"
9+
# The threshold as to what percentage is consider a significant shorter time.
10+
"significantTimeDiff" : .90, # 90% threshold
11+
# Valued passed to stash API function FindDuplicateScenes.
12+
"duration_diff" : 10, # (default=10) A value from 1 to 10.
13+
# If enabled, moves destination file to recycle bin before swapping Hi-Res file.
14+
"toRecycleBeforeSwap" : True,
15+
# Character used to seperate items on the whitelist, blacklist, and graylist
16+
"listSeparator" : ",",
17+
# Tag used to tag duplicates with lower resolution, duration, and file name length.
18+
"DupFileTag" : "DuplicateMarkForDeletion",
19+
# Tag name used to tag duplicates in the whitelist. E.g. DuplicateWhitelistFile
20+
"DupWhiteListTag" : "DuplicateWhitelistFile",
21+
22+
# The following fields are ONLY used when running DupFileManager in script mode
23+
"endpoint_Scheme" : "http", # Define endpoint to use when contacting the Stash server
24+
"endpoint_Host" : "0.0.0.0", # Define endpoint to use when contacting the Stash server
25+
"endpoint_Port" : 9999, # Define endpoint to use when contacting the Stash server
26+
}

plugins/DupFileManager/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# DupFileManager: Ver 0.1.2 (By David Maisonave)
2+
3+
DupFileManager is a [Stash](https://github.com/stashapp/stash) plugin which manages duplicate file in the Stash system.
4+
5+
### Features
6+
7+
- Can merge potential source in the duplicate file names for tag names, performers, and studios.
8+
- Normally when Stash searches the file name for tag names, performers, and studios, it only does so using the primary file.
9+
- Delete duplicate file task with the following options:
10+
- Tasks (Settings->Task->[Plugin Tasks]->DupFileManager)
11+
- **Tag Duplicates** - Set tag DuplicateMarkForDeletion to the duplicates with lower resolution, duration, file name length, and/or black list path.
12+
- **Delete Tagged Duplicates** - Delete scenes having DuplicateMarkForDeletion tag.
13+
- **Delete Duplicates** - Deletes duplicate files. Performs deletion without first tagging.
14+
- Plugin UI options (Settings->Plugins->Plugins->[DupFileManager])
15+
- Has a 3 tier path selection to determine which duplicates to keep, and which should be candidates for deletions.
16+
- **Whitelist** - List of paths NOT to be deleted.
17+
- E.g. C:\Favorite\,E:\MustKeep\
18+
- **Gray-List** - List of preferential paths to determine which duplicate should be the primary.
19+
- E.g. C:\2nd_Favorite\,H:\ShouldKeep\
20+
- **Blacklist** - List of LEAST preferential paths to determine primary candidates for deletion.
21+
- E.g. C:\Downloads\,F:\DeleteMeFirst\
22+
- **Permanent Delete** - Enable to permanently delete files, instead of moving files to trash can.
23+
- **Max Dup Process** - Use to limit the maximum files to process. Can be used to do a limited test run.
24+
- **Merge Duplicate Tags** - Before deletion, merge metadata from duplicate. E.g. Tag names, performers, studios, title, galleries, rating, details, etc...
25+
- **Swap High Resolution** - When enabled, swaps higher resolution files between whitelist and blacklist/graylist files.
26+
- **Swap Longer Duration** - When enabled, swaps scene with longer duration.
27+
- Options available via DupFileManager_config.py
28+
- **dup_path** - Alternate path to move deleted files to. Example: "C:\TempDeleteFolder"
29+
- **toRecycleBeforeSwap** - When enabled, moves destination file to recycle bin before swapping files.
30+
- **addPrimaryDupPathToDetails** - If enabled, adds the primary duplicate path to the scene detail.
31+
32+
### Requirements
33+
34+
`pip install --upgrade stashapp-tools`
35+
`pip install pyYAML`
36+
`pip install Send2Trash`
37+
38+
### Installation
39+
40+
- Follow **Requirements** instructions.
41+
- In the stash plugin directory (C:\Users\MyUserName\.stash\plugins), create a folder named **DupFileManager**.
42+
- Copy all the plugin files to this folder.(**C:\Users\MyUserName\\.stash\plugins\DupFileManager**).
43+
- Click the **[Reload Plugins]** button in Stash->Settings->Plugins->Plugins.
44+
45+
That's it!!!
46+
47+
### Options
48+
49+
- Options are accessible in the GUI via Settings->Plugins->Plugins->[DupFileManager].
50+
- More options available in DupFileManager_config.py.

0 commit comments

Comments
 (0)