From 8842bf2bbb495aeac684b433e8d4dd869e5529e3 Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 3 Feb 2012 21:40:40 +0100 Subject: [PATCH] Add samplefiles to leftover files --- couchpotato/core/plugins/scanner/main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index a1a0243..5b77dbb 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -151,7 +151,10 @@ class Scanner(Plugin): for file_path in files: # Remove ignored files - if not self.keepFile(file_path): + if self.isSampleFile(file_path): + leftovers.append(file_path) + continue + elif not self.keepFile(file_path): continue is_dvd_file = self.isDVDFile(file_path) @@ -442,10 +445,13 @@ class Scanner(Plugin): pass return name + def getSamples(self, files): + return set(filter(lambda s: self.isSampleFile(s), files)) + def getMediaFiles(self, files): def test(s): - return self.filesizeBetween(s, 300, 100000) and getExt(s.lower()) in self.extensions['movie'] + return self.filesizeBetween(s, 300, 100000) and getExt(s.lower()) in self.extensions['movie'] and not self.isSampleFile(s) return set(filter(test, files)) @@ -488,13 +494,13 @@ class Scanner(Plugin): return images - def isDVDFile(self, file): + def isDVDFile(self, file_name): - if list(set(file.lower().split(os.path.sep)) & set(['video_ts', 'audio_ts'])): + if list(set(file_name.lower().split(os.path.sep)) & set(['video_ts', 'audio_ts'])): return True for needle in ['vts_', 'video_ts', 'audio_ts', 'bdmv', 'certificate']: - if needle in file.lower(): + if needle in file_name.lower(): return True return False @@ -508,7 +514,7 @@ class Scanner(Plugin): return False # Sample file - if re.search('(^|[\W_])sample\d*[\W_]', filename.lower()): + if self.isSampleFile(filename): log.debug('Is sample file "%s".' % filename) return False @@ -520,6 +526,8 @@ class Scanner(Plugin): # All is OK return True + def isSampleFile(self, filename): + return re.search('(^|[\W_])sample\d*[\W_]', filename.lower()) def filesizeBetween(self, file, min = 0, max = 100000): try: