From d616ca229875325316109ff8a8b4a642bbc760ab Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 19 May 2014 12:20:33 -0700 Subject: [PATCH] This fixes all failed download issues --- sickbeard/processTV.py | 7 +++++- sickbeard/search_queue.py | 53 +++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index faed86a0..975d2965 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -393,6 +393,8 @@ def delete_dir(processPath): def get_path_dir_files(dirName, nzbName, type): + path, dirs, files = None + if dirName == sickbeard.TV_DOWNLOAD_DIR and not nzbName or type == "manual": #Scheduled Post Processing Active #Get at first all the subdir in the dirName for path, dirs, files in ek.ek(os.walk, dirName): @@ -416,6 +418,8 @@ def process_failed(dirName, nzbName): global returnStr if sickbeard.USE_FAILED_DOWNLOADS: + processor = None + try: processor = failedProcessor.FailedProcessor(dirName, nzbName) process_result = processor.process() @@ -424,7 +428,8 @@ def process_failed(dirName, nzbName): process_result = False process_fail_message = ex(e) - returnStr += processor.log + if processor: + returnStr += processor.log if sickbeard.DELETE_FAILED and process_result: delete_dir(dirName) diff --git a/sickbeard/search_queue.py b/sickbeard/search_queue.py index 0b8e65fd..398e0ec0 100644 --- a/sickbeard/search_queue.py +++ b/sickbeard/search_queue.py @@ -212,37 +212,36 @@ class FailedQueueItem(generic_queue.QueueItem): def execute(self): generic_queue.QueueItem.execute(self) - for season in self.segment: - epObj = self.segment[season] + for season, episodes in self.segment.items(): + for epObj in episodes: + (release, provider) = failed_history.findRelease(epObj) + if release: + logger.log(u"Marking release as bad: " + release) + failed_history.markFailed(epObj) + failed_history.logFailed(release) + history.logFailed(epObj, release, provider) + failed_history.revertEpisode(epObj) - (release, provider) = failed_history.findRelease(epObj) - if release: - logger.log(u"Marking release as bad: " + release) - failed_history.markFailed(epObj) - failed_history.logFailed(release) - history.logFailed(epObj, release, provider) - failed_history.revertEpisode(epObj) + logger.log( + "Beginning failed download search for [" + epObj.prettyName() + "]") + try: + searchResult = search.searchProviders(self.show, season, [epObj], True) - logger.log( - "Beginning failed download search for [" + epObj.prettyName() + "]") - try: - searchResult = search.searchProviders(self.show, season, [epObj], True) + # reset thread back to original name + threading.currentThread().name = self.thread_name - # reset thread back to original name - threading.currentThread().name = self.thread_name + if searchResult: + for result in searchResult: + # just use the first result for now + logger.log(u"Downloading " + result.name + " from " + result.provider.name) + search.snatchEpisode(result) - if searchResult: - for result in searchResult: - # just use the first result for now - logger.log(u"Downloading " + result.name + " from " + result.provider.name) - search.snatchEpisode(result) + # give the CPU a break + time.sleep(2) - # give the CPU a break - time.sleep(2) - - else: - logger.log(u"No episodes found to retry for failed downloads return from providers!") - except Exception, e: - logger.log(traceback.format_exc(), logger.DEBUG) + else: + logger.log(u"No valid episode found to retry for [" + epObj.prettyName() + "]") + except Exception, e: + logger.log(traceback.format_exc(), logger.DEBUG) self.finish() \ No newline at end of file