From f78ed64878761640be4fef8c3e564cd827cc41ea Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 13 May 2014 09:30:25 -0700 Subject: [PATCH] Fix for failed downloads and improper storing of release name in db --- sickbeard/failed_history.py | 7 ++----- sickbeard/search.py | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/sickbeard/failed_history.py b/sickbeard/failed_history.py index 13923b4f..09ea1dc5 100644 --- a/sickbeard/failed_history.py +++ b/sickbeard/failed_history.py @@ -104,6 +104,8 @@ def hasFailed(release, size, provider="%"): is found with any provider. """ + release = prepareFailedName(release) + myDB = db.DBConnection("failed.db") sql_results = myDB.select( "SELECT * FROM failed WHERE release=? AND size=? AND provider LIKE ?", @@ -136,9 +138,6 @@ def revertEpisode(epObj): except EpisodeNotFoundException, e: logger.log(u"Unable to create episode, please set its status manually: " + ex(e), logger.WARNING) - - return - def markFailed(epObj): log_str = u"" @@ -161,7 +160,6 @@ def logSnatch(searchResult): logDate = datetime.datetime.today().strftime(dateFormat) release = prepareFailedName(searchResult.name) - providerClass = searchResult.provider if providerClass is not None: provider = providerClass.name @@ -192,7 +190,6 @@ def trimHistory(): myDB.action("DELETE FROM history WHERE date < " + str( (datetime.datetime.today() - datetime.timedelta(days=30)).strftime(dateFormat))) - def findRelease(epObj): """ Find releases in history by show ID and season. diff --git a/sickbeard/search.py b/sickbeard/search.py index 38ea6403..da9162ba 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -515,22 +515,23 @@ def searchProviders(queueItem, show, season, episodes, seasonSearch=False, manua continue result = pickBestResult(foundResults[provider.name][curEp], show) - finalResults.append(result) + if result: + finalResults.append(result) - logger.log(u"Checking if we should snatch " + result.name, logger.DEBUG) - any_qualities, best_qualities = Quality.splitQuality(show.quality) + logger.log(u"Checking if we should snatch " + result.name, logger.DEBUG) + any_qualities, best_qualities = Quality.splitQuality(show.quality) - # if there is a redownload that's higher than this then we definitely need to keep looking - if best_qualities and result.quality == max(best_qualities): - logger.log(u"Found a highest quality archive match to snatch [" + result.name + "]", logger.DEBUG) - queueItem.results = [result] - return queueItem + # if there is a redownload that's higher than this then we definitely need to keep looking + if best_qualities and result.quality == max(best_qualities): + logger.log(u"Found a highest quality archive match to snatch [" + result.name + "]", logger.DEBUG) + queueItem.results = [result] + return queueItem - # if there's no redownload that's higher (above) and this is the highest initial download then we're good - elif any_qualities and result.quality in any_qualities: - logger.log(u"Found a initial quality match to snatch [" + result.name + "]", logger.DEBUG) - queueItem.results = [result] - return queueItem + # if there's no redownload that's higher (above) and this is the highest initial download then we're good + elif any_qualities and result.quality in any_qualities: + logger.log(u"Found a initial quality match to snatch [" + result.name + "]", logger.DEBUG) + queueItem.results = [result] + return queueItem # remove duplicates and insures snatch of highest quality from results for i1, result1 in enumerate(finalResults):