From a6d30ac4258fcf051066e962fa4da2847df45789 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 15 May 2014 21:55:56 -0700 Subject: [PATCH] Fixed potential backlog issues. Fixed potential failed download item issues. Added in more detailed logging for backlogs. --- sickbeard/failedProcessor.py | 6 +++--- sickbeard/searchBacklog.py | 5 +++++ sickbeard/search_queue.py | 3 +++ sickbeard/webserve.py | 35 ++++++++++++++++++----------------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/sickbeard/failedProcessor.py b/sickbeard/failedProcessor.py index 5e72869b..266f4252 100644 --- a/sickbeard/failedProcessor.py +++ b/sickbeard/failedProcessor.py @@ -75,12 +75,12 @@ class FailedProcessor(object): logger.WARNING) raise exceptions.FailedProcessingFailed() - episodes = [] + segment = {parsed.season_number:[]} for episode in parsed.episode_numbers: epObj = self._show_obj.getEpisode(parsed.season_number, episode) - episodes.append(epObj) + segment[parsed.season_number].append(epObj) - cur_failed_queue_item = search_queue.FailedQueueItem(self._show_obj, episodes) + cur_failed_queue_item = search_queue.FailedQueueItem(self._show_obj, segment) sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item) return True diff --git a/sickbeard/searchBacklog.py b/sickbeard/searchBacklog.py index fbbb1ebe..9f8fc4a1 100644 --- a/sickbeard/searchBacklog.py +++ b/sickbeard/searchBacklog.py @@ -101,6 +101,9 @@ class BacklogSearcher: if len(segments): backlog_queue_item = search_queue.BacklogQueueItem(curShow, segments) sickbeard.searchQueueScheduler.action.add_item(backlog_queue_item) #@UndefinedVariable + else: + logger.log(u"Nothing needs to be downloaded for " + str(curShow.name) + ", skipping this season", + logger.DEBUG) # don't consider this an actual backlog search if we only did recent eps # or if we only did certain shows @@ -132,6 +135,8 @@ class BacklogSearcher: def _get_segments(self, show, fromDate): anyQualities, bestQualities = common.Quality.splitQuality(show.quality) #@UnusedVariable + logger.log(u"Seeing if we need anything from " + show.name) + myDB = db.DBConnection() if show.air_by_date: sqlResults = myDB.select( diff --git a/sickbeard/search_queue.py b/sickbeard/search_queue.py index d3b65f25..c8b77aa4 100644 --- a/sickbeard/search_queue.py +++ b/sickbeard/search_queue.py @@ -27,6 +27,7 @@ from sickbeard import db, logger, common, exceptions, helpers from sickbeard import generic_queue, scheduler from sickbeard import search, failed_history, history from sickbeard import ui +from sickbeard import searchBacklog search_queue_lock = threading.Lock() @@ -127,6 +128,8 @@ class BacklogQueueItem(generic_queue.QueueItem): generic_queue.QueueItem.execute(self) for season in self.segment: + searchBacklog.BacklogSearcher.currentSearchInfo = {'title': self.show.name + " Season " + str(season)} + wantedEps = self.segment[season] # check if we want to search for season packs instead of just season/episode diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 68711cd9..21d3712d 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3227,8 +3227,7 @@ class Home: else: return _genericMessage("Error", errMsg) - segments = {} - + segment = {} if eps is not None: sql_l = [] @@ -3245,10 +3244,10 @@ class Home: if int(status) in [WANTED, FAILED]: # figure out what episodes are wanted so we can backlog them - if epObj in segments: - segments[epObj.season].append(epObj) + if epObj.season in segment: + segment[epObj.season].append(epObj) else: - segments[epObj.season] = [epObj] + segment[epObj.season] = [epObj] with epObj.lock: # don't let them mess up UNAIRED episodes @@ -3283,28 +3282,30 @@ class Home: if int(status) == WANTED: msg = "Backlog was automatically started for the following seasons of " + showObj.name + ":
" - for cur_segment in segments: - msg += "
  • Season " + str(cur_segment) + "
  • " + for season in segment: + msg += "
  • Season " + str(season) + "
  • " logger.log(u"Sending backlog for " + showObj.name + " season " + str( - cur_segment) + " because some eps were set to wanted") - cur_backlog_queue_item = search_queue.BacklogQueueItem(showObj, cur_segment) - sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) # @UndefinedVariable + season) + " because some eps were set to wanted") msg += "" - if segments: + cur_backlog_queue_item = search_queue.BacklogQueueItem(showObj, segment) + sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) # @UndefinedVariable + + if segment: ui.notifications.message("Backlog started", msg) if int(status) == FAILED: msg = "Retrying Search was automatically started for the following season of " + showObj.name + ":
    " - for cur_segment in segments: - msg += "
  • Season " + str(cur_segment) + "
  • " + for season in segment: + msg += "
  • Season " + str(season) + "
  • " logger.log(u"Retrying Search for " + showObj.name + " season " + str( - cur_segment) + " because some eps were set to failed") - cur_failed_queue_item = search_queue.FailedQueueItem(showObj, cur_segment) - sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item) # @UndefinedVariable + season) + " because some eps were set to failed") msg += "" - if segments: + cur_failed_queue_item = search_queue.FailedQueueItem(showObj, segment) + sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item) # @UndefinedVariable + + if segment: ui.notifications.message("Retry Search started", msg) if direct: