From ce347a029c8e6a0708754d6deebc03deeaaf057a Mon Sep 17 00:00:00 2001 From: Belleyy Date: Sun, 16 Jan 2022 00:08:27 +0100 Subject: [PATCH] [renamerOnUpdate] Add option to ignore the Path Length reduction. (#23) * Update renamerOnUpdate.py * Update config.py * Update renamerOnUpdate.yml --- plugins/renamerOnUpdate/config.py | 4 ++++ plugins/renamerOnUpdate/renamerOnUpdate.py | 6 +++--- plugins/renamerOnUpdate/renamerOnUpdate.yml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/renamerOnUpdate/config.py b/plugins/renamerOnUpdate/config.py index b2421d7..479343b 100644 --- a/plugins/renamerOnUpdate/config.py +++ b/plugins/renamerOnUpdate/config.py @@ -63,8 +63,12 @@ prevent_title_performer = False # Only rename 'Organized' scenes. only_organized = False + +# If the new path is over 240 characters, the plugin will try to reduce it. Set to True to ignore that. +ignore_path_length = False # Field to remove if the path is too long. First in list will be removed then second then ... if length is still too long. order_field = ["$video_codec", "$audio_codec", "$resolution", "$height", "$studio_family", "$studio", "$parent_studio","$performer"] + # Alternate way to show diff. Not useful at all. alt_diff_display = False diff --git a/plugins/renamerOnUpdate/renamerOnUpdate.py b/plugins/renamerOnUpdate/renamerOnUpdate.py index c7b45e8..6420272 100644 --- a/plugins/renamerOnUpdate/renamerOnUpdate.py +++ b/plugins/renamerOnUpdate/renamerOnUpdate.py @@ -252,13 +252,13 @@ filename_template = None # READING CONFIG - - PERFORMER_SPLITCHAR = config.performer_splitchar PERFORMER_LIMIT = config.performer_limit PERFORMER_IGNORE_MALE = config.performer_ignore_male PREVENT_TITLE_PERF = config.prevent_title_performer +IGNORE_PATH_LENGTH = config.ignore_path_length + PROCESS_KILL = config.process_kill_attach PROCESS_ALLRESULT = config.process_getall UNICODE_USE = config.use_ascii @@ -385,7 +385,7 @@ new_path = current_path.rstrip(current_filename) + new_filename # Trying to prevent error with long paths for Win10 # https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd -if len(new_path) > 240: +if len(new_path) > 240 and not IGNORE_PATH_LENGTH: log.LogWarning("Resulting Path is too long ({})...".format(len(new_path))) for word in ORDER_SHORTFIELD: if word not in filename_template: diff --git a/plugins/renamerOnUpdate/renamerOnUpdate.yml b/plugins/renamerOnUpdate/renamerOnUpdate.yml index 5b74d14..f40fdf1 100644 --- a/plugins/renamerOnUpdate/renamerOnUpdate.yml +++ b/plugins/renamerOnUpdate/renamerOnUpdate.yml @@ -1,7 +1,7 @@ name: renamerOnUpdate description: Rename filename based on a template. url: https://github.com/stashapp/CommunityScripts -version: 1.3 +version: 1.4 exec: - python - "{pluginDir}/renamerOnUpdate.py"