forked from Github/Axter-Stash
misc
This commit is contained in:
@@ -11,10 +11,10 @@
|
|||||||
name: FileMonitor
|
name: FileMonitor
|
||||||
metadata:
|
metadata:
|
||||||
description: Monitors the Stash library folders, and updates Stash if any changes occurs in the Stash library paths.
|
description: Monitors the Stash library folders, and updates Stash if any changes occurs in the Stash library paths.
|
||||||
version: 1.0.0
|
version: 1.0.1
|
||||||
date: 2024-12-26 13:00:00
|
date: 2024-12-26 13:00:00
|
||||||
path: filemonitor.zip
|
path: filemonitor.zip
|
||||||
sha256: e0b3f9c526593590adccf6c004fac63868abb517641a7e0ac049ab2b06bd51ec
|
sha256: 8800b061f0e2bb7f5f42a91eb1a27efef4f6b823739162c67380feb21d9a395d
|
||||||
|
|
||||||
- id: renamefile
|
- id: renamefile
|
||||||
name: RenameFile
|
name: RenameFile
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ set SharedMountPath2=%5
|
|||||||
set SharedMountPath3=%6
|
set SharedMountPath3=%6
|
||||||
set SharedMountPath4=%7
|
set SharedMountPath4=%7
|
||||||
set SharedMountPath5=%8
|
set SharedMountPath5=%8
|
||||||
set VariableArg=%9
|
set SharedMountPath6=%9
|
||||||
set SkipDockerCompose=
|
set SkipDockerCompose=
|
||||||
set DLNAFunctionality="no"
|
set DLNAFunctionality="no"
|
||||||
set PullDockerStashImage=
|
set PullDockerStashImage=
|
||||||
@@ -54,16 +54,16 @@ if /I [%SharedMountPath5%]==[SKIP] (set SkipDockerCompose=yes) & (set SharedMou
|
|||||||
if /I [%SharedMountPath5%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath5=)
|
if /I [%SharedMountPath5%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath5=)
|
||||||
if /I [%SharedMountPath5%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath5=)
|
if /I [%SharedMountPath5%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath5=)
|
||||||
if /I [%SharedMountPath5%]==[WRITE] (set MountAccess=) & (set SharedMountPath5=)
|
if /I [%SharedMountPath5%]==[WRITE] (set MountAccess=) & (set SharedMountPath5=)
|
||||||
if /I [%VariableArg%]==[DLNA] (set DLNAFunctionality=yes)
|
if /I [%SharedMountPath6%]==[DLNA] (set DLNAFunctionality=yes) & (set SharedMountPath6=)
|
||||||
if /I [%VariableArg%]==[SKIP] (set SkipDockerCompose=yes)
|
if /I [%SharedMountPath6%]==[SKIP] (set SkipDockerCompose=yes) & (set SharedMountPath6=)
|
||||||
if /I [%VariableArg%]==[IMAGE] (set PullDockerStashImage=yes)
|
if /I [%SharedMountPath6%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath6=)
|
||||||
if /I [%VariableArg%]==[PULL] (set PullDockerStashImage=yes)
|
if /I [%SharedMountPath6%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath6=)
|
||||||
if /I [%VariableArg%]==[WRITE] (set MountAccess=)
|
if /I [%SharedMountPath6%]==[WRITE] (set MountAccess=) & (set SharedMountPath6=)
|
||||||
:: If user incorrectly enters below arguments instead of Stash-Port, fetch the values, and let CHECK_STASH_PORT get the required Stash-Port.
|
:: If user incorrectly enters below arguments instead of Stash-Port, fetch the values, and let CHECK_STASH_PORT get the required Stash-Port.
|
||||||
if /I [%STASH_PORT%]==[DLNA] (set DLNAFunctionality=yes) & (set SharedMountPath=)
|
if /I [%STASH_PORT%]==[DLNA] (set DLNAFunctionality=yes) & (set STASH_PORT=)
|
||||||
if /I [%STASH_PORT%]==[SKIP] (set SkipDockerCompose=yes) & (set SharedMountPath=)
|
if /I [%STASH_PORT%]==[SKIP] (set SkipDockerCompose=yes) & (set STASH_PORT=)
|
||||||
if /I [%STASH_PORT%]==[IMAGE] (set PullDockerStashImage=yes) & (set SharedMountPath=)
|
if /I [%STASH_PORT%]==[IMAGE] (set PullDockerStashImage=yes) & (set STASH_PORT=)
|
||||||
if /I [%STASH_PORT%]==[PULL] (set PullDockerStashImage=yes) & (set SharedMountPath=)
|
if /I [%STASH_PORT%]==[PULL] (set PullDockerStashImage=yes) & (set STASH_PORT=)
|
||||||
echo SkipDockerCompose = %SkipDockerCompose% ; DLNAFunctionality = %DLNAFunctionality%
|
echo SkipDockerCompose = %SkipDockerCompose% ; DLNAFunctionality = %DLNAFunctionality%
|
||||||
set DockerComposeFile="docker-compose.yml"
|
set DockerComposeFile="docker-compose.yml"
|
||||||
|
|
||||||
@@ -71,14 +71,14 @@ if [%NewContainerName%]==[] goto :MissingArgumentNewContainerName
|
|||||||
goto :HaveVariableNewContainerName
|
goto :HaveVariableNewContainerName
|
||||||
:MissingArgumentNewContainerName
|
:MissingArgumentNewContainerName
|
||||||
set /p NewContainerName="Enter the new container name: "
|
set /p NewContainerName="Enter the new container name: "
|
||||||
if [%NewContainerName%]==[] goto :eof
|
if [%NewContainerName%]==[] call:ExitWithError 160 "ERROR_BAD_ARGUMENTS"
|
||||||
:HaveVariableNewContainerName
|
:HaveVariableNewContainerName
|
||||||
|
|
||||||
if [%Image%]==[] goto :MissingArgumentImage
|
if [%Image%]==[] goto :MissingArgumentImage
|
||||||
goto :HaveVariableImage
|
goto :HaveVariableImage
|
||||||
:MissingArgumentImage
|
:MissingArgumentImage
|
||||||
set /p Image="Enter the image name: "
|
set /p Image="Enter the image name: "
|
||||||
if [%Image%]==[] goto :eof
|
if [%Image%]==[] call:ExitWithError 160 "ERROR_BAD_ARGUMENTS"
|
||||||
:HaveVariableImage
|
:HaveVariableImage
|
||||||
|
|
||||||
:CHECK_STASH_PORT
|
:CHECK_STASH_PORT
|
||||||
@@ -91,7 +91,7 @@ echo Argument #3 requires a numeric value for Stash-Port. You entered "%STASH_P
|
|||||||
:MissingArgumentSTASH_PORT
|
:MissingArgumentSTASH_PORT
|
||||||
set STASH_PORT=
|
set STASH_PORT=
|
||||||
set /p STASH_PORT="Enter the Stash port number: "
|
set /p STASH_PORT="Enter the Stash port number: "
|
||||||
if [%STASH_PORT%]==[] Goto :eof
|
if [%STASH_PORT%]==[] call:ExitWithError 160 "ERROR_BAD_ARGUMENTS"
|
||||||
goto :CHECK_STASH_PORT
|
goto :CHECK_STASH_PORT
|
||||||
:HaveVariableSTASH_PORT
|
:HaveVariableSTASH_PORT
|
||||||
|
|
||||||
@@ -149,6 +149,8 @@ if [%SharedMountPath4%]==[] goto :SkipSharedMountPaths
|
|||||||
echo - %SharedMountPath4%:/external4%MountAccess%>> %DockerComposeFile%
|
echo - %SharedMountPath4%:/external4%MountAccess%>> %DockerComposeFile%
|
||||||
if [%SharedMountPath5%]==[] goto :SkipSharedMountPaths
|
if [%SharedMountPath5%]==[] goto :SkipSharedMountPaths
|
||||||
echo - %SharedMountPath5%:/external5%MountAccess%>> %DockerComposeFile%
|
echo - %SharedMountPath5%:/external5%MountAccess%>> %DockerComposeFile%
|
||||||
|
if [%SharedMountPath6%]==[] goto :SkipSharedMountPaths
|
||||||
|
echo - %SharedMountPath6%:/external5%MountAccess%>> %DockerComposeFile%
|
||||||
:SkipSharedMountPaths
|
:SkipSharedMountPaths
|
||||||
|
|
||||||
if [%SkipDockerCompose%] NEQ [] goto :DoNot_DockerCompose
|
if [%SkipDockerCompose%] NEQ [] goto :DoNot_DockerCompose
|
||||||
@@ -158,4 +160,9 @@ docker pull %Image%
|
|||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
:DoNot_DockerCompose
|
:DoNot_DockerCompose
|
||||||
cd ..
|
cd ..
|
||||||
|
Goto :eof
|
||||||
|
|
||||||
|
:ExitWithError
|
||||||
|
Echo Error: Exiting with error code %1 and error message %2
|
||||||
|
Exit %~1
|
||||||
|
Goto :eof
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
# To test, uninstall packages via command line: pip uninstall -y watchdog schedule requests
|
# To test, uninstall packages via command line: pip uninstall -y watchdog schedule requests
|
||||||
import sys, os, pathlib, platform, traceback
|
import sys, os, pathlib, platform, traceback
|
||||||
# ToDo: Add logic to optionally pull package requirements from requirements.txt file.
|
# ToDo: Add logic to optionally pull package requirements from requirements.txt file.
|
||||||
|
# Add logic to report error sys.exit(126) -- 126 (0x7E) ERROR_MOD_NOT_FOUND: The specified module could not be found.
|
||||||
|
|
||||||
def modulesInstalled(moduleNames, install=True, silent=False):
|
def modulesInstalled(moduleNames, install=True, silent=False):
|
||||||
retrnValue = True
|
retrnValue = True
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ dockerMapVolumes = {}
|
|||||||
dockerReverseMapVolumes = {}
|
dockerReverseMapVolumes = {}
|
||||||
dockerObservedPaths = {}
|
dockerObservedPaths = {}
|
||||||
if not parse_args.docker == None and len(parse_args.docker) > 0:
|
if not parse_args.docker == None and len(parse_args.docker) > 0:
|
||||||
|
if stash.IS_DOCKER:
|
||||||
|
stash.Error("You are running this script from within Docker. This is NOT supported. Run this script in the host machine instead. Performing early exit due to unsupported action.")
|
||||||
|
sys.exit(50) # ERROR_NOT_SUPPORTED: The request is not supported.
|
||||||
stash.Log(f"Docker compose YML file = {parse_args.docker}")
|
stash.Log(f"Docker compose YML file = {parse_args.docker}")
|
||||||
ModulesValidate.modulesInstalled(["pyyaml"], silent=True)
|
ModulesValidate.modulesInstalled(["pyyaml"], silent=True)
|
||||||
import yaml
|
import yaml
|
||||||
@@ -140,6 +143,13 @@ if not parse_args.docker == None and len(parse_args.docker) > 0:
|
|||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
stash.Error(f"Exception while parsing Docker file {parse_args.docker}; Error: {e}\nTraceBack={tb}")
|
stash.Error(f"Exception while parsing Docker file {parse_args.docker}; Error: {e}\nTraceBack={tb}")
|
||||||
|
|
||||||
|
if stash.IS_DOCKER:
|
||||||
|
stash.Error("You are running this script from within Docker. This is NOT supported. Run this script in the host machine instead.")
|
||||||
|
stash.Warn("For more information on running FileMonitor on host machine see following link:\n https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor#Docker")
|
||||||
|
stash.Warn("Performing early exit because FileMonitor has to run on the host machine, and can NOT run on Docker directly.")
|
||||||
|
sys.exit(10) # ERROR_BAD_ENVIRONMENT: The environment is incorrect.
|
||||||
|
# Alternate error: sys.exit(160) # ERROR_BAD_ARGUMENTS: One or more arguments are not correct.
|
||||||
|
|
||||||
if stash.DRY_RUN:
|
if stash.DRY_RUN:
|
||||||
stash.Log("Dry run mode is enabled.")
|
stash.Log("Dry run mode is enabled.")
|
||||||
stash.Trace(f"(SCAN_MODIFIED={SCAN_MODIFIED}) (SCAN_ON_ANY_EVENT={SCAN_ON_ANY_EVENT}) (RECURSIVE={RECURSIVE})")
|
stash.Trace(f"(SCAN_MODIFIED={SCAN_MODIFIED}) (SCAN_ON_ANY_EVENT={SCAN_ON_ANY_EVENT}) (RECURSIVE={RECURSIVE})")
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ def rename_files_task():
|
|||||||
all_scenes = scene_result['allScenes']
|
all_scenes = scene_result['allScenes']
|
||||||
if not all_scenes:
|
if not all_scenes:
|
||||||
stash.Error("No scenes found.")
|
stash.Error("No scenes found.")
|
||||||
exit()
|
sys.exit(13)
|
||||||
# Find the scene with the latest updated_at timestamp
|
# Find the scene with the latest updated_at timestamp
|
||||||
latest_scene = max(all_scenes, key=lambda scene: scene['updated_at'])
|
latest_scene = max(all_scenes, key=lambda scene: scene['updated_at'])
|
||||||
# Extract the ID of the latest scene
|
# Extract the ID of the latest scene
|
||||||
|
|||||||
Reference in New Issue
Block a user