forked from Github/Axter-Stash
Moved rarely used fields to config file
This commit is contained in:
@@ -20,6 +20,7 @@ from watchdog.observers import Observer # This is also needed for event attribut
|
||||
import watchdog # pip install watchdog # https://pythonhosted.org/watchdog/
|
||||
from threading import Lock, Condition
|
||||
from multiprocessing import shared_memory
|
||||
from changefilemonitor_config import config # Import settings from changefilemonitor_config.py
|
||||
|
||||
# **********************************************************************
|
||||
# Constant global variables --------------------------------------------
|
||||
@@ -91,7 +92,7 @@ if gettingCalledAsStashPlugin and StdInRead:
|
||||
FRAGMENT_SERVER = json_input["server_connection"]
|
||||
else:
|
||||
runningInPluginMode = False
|
||||
FRAGMENT_SERVER = {'Scheme': 'http', 'Host': '0.0.0.0', 'Port': 9999, 'SessionCookie': {'Name': 'session', 'Value': '', 'Path': '', 'Domain': '', 'Expires': '0001-01-01T00:00:00Z', 'RawExpires': '', 'MaxAge': 0, 'Secure': False, 'HttpOnly': False, 'SameSite': 0, 'Raw': '', 'Unparsed': None}, 'Dir': os.path.dirname(Path(__file__).resolve().parent), 'PluginDir': Path(__file__).resolve().parent}
|
||||
FRAGMENT_SERVER = {'Scheme': config['endpoint_Scheme'], 'Host': config['endpoint_Host'], 'Port': config['endpoint_Port'], 'SessionCookie': {'Name': 'session', 'Value': '', 'Path': '', 'Domain': '', 'Expires': '0001-01-01T00:00:00Z', 'RawExpires': '', 'MaxAge': 0, 'Secure': False, 'HttpOnly': False, 'SameSite': 0, 'Raw': '', 'Unparsed': None}, 'Dir': os.path.dirname(Path(__file__).resolve().parent), 'PluginDir': Path(__file__).resolve().parent}
|
||||
print("Running in non-plugin mode!", file=sys.stderr)
|
||||
|
||||
stash = StashInterface(FRAGMENT_SERVER)
|
||||
@@ -102,7 +103,6 @@ stashPaths = []
|
||||
settings = {
|
||||
"recursiveDisabled": False,
|
||||
"runCleanAfterDelete": False,
|
||||
"runGenerateContent": False,
|
||||
"scanModified": False,
|
||||
"zzdebugTracing": False,
|
||||
"zzdryRun": False,
|
||||
@@ -115,7 +115,7 @@ debugTracing = settings["zzdebugTracing"]
|
||||
RECURSIVE = settings["recursiveDisabled"] == False
|
||||
SCAN_MODIFIED = settings["scanModified"]
|
||||
RUN_CLEAN_AFTER_DELETE = settings["runCleanAfterDelete"]
|
||||
RUN_GENERATE_CONTENT = settings["runGenerateContent"]
|
||||
RUN_GENERATE_CONTENT = config['runGenerateContent']
|
||||
|
||||
for item in STASHPATHSCONFIG:
|
||||
stashPaths.append(item["path"])
|
||||
|
||||
@@ -11,10 +11,6 @@ settings:
|
||||
displayName: Run Clean
|
||||
description: Enable to run metadata clean task after file deletion.
|
||||
type: BOOLEAN
|
||||
runGenerateContent:
|
||||
displayName: Run Generate Content
|
||||
description: Enable to run metadata_generate (Generate Content) after metadata scan.
|
||||
type: BOOLEAN
|
||||
scanModified:
|
||||
displayName: Scan Modifications
|
||||
description: Enable to monitor changes in file system for modification flag. This option is NOT needed for Windows, because on Windows changes are triggered via CREATE, DELETE, and MOVE flags. Other OS may differ.
|
||||
|
||||
12
plugins/ChangeFileMonitor/changefilemonitor_config.py
Normal file
12
plugins/ChangeFileMonitor/changefilemonitor_config.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# Description: This is a Stash plugin which updates Stash if any changes occurs in the Stash library paths.
|
||||
# By David Maisonave (aka Axter) Jul-2024 (https://www.axter.com/)
|
||||
# Get the latest developers version from following link: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/ChangeFileMonitor
|
||||
config = {
|
||||
# Enable to run metadata_generate (Generate Content) after metadata scan.
|
||||
"runGenerateContent": False,
|
||||
|
||||
# The following fields are ONLY used when running ChangeFileMonitor in script mode
|
||||
"endpoint_Scheme" : "http", # Define endpoint to use when contacting the Stash server
|
||||
"endpoint_Host" : "0.0.0.0", # Define endpoint to use when contacting the Stash server
|
||||
"endpoint_Port" : 9999, # Define endpoint to use when contacting the Stash server
|
||||
}
|
||||
@@ -19,7 +19,6 @@ from renamefile_settings import config # Import settings from renamefile_setting
|
||||
# Constant global variables --------------------------------------------
|
||||
LOG_FILE_PATH = log_file_path = f"{Path(__file__).resolve().parent}\\{Path(__file__).stem}.log"
|
||||
FORMAT = "[%(asctime)s - LN:%(lineno)s] %(message)s"
|
||||
DEFAULT_ENDPOINT = "http://localhost:9999/graphql" # Default GraphQL endpoint
|
||||
DEFAULT_FIELD_KEY_LIST = "title,performers,studio,tags" # Default Field Key List with the desired order
|
||||
PLUGIN_ID = Path(__file__).stem.lower()
|
||||
DEFAULT_SEPERATOR = "-"
|
||||
@@ -58,9 +57,10 @@ logger = logging.getLogger(PLUGIN_ID)
|
||||
# ----------------------------------------------------------------------
|
||||
# Code section to fetch variables from Plugin UI and from renamefile_settings.py
|
||||
json_input = json.loads(sys.stdin.read())
|
||||
FRAGMENT_SERVER = json_input["server_connection"]
|
||||
FRAGMENT_SERVER = json_input['server_connection']
|
||||
stash = StashInterface(FRAGMENT_SERVER)
|
||||
pluginConfiguration = stash.get_configuration()["plugins"]
|
||||
|
||||
settings = {
|
||||
"performerAppend": False,
|
||||
"studioAppend": False,
|
||||
@@ -68,11 +68,8 @@ settings = {
|
||||
"z_keyFIeldsIncludeInFileName": False,
|
||||
"zafileRenameViaMove": False,
|
||||
"zfieldKeyList": DEFAULT_FIELD_KEY_LIST,
|
||||
"zgraphqlEndpoint": DEFAULT_ENDPOINT,
|
||||
"zmaximumTagKeys": 12,
|
||||
"zpathToExclude": "",
|
||||
"zseparators": DEFAULT_SEPERATOR,
|
||||
"ztagWhitelist": "",
|
||||
"zzdebugTracing": False,
|
||||
"zzdryRun": False,
|
||||
}
|
||||
@@ -95,11 +92,19 @@ except:
|
||||
pass
|
||||
logger.info(f"\nStarting (debugTracing={debugTracing}) (dry_run={dry_run}) (PLUGIN_ARGS_MODE={PLUGIN_ARGS_MODE}) (inputToUpdateScenePost={inputToUpdateScenePost})************************************************")
|
||||
if debugTracing: logger.info("settings: %s " % (settings,))
|
||||
# if PLUGIN_ID in pluginConfiguration:
|
||||
# if debugTracing: logger.info(f"Debug Tracing (pluginConfiguration[PLUGIN_ID]={pluginConfiguration[PLUGIN_ID]})................")
|
||||
|
||||
if PLUGIN_ID in pluginConfiguration:
|
||||
if debugTracing: logger.info(f"Debug Tracing (pluginConfiguration[PLUGIN_ID]={pluginConfiguration[PLUGIN_ID]})................")
|
||||
# if 'zmaximumTagKeys' not in pluginConfiguration[PLUGIN_ID]:
|
||||
# if debugTracing: logger.info("Debug Tracing................")
|
||||
# stash.configure_plugin(PLUGIN_ID, settings) # , init_defaults=True
|
||||
# try:
|
||||
# stash.configure_plugin(PLUGIN_ID, settings)
|
||||
# stash.configure_plugin("renamefile", {"zmaximumTagKeys": 12})
|
||||
# except Exception as e:
|
||||
# logger.error(f"configure_plugin failed!!! Error: {e}")
|
||||
# logger.exception('Got exception on main handler')
|
||||
# pass
|
||||
# # stash.configure_plugin(PLUGIN_ID, settings) # , init_defaults=True
|
||||
# if debugTracing: logger.info("Debug Tracing................")
|
||||
|
||||
if dry_run:
|
||||
@@ -109,18 +114,21 @@ if debugTracing: logger.info("Debug Tracing................")
|
||||
max_tag_keys = settings["zmaximumTagKeys"] if settings["zmaximumTagKeys"] != 0 else 12 # Need this incase use explicitly sets value to zero in UI
|
||||
if debugTracing: logger.info("Debug Tracing................")
|
||||
# ToDo: Add split logic here to slpit possible string array into an array
|
||||
exclude_paths = settings["zpathToExclude"]
|
||||
exclude_paths = config["pathToExclude"]
|
||||
exclude_paths = exclude_paths.split()
|
||||
if debugTracing: logger.info(f"Debug Tracing (exclude_paths={exclude_paths})................")
|
||||
# Extract tag whitelist from settings
|
||||
tag_whitelist = settings["ztagWhitelist"]
|
||||
tag_whitelist = config["tagWhitelist"]
|
||||
if debugTracing: logger.info("Debug Tracing................")
|
||||
if not tag_whitelist:
|
||||
tag_whitelist = ""
|
||||
if debugTracing: logger.info(f"Debug Tracing (tag_whitelist={tag_whitelist})................")
|
||||
endpoint = settings["zgraphqlEndpoint"] # GraphQL endpoint
|
||||
if not endpoint or endpoint == "":
|
||||
endpoint = DEFAULT_ENDPOINT
|
||||
|
||||
endpointHost = json_input['server_connection']['Host']
|
||||
if endpointHost == "0.0.0.0":
|
||||
endpointHost = "localhost"
|
||||
endpoint = f"{json_input['server_connection']['Scheme']}://{endpointHost}:{json_input['server_connection']['Port']}/graphql"
|
||||
|
||||
if debugTracing: logger.info(f"Debug Tracing (endpoint={endpoint})................")
|
||||
# Extract rename_files and move_files settings from renamefile_settings.py
|
||||
rename_files = config["rename_files"]
|
||||
|
||||
@@ -27,26 +27,14 @@ settings:
|
||||
displayName: Key Fields
|
||||
description: '(Default=title,performers,studio,tags) Define key fields to use to format the file name. This is a comma seperated list, and the list should be in the desired format order. For example, if the user wants the performers name before the title, set the performers name first. Example:"performers,title,tags". This is an example of user adding height:"title,performers,tags,height" Here''s an example using all of the supported fields: "title,performers,tags,studio,galleries,resolution,width,height,video_codec,frame_rate,date".'
|
||||
type: STRING
|
||||
zgraphqlEndpoint:
|
||||
displayName: GraphQL Endpoint
|
||||
description: (Default=http://localhost:9999/graphql). Update with your endpoint, or leave blank to use default.
|
||||
type: STRING
|
||||
zmaximumTagKeys:
|
||||
displayName: Max Tag Keys
|
||||
description: (Default=12) Maximum quantity of tag keys to append to file name. 0=Default(12); -1=No tags appended.
|
||||
type: NUMBER
|
||||
zpathToExclude:
|
||||
displayName: Exclude Path
|
||||
description: 'Add path(s) to exclude from RenameFile. Example Usage: r"/path/to/exclude1" When entering multiple paths, use space. Example: r"/path_1_to/exclude" r"/someOtherPath2Exclude" r"/yetAnotherPath"'
|
||||
type: STRING
|
||||
zseparators:
|
||||
displayName: Separator
|
||||
description: '(Default=-) Define the separator to use between different parts of the filename. Example Usage: ","'
|
||||
type: STRING
|
||||
ztagWhitelist:
|
||||
displayName: Tag Whitelist
|
||||
description: 'Define a whitelist of allowed tags or EMPTY to allow all tags. Example Usage: "tag1", "tag2", "tag3"'
|
||||
type: STRING
|
||||
zzdebugTracing:
|
||||
displayName: Debug Tracing
|
||||
description: (Default=false) [***For Advanced Users***] Enable debug tracing. When enabled, additional tracing logging is added to Stash\plugins\RenameFile\renamefile.log
|
||||
|
||||
@@ -37,6 +37,10 @@ config = {
|
||||
"frame_rate": 'FR',
|
||||
"date": '',
|
||||
},
|
||||
# Add path(s) to exclude from RenameFile. Example Usage: r"/path/to/exclude1" When entering multiple paths, use space. Example: r"/path_1_to/exclude" r"/someOtherPath2Exclude" r"/yetAnotherPath"
|
||||
"pathToExclude": "",
|
||||
# Define a whitelist of allowed tags or EMPTY to allow all tags. Example Usage: "tag1", "tag2", "tag3"
|
||||
"tagWhitelist": "",
|
||||
# Define whether files should be renamed when moved
|
||||
"rename_files": True,
|
||||
# Define whether the original file name should be used if title is empty
|
||||
|
||||
Reference in New Issue
Block a user