Added report feature to DupFileManager

This commit is contained in:
David Maisonave
2024-10-22 11:38:08 -04:00
parent 15bca1c899
commit a49c9aeb6f
6 changed files with 588 additions and 95 deletions

View File

@@ -12,6 +12,22 @@ config = {
"toRecycleBeforeSwap" : True,
# Character used to seperate items on the whitelist, blacklist, and graylist
"listSeparator" : ",",
# Enable to permanently delete files, instead of moving files to trash can.
"permanentlyDelete" : False,
# After running a 'Delete Duplicates' task, run Clean, Clean-Generated, and Optimize-Database.
"cleanAfterDel" : True,
# Generate PHASH after tag or delete task.
"doGeneratePhash" : False,
# If enabled, skip processing tagged scenes. This option is ignored if createHtmlReport is True
"skipIfTagged" : False,
# If enabled, stop multiple scanning jobs after processing duplicates
"killScanningPostProcess" : True,
# If enabled, tag scenes which have longer duration, but lower resolution
"tagLongDurationLowRes" : True,
# If enabled, bit-rate is used in important comparisons for function allThingsEqual
"bitRateIsImporantComp" : True,
# If enabled, codec is used in important comparisons for function allThingsEqual
"codecIsImporantComp" : True,
# Tag names **************************************************
# Tag used to tag duplicates with lower resolution, duration, and file name length.
@@ -25,6 +41,16 @@ config = {
# Tag name for scenes with significant longer duration but lower resolution
"longerDurationLowerResolution" : "_LongerDurationLowerResolution",
# Other tag related options **************************************************
# If enabled, when adding tag DuplicateMarkForDeletion to graylist scene, also add tag _GraylistMarkForDeletion.
"graylistTagging" : True,
# If enabled, the Clear Tags task clears scenes of all tags (DuplicateMarkForDeletion, _DuplicateWhite..., _ExcludeDup..., _Graylist..., _LongerDur...)
"clearAllDupfileManagerTags" : True,
# If enabled, append dup tag name with match duplicate distance number. I.E. (DuplicateMarkForDeletion_0) or (DuplicateMarkForDeletion_1)
"appendMatchDupDistance" : True,
# If enabled, start dup tag name with an underscore. I.E. (_DuplicateMarkForDeletion). Places tag at the end of tag list.
"underscoreDupFileTag" : True,
# Favor setings *********************************************
# If enabled, favor longer file name over shorter. If disabled, favor shorter file name.
"favorLongerFileName" : True,
@@ -51,16 +77,155 @@ config = {
# Determines which codecRankingSet to use when ranking codec. Default is 1 for codecRankingSet1
"codecRankingSetToUse" : 1,
# If enabled, skip processing tagged scenes
"skipIfTagged" : True,
# If enabled, stop multiple scanning jobs after processing duplicates
"killScanningPostProcess" : True,
# If enabled, tag scenes which have longer duration, but lower resolution
"tagLongDurationLowRes" : True,
# If enabled, bit-rate is used in important comparisons for function allThingsEqual
"bitRateIsImporantComp" : True,
# If enabled, codec is used in important comparisons for function allThingsEqual
"codecIsImporantComp" : True,
# HTML Report **************************************************
# If enabled, create an HTML report when tagging duplicate files
"createHtmlReport" : True,
# If enabled, report displays stream instead of preview for video
"streamOverPreview" : False, # This option works in Chrome, but does not work very well on firefox.
# If enabled, create an HTML report when tagging duplicate files
"htmlReportName" : "DuplicateTagScenes.html",
# HTML report prefix, before table listing
"htmlReportPrefix" : """<!DOCTYPE html>
<html>
<head>
<title>Stash Duplicate Report</title>
<style>
h2 {text-align: center;}
table, th, td {border:1px solid black;}
.inline {
display: inline;
}
.scene-details{text-align: center;font-size: small;}
.reason-details{text-align: left;font-size: small;}
.link-items{text-align: center;font-size: small;}
.link-button {
background: none;
border: none;
color: blue;
text-decoration: underline;
cursor: pointer;
font-size: 1em;
font-family: serif;
text-align: center;
font-size: small;
}
.link-button:focus {
outline: none;
}
.link-button:active {
color:red;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
var superQuery = `{ mutation SceneDestroy($input:SceneDestroyInput!) {sceneDestroy(input: $input)} }`
$(document).ready(function(){
$("button").click(function(){
chkBxRemoveValid = document.getElementById("RemoveValidatePrompt");
chkBxDisableDeleteConfirm = document.getElementById("RemoveToKeepConfirm");
if (this.value === "Duplicate" || this.value === "ToKeep")
{
if (!chkBxDisableDeleteConfirm.checked && !confirm("Are you sure you want to delete this file and remove scene from stash?")) {
return
}
$.ajax({method: "POST", url: "http://127.0.0.1:9999/graphql", contentType: "application/json",
data: JSON.stringify({
query: `mutation SceneDestroy($input:SceneDestroyInput!) {sceneDestroy(input: $input)}`,
variables: {"input":{"delete_file":true,"id":this.id}},
}), success: function(result){
$("#div1").html(result);
}});
this.style.visibility = 'hidden';
if (!chkBxRemoveValid.checked) alert("Sent delete request for scene ID# " + this.id)
}
else if (this.value === "RemoveDupTag")
{
$.ajax({method: "POST", url: "http://127.0.0.1:9999/graphql", contentType: "application/json",
data: JSON.stringify({
query: `mutation RunPluginOperation($plugin_id:ID!,$args:Map!){runPluginOperation(plugin_id:$plugin_id,args:$args)}`,
variables: {"plugin_id": "DupFileManager", "args": {"removeDupTag":this.id, "mode":"remove_a_duplicate_tag"}},
}), success: function(result){
$("#div1").html(result);
}});
this.style.visibility = 'hidden';
if (!chkBxRemoveValid.checked) alert("Sent remove duplicate tag request for scene ID# " + this.id)
}
else if (this.value === "AddExcludeTag")
{
$.ajax({method: "POST", url: "http://127.0.0.1:9999/graphql", contentType: "application/json",
data: JSON.stringify({
query: `mutation RunPluginOperation($plugin_id:ID!,$args:Map!){runPluginOperation(plugin_id:$plugin_id,args:$args)}`,
variables: {"plugin_id": "DupFileManager", "args": {"addExcludeForDelTag":this.id, "mode":"add_an_exclude_tag"}},
}), success: function(result){
$("#div1").html(result);
}});
this.style.visibility = 'hidden';
if (!chkBxRemoveValid.checked) alert("Sent add exclude tag request for scene ID# " + this.id)
}
else if (this.value === "RemoveExcludeTag")
{
$.ajax({method: "POST", url: "http://127.0.0.1:9999/graphql", contentType: "application/json",
data: JSON.stringify({
query: `mutation RunPluginOperation($plugin_id:ID!,$args:Map!){runPluginOperation(plugin_id:$plugin_id,args:$args)}`,
variables: {"plugin_id": "DupFileManager", "args": {"removeExcludeForDelTag":this.id, "mode":"remove_an_exclude_tag"}},
}), success: function(result){
$("#div1").html(result);
}});
this.style.visibility = 'hidden';
if (!chkBxRemoveValid.checked) alert("Sent remove exclude tag request for scene ID# " + this.id)
}
else if (this.value === "mergeTags")
{
$.ajax({method: "POST", url: "http://127.0.0.1:9999/graphql", contentType: "application/json",
data: JSON.stringify({
query: `mutation RunPluginOperation($plugin_id:ID!,$args:Map!){runPluginOperation(plugin_id:$plugin_id,args:$args)}`,
variables: {"plugin_id": "DupFileManager", "args": {"mergeScenes":this.id, "mode":"merge_tags"}},
}), success: function(result){
$("#div1").html(result);
}});
this.style.visibility = 'hidden';
if (!chkBxRemoveValid.checked) alert("Sent merge scene request for scenes " + this.id)
}
});
});
</script>
</head>
<body>
<center><table style="color:darkgreen;background-color:powderblue;">
<tr><th>Report Info</th><th>Report Options</th></tr>
<tr>
<td><table><tr>
<td>Found (QtyPlaceHolder) duplice sets</td>
<td>Date Created: (DateCreatedPlaceHolder)</td>
</tr></table></td>
<td><table><tr>
<td><input type="checkbox" id="RemoveValidatePrompt" name="RemoveValidatePrompt"><label for="RemoveValidatePrompt" title="Disable Validate Prompts (Popups)">Disable Task Prompt</label><br></td>
<td><input type="checkbox" id="RemoveToKeepConfirm" name="RemoveToKeepConfirm"><label for="RemoveToKeepConfirm" title="Disable confirmation prompts for delete scenes">Disable Delete Confirmation</label><br></td>
</tr></table></td>
</tr></table></center>
<h2>Stash Duplicate Scenes Report (MatchTypePlaceHolder)</h2>\n""",
# HTML report postfiox, after table listing
"htmlReportPostfix" : "\n</body></html>",
# HTML report table
"htmlReportTable" : "<table style=\"width:100%\">",
# HTML report table row
"htmlReportTableRow" : "<tr>",
# HTML report table header
"htmlReportTableHeader" : "<th>",
# HTML report table data
"htmlReportTableData" : "<td>",
# HTML report video preview
"htmlReportVideoPreview" : "width='160' height='120' controls", # Alternative option "autoplay loop controls" or "autoplay controls"
# The number off seconds in time difference for supper highlight on htmlReport
"htmlHighlightTimeDiff" : 3,
# Supper highlight for details with higher resolution or duration
"htmlSupperHighlight" : "yellow",
# Lower highlight for details with slightly higher duration
"htmlLowerHighlight" : "nyanza",
# Text color for details with different resolution, duration, size, bitrate,codec, or framerate
"htmlDetailDiffTextColor" : "red",
# Paginate HTML report. Maximum number of results to display on one page, before adding (paginating) an additional page.
"htmlReportPaginate" : 100,
# The following fields are ONLY used when running DupFileManager in script mode
"endpoint_Scheme" : "http", # Define endpoint to use when contacting the Stash server