From b0781b45f830d4961178129a36de065ff4409c04 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 19 Sep 2013 23:49:23 +0200 Subject: [PATCH] Different seperator for folder and filename --- couchpotato/core/plugins/renamer/__init__.py | 8 +++++++- couchpotato/core/plugins/renamer/main.py | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) mode change 100644 => 100755 couchpotato/core/plugins/renamer/main.py diff --git a/couchpotato/core/plugins/renamer/__init__.py b/couchpotato/core/plugins/renamer/__init__.py index 6472a2d..921b3e1 100755 --- a/couchpotato/core/plugins/renamer/__init__.py +++ b/couchpotato/core/plugins/renamer/__init__.py @@ -120,7 +120,13 @@ config = [{ { 'advanced': True, 'name': 'separator', - 'label': 'Separator', + 'label': 'File-Separator', + 'description': 'Replace all the spaces with a character. Example: ".", "-" (without quotes). Leave empty to use spaces.', + }, + { + 'advanced': True, + 'name': 'foldersep', + 'label': 'Folder-Separator', 'description': 'Replace all the spaces with a character. Example: ".", "-" (without quotes). Leave empty to use spaces.', }, { diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py old mode 100644 new mode 100755 index 0013298..ad7df1c --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -252,7 +252,7 @@ class Renamer(Plugin): replacements['cd_nr'] = cd if multiple else '' # Naming - final_folder_name = self.doReplace(folder_name, replacements) + final_folder_name = self.doReplace(folder_name, replacements, folder = True) final_file_name = self.doReplace(file_name, replacements) replacements['filename'] = final_file_name[:-(len(getExt(final_file_name)) + 1)] @@ -508,7 +508,7 @@ class Renamer(Plugin): for extra in set(filter(test, group['files'][extra_type])): replacements['ext'] = getExt(extra) - final_folder_name = self.doReplace(folder_name, replacements, remove_multiple = remove_multiple) + final_folder_name = self.doReplace(folder_name, replacements, remove_multiple = remove_multiple, folder = True) final_file_name = self.doReplace(file_name, replacements, remove_multiple = remove_multiple) rename_files[extra] = os.path.join(destination, final_folder_name, final_file_name) @@ -603,7 +603,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) return True - def doReplace(self, string, replacements, remove_multiple = False): + def doReplace(self, string, replacements, remove_multiple = False, folder = False): """ replace confignames with the real thing """ @@ -623,7 +623,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) replaced = re.sub(r"[\x00:\*\?\"<>\|]", '', replaced) - sep = self.conf('separator') + sep = self.conf('foldersep') if folder else self.conf('separator') return self.replaceDoubles(replaced.lstrip('. ')).replace(' ', ' ' if not sep else sep) def replaceDoubles(self, string):