Fix for when no best match is found.

This commit is contained in:
echel0n 2014-05-13 10:11:19 -07:00
parent f78ed64878
commit 5f8037530a

View file

@ -220,6 +220,7 @@ def pickBestResult(results, show, quality_list=None):
if not bestResult or bestResult.quality < cur_result.quality and cur_result.quality != Quality.UNKNOWN: if not bestResult or bestResult.quality < cur_result.quality and cur_result.quality != Quality.UNKNOWN:
bestResult = cur_result bestResult = cur_result
elif bestResult.quality == cur_result.quality: elif bestResult.quality == cur_result.quality:
if "proper" in cur_result.name.lower() or "repack" in cur_result.name.lower(): if "proper" in cur_result.name.lower() or "repack" in cur_result.name.lower():
bestResult = cur_result bestResult = cur_result
@ -514,23 +515,27 @@ def searchProviders(queueItem, show, season, episodes, seasonSearch=False, manua
if len(foundResults[provider.name][curEp]) == 0: if len(foundResults[provider.name][curEp]) == 0:
continue continue
result = pickBestResult(foundResults[provider.name][curEp], show) bestResult = pickBestResult(foundResults[provider.name][curEp], show)
if result:
finalResults.append(result)
logger.log(u"Checking if we should snatch " + result.name, logger.DEBUG) # if all results were rejected move on to the next episode
if not bestResult:
continue
finalResults.append(bestResult)
logger.log(u"Checking if we should snatch " + bestResult.name, logger.DEBUG)
any_qualities, best_qualities = Quality.splitQuality(show.quality) 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 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): if best_qualities and bestResult.quality == max(best_qualities):
logger.log(u"Found a highest quality archive match to snatch [" + result.name + "]", logger.DEBUG) logger.log(u"Found a highest quality archive match to snatch [" + bestResult.name + "]", logger.DEBUG)
queueItem.results = [result] queueItem.results = [bestResult]
return queueItem return queueItem
# if there's no redownload that's higher (above) and this is the highest initial download then we're good # 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: elif any_qualities and bestResult.quality in any_qualities:
logger.log(u"Found a initial quality match to snatch [" + result.name + "]", logger.DEBUG) logger.log(u"Found a initial quality match to snatch [" + bestResult.name + "]", logger.DEBUG)
queueItem.results = [result] queueItem.results = [bestResult]
return queueItem return queueItem
# remove duplicates and insures snatch of highest quality from results # remove duplicates and insures snatch of highest quality from results