From 475ac1bb9c20095315bdf6c913470db83344894a Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 28 Sep 2013 18:06:45 +0200 Subject: [PATCH] Only use filename for identification when possible. fix #2233 & #954 --- couchpotato/core/plugins/scanner/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index 0662d00..9990bda 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -1,7 +1,8 @@ from couchpotato import get_session from couchpotato.core.event import fireEvent, addEvent from couchpotato.core.helpers.encoding import toUnicode, simplifyString, ss -from couchpotato.core.helpers.variable import getExt, getImdb, tryInt +from couchpotato.core.helpers.variable import getExt, getImdb, tryInt, \ + splitString from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import File, Movie @@ -741,9 +742,14 @@ class Scanner(Plugin): def createStringIdentifier(self, file_path, folder = '', exclude_filename = False): - identifier = file_path.replace(folder, '') # root folder + year = self.findYear(file_path) + + identifier = file_path.replace(folder, '').lstrip(os.path.sep) # root folder identifier = os.path.splitext(identifier)[0] # ext + path_split = splitString(identifier, os.path.sep) + identifier = path_split[-2] if len(path_split) > 1 and len(path_split[-2]) > len(path_split[-1]) else path_split[-1] # Only get filename + if exclude_filename: identifier = identifier[:len(identifier) - len(os.path.split(identifier)[-1])] @@ -757,7 +763,6 @@ class Scanner(Plugin): identifier = re.sub(self.clean, '::', simplifyString(identifier)).strip(':') # Year - year = self.findYear(identifier) if year and identifier[:4] != year: identifier = '%s %s' % (identifier.split(year)[0].strip(), year) else: