forked from Github/Axter-Stash
FileMonitor ver 1.0.3
- Added start and stop FileMonitor button to Tools-UI FileMonitor Status - Fixed bug associated with starting FileMonitor service with no jobs waiting.
This commit is contained in:
@@ -18,6 +18,7 @@ html.wait, html.wait * { cursor: wait !important; }
|
||||
<link rel="stylesheet" type="text/css" href="https://www.axter.com/js/jquery.prompt.css"/>
|
||||
<script>
|
||||
const isChrome = !!window.chrome;
|
||||
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let thisUrl = "" + window.location;
|
||||
const isAxterCom = (thisUrl.search("axter.com") > -1);
|
||||
@@ -288,7 +289,17 @@ function ProcessClick(This_){
|
||||
RunPluginDupFileManager(ID, Param, true);
|
||||
}
|
||||
}
|
||||
|
||||
var scenesPerPageOver250WarningGiven = false;
|
||||
var scenesPerPageOver350WarningGiven = false;
|
||||
$(document).ready(function(){
|
||||
var scenesPerPageInput = document.getElementById("scenesPerPage");
|
||||
if (isChrome){
|
||||
scenesPerPageInput.setAttribute("max",1000);
|
||||
}
|
||||
else if (isFirefox){
|
||||
scenesPerPageInput.setAttribute("max",5000);
|
||||
}
|
||||
if ($("#IncludePreviewImage").prop('checked')){
|
||||
$("#ImagePreviewSize").prop('disabled', false);
|
||||
$("#ImagePreviewPopupSize").prop('disabled', false);
|
||||
@@ -370,6 +381,16 @@ $(document).ready(function(){
|
||||
$("#VideoPreviewHeight").prop('disabled', true);
|
||||
}
|
||||
});
|
||||
$("#scenesPerPage").change(function() {
|
||||
if (!isFirefox && $("#scenesPerPage").val() > 250 && $("#scenesPerPage").val() < 351 && scenesPerPageOver250WarningGiven == false){
|
||||
scenesPerPageOver250WarningGiven = true;
|
||||
alert("Using more than 250 scenes per page will trigger a long page load delay. Browsers like Chrome and MS Edge perform poorly. It's recommend to use Firefox browser for this many scenes per page.");
|
||||
}
|
||||
else if ($("#scenesPerPage").val() > 350 && scenesPerPageOver350WarningGiven == false){
|
||||
scenesPerPageOver350WarningGiven = true;
|
||||
alert("It's not pratical to create a report with more than 350 scenes per page. Some browsers (Chrome & Edge) will hang when trying to load the page.");
|
||||
}
|
||||
});
|
||||
});
|
||||
function DeleteDupInPath(){
|
||||
alert('Something went wrong!!!');
|
||||
@@ -2046,7 +2067,7 @@ function DeleteDupInPath(){
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="easyui-tooltip" title="Number of scenes per page in report. Default value is 100."><label for="scenesPerPage">Scenes Per Page:</label><input type="number" min="25" max="5000" step="25" id="scenesPerPage" name="scenesPerPage" value="100"></div>
|
||||
<div class="easyui-tooltip" title="Number of scenes per page in report. Default value is 100. Over 350 scenes per page is not recommended."><label for="scenesPerPage">Scenes Per Page:</label><input type="number" min="25" max="2000" step="25" id="scenesPerPage" name="scenesPerPage" value="100"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="easyui-tooltip" title="The minimum time difference in seconds for report to highlight scene time. This is the time difference between [Duplicate-to-Delete] scene and [Scene-ToKeep]. Default value is 3."><label for="TimeDiffHighlight">Time Diff Highlight:</label><input type="number" min="1" max="300" step="1" id="TimeDiffHighlight" name="TimeDiffHighlight" value="3"></div>
|
||||
@@ -2054,7 +2075,7 @@ function DeleteDupInPath(){
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="easyui-tooltip" title="Create report with a collage preview image."><label for="IncludePreviewImage">Collage preview image:</label><input type="checkbox" id="IncludePreviewImage" name="IncludePreviewImage" value="true"></div>
|
||||
<table style="width:100%;border:none;" cellspacing="0" cellpadding="0"><tr><td style="border:none;"><div class="easyui-tooltip" title="Create report with a collage preview image."><label for="IncludePreviewImage">Collage preview image:</label><input type="checkbox" id="IncludePreviewImage" name="IncludePreviewImage" value="true"></div></td><td style="text-align:right;border:none;">[<b style="color:red;" class="easyui-tooltip" title="Recommend using preview image over preview video for report with over 500 scenes per page.">?</b>]</td></tr></table>
|
||||
<div class="easyui-tooltip" title="Create report with scene cover preview image. Requires DupFileManger version 1.1.6 or higher."><label for="IncludeSceneCoverPreviewImage">Scene cover preview image:</label><input type="checkbox" id="IncludeSceneCoverPreviewImage" name="IncludeSceneCoverPreviewImage" value="true"></div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -2093,7 +2114,7 @@ function DeleteDupInPath(){
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">
|
||||
<div class="easyui-tooltip" title="Create report with preview video."><label for="IncludePreviewVideo">Preview video:</label><input type="checkbox" id="IncludePreviewVideo" name="IncludePreviewVideo" value="true" checked></div>
|
||||
<table style="width:100%;border:none;" cellspacing="0" cellpadding="0"><tr><td style="border:none;"><div class="easyui-tooltip" title="Create report with preview video."><label for="IncludePreviewVideo">Preview video:</label><input type="checkbox" id="IncludePreviewVideo" name="IncludePreviewVideo" value="true" checked></div></td><td style="text-align:right;border:none;">[<b style="color:red;" class="easyui-tooltip" title="Recommend using preview image over preview video for report with over 500 scenes per page.">?</b>]</td></tr></table>
|
||||
<div class="easyui-tooltip" title="Create report with Webp preview video. Requires DupFileManger version 1.1.6 or higher."><label for="IncludeWebpPreviewImage">Webp preview video:</label><input type="checkbox" id="IncludeWebpPreviewImage" name="IncludeWebpPreviewImage" value="true"></div>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# FileMonitor: Ver 1.0.2 (By David Maisonave)
|
||||
# FileMonitor: Ver 1.0.3 (By David Maisonave)
|
||||
|
||||
FileMonitor is a [Stash](https://github.com/stashapp/stash) plugin with the following two main features:
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
const { Link, NavLink, } = PluginApi.libraries.ReactRouterDOM;
|
||||
var iconToUse = faFileCircleXmark;
|
||||
var FileMonitorRunningStatusStr = "";
|
||||
var StartOrStop_FileMonitorButton = null;
|
||||
var DockerWarning = null;
|
||||
function RunPluginFileMonitor(Mode, ActionID = 0, DataType = "text", Async = false) {
|
||||
console.log("Mode = " + Mode);
|
||||
@@ -29,10 +30,12 @@
|
||||
if (result.indexOf("FileMonitorStatus:'RUNNING'") > 0){
|
||||
iconToUse = faFileCircleCheck;
|
||||
FileMonitorRunningStatusStr = "FileMonitor is RUNNING...";
|
||||
StartOrStop_FileMonitorButton = React.createElement(Link, { to: "/FileMonitor_Stop", title: "Stops library monitoring within 2 minutes." }, React.createElement(Button, null, "Stop Library Monitor"));
|
||||
}
|
||||
else {
|
||||
iconToUse = faFileCircleXmark;
|
||||
FileMonitorRunningStatusStr = "FileMonitor is NOT running!!!";
|
||||
StartOrStop_FileMonitorButton = React.createElement(Link, { to: "/FileMonitor_Start", title: "Run FileMonitor as a SERVICE to update Stash with any media file changes." }, React.createElement(Button, null, "Start Library Monitor Service"));
|
||||
}
|
||||
if (result.indexOf("IS_DOCKER:'True'") > 0){
|
||||
DockerWarning = React.createElement("div", null,
|
||||
@@ -66,7 +69,9 @@
|
||||
});
|
||||
}
|
||||
RunPluginFileMonitor("getFileMonitorRunningStatus");
|
||||
const HomePage = () => {
|
||||
function DisplayFileMonitorRunningStatus(PreCmd = null) {
|
||||
if (PreCmd != null)
|
||||
RunPluginFileMonitor(PreCmd);
|
||||
RunPluginFileMonitor("getFileMonitorRunningStatus", 1);
|
||||
console.log("FileMonitorRunningStatusStr = " + FileMonitorRunningStatusStr);
|
||||
var MyHeader = React.createElement("h1", null, "FileMonitor Running Status Page");
|
||||
@@ -75,10 +80,22 @@
|
||||
React.createElement("p", null),
|
||||
React.createElement("p", null),
|
||||
React.createElement("h4", null, FileMonitorRunningStatusStr),
|
||||
DockerWarning
|
||||
DockerWarning,
|
||||
StartOrStop_FileMonitorButton
|
||||
));
|
||||
}
|
||||
const HomePage = () => {
|
||||
return DisplayFileMonitorRunningStatus();
|
||||
};
|
||||
const FileMonitor_Start = () => {
|
||||
return DisplayFileMonitorRunningStatus("start_library_monitor_service_json");
|
||||
};
|
||||
const FileMonitor_Stop = () => {
|
||||
return DisplayFileMonitorRunningStatus("stop_library_monitor_json");
|
||||
};
|
||||
PluginApi.register.route("/FileMonitor", HomePage);
|
||||
PluginApi.register.route("/FileMonitor_Start", FileMonitor_Start);
|
||||
PluginApi.register.route("/FileMonitor_Stop", FileMonitor_Stop);
|
||||
PluginApi.patch.before("SettingsToolsSection", function (props) {
|
||||
const { Setting, } = PluginApi.components;
|
||||
return [
|
||||
|
||||
@@ -65,11 +65,15 @@ stash = StashPluginHelper(
|
||||
apiKey=parse_args.apikey
|
||||
)
|
||||
|
||||
doJsonReturnModeTypes = ["getFileMonitorRunningStatus"]
|
||||
doJsonReturnModeTypes = ["getFileMonitorRunningStatus", "start_library_monitor_service_json", "stop_library_monitor_json"]
|
||||
doJsonReturn = False
|
||||
doJsonReturnFileMonitorStatus = False
|
||||
if len(sys.argv) < 2 and stash.PLUGIN_TASK_NAME in doJsonReturnModeTypes:
|
||||
doJsonReturn = True
|
||||
doJsonReturnFileMonitorStatus = True
|
||||
stash.log_to_norm = stash.LogTo.FILE
|
||||
if stash.PLUGIN_TASK_NAME.endswith("_json"):
|
||||
stash.PLUGIN_TASK_NAME = stash.PLUGIN_TASK_NAME[:-5]
|
||||
|
||||
stash.status(logLevel=logging.DEBUG)
|
||||
stash.Log(f"\nStarting (__file__={__file__}) (stash.CALLED_AS_STASH_PLUGIN={stash.CALLED_AS_STASH_PLUGIN}) (stash.DEBUG_TRACING={stash.DEBUG_TRACING}) (stash.DRY_RUN={stash.DRY_RUN}) (stash.PLUGIN_TASK_NAME={stash.PLUGIN_TASK_NAME})************************************************")
|
||||
@@ -213,6 +217,8 @@ def isJobWaitingToRun(getJobIdOf_StartAsAServiceTask = False):
|
||||
FileMonitorPluginIsOnTaskQue = False
|
||||
jobIsWaiting = False
|
||||
taskQue = stash.job_queue()
|
||||
if taskQue == None:
|
||||
return jobIsWaiting
|
||||
for jobDetails in taskQue:
|
||||
stash.Trace(f"(Job ID({jobDetails['id']})={jobDetails})")
|
||||
if getJobIdOf_StartAsAServiceTask:
|
||||
@@ -882,6 +888,8 @@ def stop_library_monitor():
|
||||
stash.Trace(f"Shared memory map opended, and flag set to {shm_buffer[0]}")
|
||||
shm_a.close()
|
||||
shm_a.unlink() # Call unlink only once to release the shared memory
|
||||
if doJsonReturnFileMonitorStatus:
|
||||
sys.stdout.write("{" + f"{stash.PLUGIN_TASK_NAME} : 'complete', FileMonitorStatus:'NOT running', IS_DOCKER:'{stash.IS_DOCKER}'" + "}")
|
||||
|
||||
def start_library_monitor_service():
|
||||
# First check if FileMonitor is already running
|
||||
@@ -901,6 +909,9 @@ def start_library_monitor_service():
|
||||
args += ["-a", stash.API_KEY]
|
||||
results = stash.executePythonScript(args)
|
||||
stash.Trace(f"executePythonScript results='{results}'")
|
||||
if doJsonReturnFileMonitorStatus:
|
||||
time.sleep(5)
|
||||
sys.stdout.write("{" + f"{stash.PLUGIN_TASK_NAME} : 'complete', FileMonitorStatus:'RUNNING', IS_DOCKER:'{stash.IS_DOCKER}'" + "}")
|
||||
|
||||
def synchronize_library(removeScene=False):
|
||||
stash.startSpinningProcessBar()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: FileMonitor
|
||||
description: Monitors the Stash library folders, and updates Stash if any changes occurs in the Stash library paths.
|
||||
version: 1.0.2
|
||||
version: 1.0.3
|
||||
url: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor
|
||||
ui:
|
||||
javascript:
|
||||
|
||||
@@ -6,3 +6,6 @@
|
||||
- Added Docker support.
|
||||
### 1.0.2
|
||||
- Added ability to monitor host file system for multiple Docker Stash installations.
|
||||
### 1.0.3
|
||||
- Added start and stop FileMonitor button to Tools-UI FileMonitor Status
|
||||
- Fixed bug associated with starting FileMonitor service with no jobs waiting.
|
||||
Reference in New Issue
Block a user