diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 7c4b637f..0ff7ed03 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -334,11 +334,19 @@ class GenericProvider: addCacheEntry = False if not (showObj.air_by_date or showObj.sports): - if search_mode == 'sponly' and len(parse_result.episode_numbers): - logger.log( - u"This is supposed to be a season pack search but the result " + title + " is not a valid season pack, skipping it", - logger.DEBUG) - addCacheEntry = True + if search_mode == 'sponly': + if len(parse_result.episode_numbers): + logger.log( + u"This is supposed to be a season pack search but the result " + title + " is not a valid season pack, skipping it", + logger.DEBUG) + addCacheEntry = True + if len(parse_result.episode_numbers) and ( + parse_result.season_number not in set([ep.season for ep in episodes]) or not [ep for ep in episodes if + ep.scene_episode in parse_result.episode_numbers]): + logger.log( + u"The result " + title + " doesn't seem to be a valid episode that we are trying to snatch, ignoring", + logger.DEBUG) + addCacheEntry = True else: if not len(parse_result.episode_numbers) and parse_result.season_number and not [ep for ep in episodes if diff --git a/sickbeard/search.py b/sickbeard/search.py index 5fc3621b..9fd25039 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -533,7 +533,8 @@ def searchProviders(show, episodes, manualSearch=False): # see if every episode is wanted if bestSeasonResult: - + searchedSeasons = [] + searchedSeasons = [str(x.season) for x in episodes] # get the quality of the season nzb seasonQual = bestSeasonResult.quality logger.log( @@ -541,18 +542,21 @@ def searchProviders(show, episodes, manualSearch=False): seasonQual], logger.DEBUG) myDB = db.DBConnection() - allEps = [int(x["episode"]) for x in - myDB.select("SELECT episode FROM tv_episodes WHERE showid = ? AND season = ?", - [show.indexerid, season])] + allEps = [int(x["episode"]) + for x in myDB.select("SELECT episode FROM tv_episodes WHERE showid = ? AND ( season IN ( " + ','.join(searchedSeasons) + " ) )", + [show.indexerid])] + + logger.log(u"Executed query: [SELECT episode FROM tv_episodes WHERE showid = %s AND season in %s]" % (show.indexerid, ','.join(searchedSeasons))) logger.log(u"Episode list: " + str(allEps), logger.DEBUG) allWanted = True anyWanted = False for curEpNum in allEps: - if not show.wantEpisode(season, curEpNum, seasonQual): - allWanted = False - else: - anyWanted = True + for season in set([x.season for x in episodes]): + if not show.wantEpisode(season, curEpNum, seasonQual): + allWanted = False + else: + anyWanted = True # if we need every ep in the season and there's nothing better then just download this and be done with it (unless single episodes are preferred) if allWanted and bestSeasonResult.quality == highest_quality_overall: