From caa360d4c0c8b73510e0a9e39bdc965f97c790c6 Mon Sep 17 00:00:00 2001 From: Luca <l.dimarino@gmail.com> Date: Mon, 20 May 2013 12:58:23 +0200 Subject: [PATCH] PostProcessing Mod: Do not PostProcess files and dir again if we use KEEP_PROCESSING_DIR --- sickbeard/processTV.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index 99a84df1a..a2c99f08f 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -90,6 +90,14 @@ def processDir (dirName, nzbName=None, recurse=False): #Process Video File in the current Path for cur_video_file in videoFiles: + # Avoid processing the same file again if we use KEEP_PROCESSING_DIR + if sickbeard.KEEP_PROCESSED_DIR: + myDB = db.DBConnection() + sqlresult = myDB.select("SELECT * FROM tv_episodes WHERE release_name = ?", [cur_video_file.rpartition('.')[0]]) + if sqlresult: + returnStr += logHelper(u"You're trying to post process the file " + cur_video_file + " that's already been processed, skipping", logger.DEBUG) + continue + cur_video_file_path = ek.ek(os.path.join, dirName, cur_video_file) try: @@ -103,7 +111,7 @@ def processDir (dirName, nzbName=None, recurse=False): returnStr += processor.log if process_result: - returnStr += logHelper(u"Processing succeeded for "+cur_video_file_path) + returnStr += logHelper(u"Processing succeeded for "+cur_video_file_path) else: returnStr += logHelper(u"Processing failed for "+cur_video_file_path+": "+process_fail_message, logger.WARNING) @@ -196,13 +204,21 @@ def validateDir(path, dirName, returnStr): sqlResults = myDB.select("SELECT * FROM tv_shows") for sqlShow in sqlResults: if dirName.lower().startswith(ek.ek(os.path.realpath, sqlShow["location"]).lower()+os.sep) or dirName.lower() == ek.ek(os.path.realpath, sqlShow["location"]).lower(): - returnStr += logHelper(u"You're trying to post process an episode that's already been moved to its show dir", logger.ERROR) + returnStr += logHelper(u"You're trying to post process an episode that's already been moved to its show dir, skipping", logger.ERROR) return False - #check if the dir have at least one tv video file + # Get the videofile list for the next checks files = ek.ek(os.listdir, os.path.join(path, dirName)) videoFiles = filter(helpers.isMediaFile, files) - + + # Avoid processing the same dir again if we use KEEP_PROCESSING_DIR + if sickbeard.KEEP_PROCESSED_DIR: + numPostProcFiles = myDB.select("SELECT COUNT(release_name) as numfiles FROM tv_episodes WHERE release_name = ?", [dirName]) + if int(numPostProcFiles[0][0]) == len(videoFiles): + returnStr += logHelper(u"You're trying to post process a dir that's already been processed, skipping", logger.DEBUG) + return False + + #check if the dir have at least one tv video file for video in videoFiles: try: NameParser().parse(video) -- GitLab