forked from Github/Axter-Stash
Moved rarely used fields to config file
This commit is contained in:
@@ -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