From c1944c987d7b17772498db7980cadfc7e3f16954 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 14 Nov 2013 22:35:13 +0100 Subject: [PATCH] Add some more double char replacements --- couchpotato/core/plugins/renamer/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 45d46e5..c544f13 100755 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -748,18 +748,22 @@ Remove it if you want it to be renamed (again, or at least let it try again) for x, r in replacements.iteritems(): if x in ['thename', 'namethe']: replaced = replaced.replace(u'<%s>' % toUnicode(x), toUnicode(r)) - else: - continue replaced = re.sub(r"[\x00:\*\?\"<>\|]", '', replaced) sep = self.conf('foldersep') if folder else self.conf('separator') return replaced.replace(' ', ' ' if not sep else sep) def replaceDoubles(self, string): - replaces = [('\s', ' '), ('\s\.', ' '), ('\.', '.'), ('_', '_'), ('-', '-')] + + replaces = [ + ('\.+', '.'), ('_+', '_'), ('-+', '-'), ('\s+', ' '), + ('(\s\.)+', '.'), ('(-\.)+', '.'), ('(\s-)+', '-'), + ] + for r in replaces: reg, replace_with = r - string = re.sub('%s+' % reg, replace_with, string) + string = re.sub(reg, replace_with, string) + return string def deleteEmptyFolder(self, folder, show_error = True):