fix is_sample and add exit to create_destination

This commit is contained in:
Clinton Hall 2013-03-01 09:55:10 -08:00
commit 5ec0fce884

View file

@ -122,7 +122,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
return inputDirectory, inputName, inputCategory, root return inputDirectory, inputName, inputCategory, root
def is_sample(filePath, inputName): def is_sample(filePath, inputName, minSampleSize):
# 200 MB in bytes # 200 MB in bytes
SIZE_CUTOFF = minSampleSize * 1024 * 1024 SIZE_CUTOFF = minSampleSize * 1024 * 1024
# Ignore 'sample' in files unless 'sample' in Torrent Name # Ignore 'sample' in files unless 'sample' in Torrent Name
@ -135,8 +135,8 @@ def create_destination(outputDestination):
Logger.info("CREATE DESTINATION: Creating destination folder: %s", outputDestination) Logger.info("CREATE DESTINATION: Creating destination folder: %s", outputDestination)
os.makedirs(outputDestination) os.makedirs(outputDestination)
except Exception, e: except Exception, e:
Logger.error("CREATE DESTINATION: Not possible to create destination folder: %s", e) Logger.error("CREATE DESTINATION: Not possible to create destination folder: %s. Exiting", e)
return False sys.exit(-1)
def copy_link(source, target, useLink, outputDestination): def copy_link(source, target, useLink, outputDestination):
@ -279,7 +279,7 @@ for dirpath, dirnames, filenames in os.walk(inputDirectory):
filePath = os.path.join(dirpath, file) filePath = os.path.join(dirpath, file)
fileExtention = os.path.splitext(file)[1] fileExtention = os.path.splitext(file)[1]
if fileExtention in mediaContainer: # If the file is a video file if fileExtention in mediaContainer: # If the file is a video file
if is_sample(filePath, inputName): # Ignore samples if is_sample(filePath, inputName, minSampleSize): # Ignore samples
Logger.info("MAIN: Ignoring sample file: %s ", filePath) Logger.info("MAIN: Ignoring sample file: %s ", filePath)
continue continue
else: else: