From a4c8c53c9141c2050caf230c12ec080faff9c0ca Mon Sep 17 00:00:00 2001 From: KontiSR Date: Wed, 17 Sep 2014 12:24:54 +0200 Subject: [PATCH 1/2] Fixed SearchFailedDownload when selecting multiple ep's as failed in displayShow Searched for other occurrences for the search_queue.FailedQueueItem() call. Changed segment to [segment] The failedDownloadQueueItem always expects a single epObj in the segment. But when checking multiple episodes as "Failed" in displayShow, an array is provided. I've changed the queueItem to always iterate over it as an array. And i've made sure that when retry a single episode, it's also send to the queueItem as an array (with a single element). I've had to adapt the queuing functionality in webserve for this. --- sickbeard/failedProcessor.py | 2 +- sickbeard/search_queue.py | 32 +++++++++++--------- sickbeard/webserve.py | 57 ++++++++++++++++++++++++------------ 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/sickbeard/failedProcessor.py b/sickbeard/failedProcessor.py index 586c5aed..b66f9be2 100644 --- a/sickbeard/failedProcessor.py +++ b/sickbeard/failedProcessor.py @@ -67,7 +67,7 @@ class FailedProcessor(object): for episode in parsed.episode_numbers: segment = parsed.show.getEpisode(parsed.season_number, episode) - cur_failed_queue_item = search_queue.FailedQueueItem(parsed.show, segment) + cur_failed_queue_item = search_queue.FailedQueueItem(parsed.show, [segment]) sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item) return True diff --git a/sickbeard/search_queue.py b/sickbeard/search_queue.py index 6d196258..34bdcf8e 100644 --- a/sickbeard/search_queue.py +++ b/sickbeard/search_queue.py @@ -245,21 +245,24 @@ class FailedQueueItem(generic_queue.QueueItem): def run(self): generic_queue.QueueItem.run(self) - + self.started = True + try: - logger.log(u"Marking episode as bad: [" + self.segment.prettyName() + "]") - self.started = True - failed_history.markFailed(self.segment) + for epObj in self.segment: + + logger.log(u"Marking episode as bad: [" + epObj.prettyName() + "]") + + failed_history.markFailed(epObj) + + (release, provider) = failed_history.findRelease(epObj) + if release: + failed_history.logFailed(release) + history.logFailed(epObj, release, provider) + + failed_history.revertEpisode(epObj) + logger.log("Beginning failed download search for: [" + epObj.prettyName() + "]") - (release, provider) = failed_history.findRelease(self.segment) - if release: - failed_history.logFailed(release) - history.logFailed(self.segment, release, provider) - - failed_history.revertEpisode(self.segment) - logger.log("Beginning failed download search for: [" + self.segment.prettyName() + "]") - - searchResult = search.searchProviders(self.show, [self.segment], True) + searchResult = search.searchProviders(self.show, self.segment, True) if searchResult: for result in searchResult: @@ -270,7 +273,8 @@ class FailedQueueItem(generic_queue.QueueItem): # give the CPU a break time.sleep(common.cpu_presets[sickbeard.CPU_PRESET]) else: - logger.log(u"No valid episode found to retry for: [" + self.segment.prettyName() + "]") + pass + #logger.log(u"No valid episode found to retry for: [" + self.segment.prettyName() + "]") except Exception: logger.log(traceback.format_exc(), logger.DEBUG) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 11e08e89..f5189539 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -4204,7 +4204,7 @@ class Home(MainHandler): msg = "Retrying Search was automatically started for the following season of " + showObj.name + ":
" for season, segment in segments.items(): - cur_failed_queue_item = search_queue.FailedQueueItem(showObj, segment) + cur_failed_queue_item = search_queue.FailedQueueItem(showObj, [segment]) sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item) # @UndefinedVariable msg += "
  • Season " + str(season) + "
  • " @@ -4358,20 +4358,28 @@ class Home(MainHandler): if currentManualSearchThreadsQueued: for searchThread in currentManualSearchThreadsQueued: searchstatus = 'queued' - - episodes.append({'episode': searchThread.segment.episode, - 'episodeindexid': searchThread.segment.indexerid, - 'season' : searchThread.segment.season, - 'searchstatus' : searchstatus, - 'status' : statusStrings[searchThread.segment.status], - 'quality': self.getQualityClass(searchThread.segment)}) + if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): + episodes.append({'episode': searchThread.segment.episode, + 'episodeindexid': searchThread.segment.indexerid, + 'season' : searchThread.segment.season, + 'searchstatus' : searchstatus, + 'status' : statusStrings[searchThread.segment.status], + 'quality': self.getQualityClass(searchThread.segment)}) + else: + for epObj in searchThread.segment: + episodes.append({'episode': epObj.episode, + 'episodeindexid': epObj.indexerid, + 'season' : epObj.season, + 'searchstatus' : searchstatus, + 'status' : statusStrings[epObj.status], + 'quality': self.getQualityClass(epObj)}) if currentManualSearchThreadActive: searchThread = currentManualSearchThreadActive searchstatus = 'searching' if searchThread.success: searchstatus = 'finished' - episodes.append({'episode': searchThread.segment.episode, + episodes.append({'episode': searchThread.segment.episode, 'episodeindexid': searchThread.segment.indexerid, 'season' : searchThread.segment.season, 'searchstatus' : searchstatus, @@ -4380,14 +4388,27 @@ class Home(MainHandler): if finishedManualSearchThreadItems: for searchThread in finishedManualSearchThreadItems: - if str(searchThread.show.indexerid) == show and not [x for x in episodes if x['episodeindexid'] == searchThread.segment.indexerid]: - searchstatus = 'finished' - episodes.append({'episode': searchThread.segment.episode, - 'episodeindexid': searchThread.segment.indexerid, - 'season' : searchThread.segment.season, - 'searchstatus' : searchstatus, - 'status' : statusStrings[searchThread.segment.status], - 'quality': self.getQualityClass(searchThread.segment)}) + if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): + if str(searchThread.show.indexerid) == show and not [x for x in episodes if x['episodeindexid'] == searchThread.segment.indexerid]: + searchstatus = 'finished' + episodes.append({'episode': searchThread.segment.episode, + 'episodeindexid': searchThread.segment.indexerid, + 'season' : searchThread.segment.season, + 'searchstatus' : searchstatus, + 'status' : statusStrings[searchThread.segment.status], + 'quality': self.getQualityClass(searchThread.segment)}) + else: + ### These are only Failed Downloads/Retry SearchThreadItems.. lets loop through the segement/episodes + if str(searchThread.show.indexerid) == show: + for epObj in searchThread.segment: + if not [x for x in episodes if x['episodeindexid'] == epObj.indexerid]: + searchstatus = 'finished' + episodes.append({'episode': epObj.episode, + 'episodeindexid': epObj.indexerid, + 'season' : epObj.season, + 'searchstatus' : searchstatus, + 'status' : statusStrings[epObj.status], + 'quality': self.getQualityClass(epObj)}) return json.dumps({'show': show, 'episodes' : episodes}) @@ -4514,7 +4535,7 @@ class Home(MainHandler): return json.dumps({'result': 'failure'}) # make a queue item for it and put it on the queue - ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, ep_obj) + ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, [ep_obj]) sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable if ep_queue_item.success: From c54e70e99b741d62cc36df1a9ec0e249a2fe983d Mon Sep 17 00:00:00 2001 From: KontiSR Date: Fri, 19 Sep 2014 13:56:49 +0200 Subject: [PATCH 2/2] Fixed displaying of currently running searches --- sickbeard/webserve.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index f5189539..3ae7792f 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -4379,13 +4379,15 @@ class Home(MainHandler): searchstatus = 'searching' if searchThread.success: searchstatus = 'finished' - episodes.append({'episode': searchThread.segment.episode, + else: + searchstatus = 'searching' + episodes.append({'episode': searchThread.segment.episode, 'episodeindexid': searchThread.segment.indexerid, - 'season' : searchThread.segment.season, - 'searchstatus' : searchstatus, - 'status' : statusStrings[searchThread.segment.status], - 'quality': self.getQualityClass(searchThread.segment)}) - + 'season' : searchThread.segment.season, + 'searchstatus' : searchstatus, + 'status' : statusStrings[searchThread.segment.status], + 'quality': self.getQualityClass(searchThread.segment)}) + if finishedManualSearchThreadItems: for searchThread in finishedManualSearchThreadItems: if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):