From 356d52c8dde6c296c54dcbf99c663944f5ec35a1 Mon Sep 17 00:00:00 2001
From: Luca <l.dimarino@gmail.com>
Date: Fri, 17 May 2013 11:53:50 +0200
Subject: [PATCH] PostProcessor Fixes

---
 sickbeard/postProcessor.py |  8 ++++----
 sickbeard/processTV.py     | 20 +++++++++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py
index c7e3a1597..2a01cc9c5 100644
--- a/sickbeard/postProcessor.py
+++ b/sickbeard/postProcessor.py
@@ -153,10 +153,10 @@ class PostProcessor(object):
         if not file_path:
             return []
 
-        if file_path != self.file_path:
-            associated_dir = os.path.dirname(file_path)
-            associated_fname = os.path.basename(self.file_path) 
-            file_path = os.path.join(associated_dir, associated_fname)
+#        if file_path != self.file_path:
+#            associated_dir = os.path.dirname(file_path)
+#            associated_fname = os.path.basename(self.file_path) 
+#            file_path = os.path.join(associated_dir, associated_fname)
 
         file_path_list = []
     
diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py
index 30218db44..99a84df1a 100644
--- a/sickbeard/processTV.py
+++ b/sickbeard/processTV.py
@@ -76,7 +76,6 @@ def processDir (dirName, nzbName=None, recurse=False):
             files = ek.ek(os.listdir, dirName)
             dirs = [dirs]
 
-    process_result = False
     videoFiles = filter(helpers.isMediaFile, files)
 
     # If nzbName is set and there's more than one videofile in the folder, files will be lost (overwritten).
@@ -110,9 +109,9 @@ def processDir (dirName, nzbName=None, recurse=False):
 
     #Process Video File in all TV Subdir
     for dir in [x for x in dirs if validateDir(path, x, returnStr)]:
-
-#        process_result = False
-
+        
+        process_result = True
+        
         for processPath, processDir, fileList in ek.ek(os.walk, ek.ek(os.path.join, path, dir), topdown=False):
 
             videoFiles = filter(helpers.isMediaFile, fileList)
@@ -199,5 +198,16 @@ def validateDir(path, dirName, returnStr):
         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)
             return False
+
+    #check if the dir have at least one tv video file
+    files = ek.ek(os.listdir, os.path.join(path, dirName))
+    videoFiles = filter(helpers.isMediaFile, files)
+    
+    for video in videoFiles:
+        try:
+            NameParser().parse(video)
+            return True
+        except InvalidNameException:
+            pass
     
-    return True
+    return False
-- 
GitLab