Browse Source

Add samplefiles to leftover files

pull/84/head
Ruud 13 years ago
parent
commit
8842bf2bbb
  1. 20
      couchpotato/core/plugins/scanner/main.py

20
couchpotato/core/plugins/scanner/main.py

@ -151,7 +151,10 @@ class Scanner(Plugin):
for file_path in files: for file_path in files:
# Remove ignored 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 continue
is_dvd_file = self.isDVDFile(file_path) is_dvd_file = self.isDVDFile(file_path)
@ -442,10 +445,13 @@ class Scanner(Plugin):
pass pass
return name return name
def getSamples(self, files):
return set(filter(lambda s: self.isSampleFile(s), files))
def getMediaFiles(self, files): def getMediaFiles(self, files):
def test(s): 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)) return set(filter(test, files))
@ -488,13 +494,13 @@ class Scanner(Plugin):
return images 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 return True
for needle in ['vts_', 'video_ts', 'audio_ts', 'bdmv', 'certificate']: for needle in ['vts_', 'video_ts', 'audio_ts', 'bdmv', 'certificate']:
if needle in file.lower(): if needle in file_name.lower():
return True return True
return False return False
@ -508,7 +514,7 @@ class Scanner(Plugin):
return False return False
# Sample file # Sample file
if re.search('(^|[\W_])sample\d*[\W_]', filename.lower()): if self.isSampleFile(filename):
log.debug('Is sample file "%s".' % filename) log.debug('Is sample file "%s".' % filename)
return False return False
@ -520,6 +526,8 @@ class Scanner(Plugin):
# All is OK # All is OK
return True return True
def isSampleFile(self, filename):
return re.search('(^|[\W_])sample\d*[\W_]', filename.lower())
def filesizeBetween(self, file, min = 0, max = 100000): def filesizeBetween(self, file, min = 0, max = 100000):
try: try:

Loading…
Cancel
Save