Private GIT

Skip to content
Snippets Groups Projects
Commit caa360d4 authored by Luca's avatar Luca
Browse files

PostProcessing Mod: Do not PostProcess files and dir again if we use KEEP_PROCESSING_DIR

parent 4b059e35
Branches
Tags
No related merge requests found
...@@ -90,6 +90,14 @@ def processDir (dirName, nzbName=None, recurse=False): ...@@ -90,6 +90,14 @@ def processDir (dirName, nzbName=None, recurse=False):
#Process Video File in the current Path #Process Video File in the current Path
for cur_video_file in videoFiles: 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) cur_video_file_path = ek.ek(os.path.join, dirName, cur_video_file)
try: try:
...@@ -196,13 +204,21 @@ def validateDir(path, dirName, returnStr): ...@@ -196,13 +204,21 @@ def validateDir(path, dirName, returnStr):
sqlResults = myDB.select("SELECT * FROM tv_shows") sqlResults = myDB.select("SELECT * FROM tv_shows")
for sqlShow in sqlResults: 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(): 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 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)) files = ek.ek(os.listdir, os.path.join(path, dirName))
videoFiles = filter(helpers.isMediaFile, files) 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: for video in videoFiles:
try: try:
NameParser().parse(video) NameParser().parse(video)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment