diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index df001f87..405927cc 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -254,9 +254,6 @@ class NameParser(object): # if the dirname has a release group/show name I believe it over the filename final_result.series_name = self._combine_results(dir_name_result, file_name_result, 'series_name') -# if final_result.sports: -# final_result.series_name = str(final_result.series_name).partition(" ")[0] - final_result.extra_info = self._combine_results(dir_name_result, file_name_result, 'extra_info') final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group') diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index f807da2d..ff989785 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -339,8 +339,7 @@ class GenericProvider: wantEp = True for epNo in actual_episodes: epObj = self.show.getEpisode(actual_season, epNo) - if not epObj or not self.show.wantEpisode(epObj.season, epObj.episode, quality, - manualSearch=manualSearch): + if not epObj or not self.show.wantEpisode(epObj.season, epObj.episode, quality,manualSearch=manualSearch): wantEp = False break diff --git a/sickbeard/search.py b/sickbeard/search.py index 14219c04..cb79c06b 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -348,9 +348,25 @@ def isFirstBestMatch(result): return False +def filterSearchResults(show, results): + foundResults = {} + + # make a list of all the results for this provider + for curEp in results: + # skip non-tv crap + results[curEp] = filter( + lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name, show), + results[curEp]) + + if curEp in foundResults: + foundResults[curEp] += results[curEp] + else: + foundResults[curEp] = results[curEp] + + return foundResults + def searchProviders(show, season, episode=None, manualSearch=False): logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season)) - curResults = {} foundResults = {} didSearch = False @@ -366,8 +382,6 @@ def searchProviders(show, season, episode=None, manualSearch=False): ep_obj = show.getEpisode(season, episode) wantedEps = [ep_obj] - - for curProvider in providers.sortedProviderList(): if not curProvider.isActive(): continue @@ -378,23 +392,21 @@ def searchProviders(show, season, episode=None, manualSearch=False): # search cache first for wanted episodes for ep_obj in wantedEps: - results = curProvider.cache.searchCache(ep_obj, manualSearch) - if results: - curResults.update(results) + curResults = curProvider.cache.searchCache(ep_obj, manualSearch) + foundResults = filterSearchResults(show, curResults) - # did we find our results ? - if len(curResults): - logger.log(u"Cache results: " + repr(curResults), logger.DEBUG) + if len(foundResults): + logger.log(u"Cache results: " + repr(foundResults), logger.DEBUG) didSearch = True break - if not len(curResults): + if not len(foundResults): for curProvider in providers.sortedProviderList(): if not curProvider.isActive(): continue try: - curResults.update(curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch)) + curResults = curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch) except exceptions.AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) continue @@ -403,18 +415,13 @@ def searchProviders(show, season, episode=None, manualSearch=False): logger.log(traceback.format_exc(), logger.DEBUG) continue + # finished searching this provider successfully didSearch = True - # make a list of all the results for this provider - for curEp in curResults: - # skip non-tv crap - curResults[curEp] = filter( - lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name,show),curResults[curEp]) - - if curEp in foundResults: - foundResults[curEp] += curResults[curEp] - else: - foundResults[curEp] = curResults[curEp] + foundResults = filterSearchResults(show, curResults) + if len(foundResults): + logger.log(u"Provider search results: " + str(foundResults), logger.DEBUG) + break if not didSearch: logger.log(u"No NZB/Torrent providers found or enabled in the sickbeard config. Please check your settings.", diff --git a/sickbeard/searchBacklog.py b/sickbeard/searchBacklog.py index e4725190..486aee1f 100644 --- a/sickbeard/searchBacklog.py +++ b/sickbeard/searchBacklog.py @@ -123,7 +123,7 @@ class BacklogSearcher: if curShow.air_by_date: segments = [x[1] for x in self._get_air_by_date_segments(curShow.indexerid, fromDate)] elif curShow.sports: - segments = [x[1] for x in self._get_sports_segments(curShow.indexerid, fromDate)] + segments = self._get_sports_segments(curShow.indexerid, fromDate) else: segments = self._get_season_segments(curShow.indexerid, fromDate) @@ -195,24 +195,11 @@ class BacklogSearcher: return air_by_date_segments def _get_sports_segments(self, indexer_id, fromDate): - # query the DB for all dates for this show myDB = db.DBConnection() - num_sports_results = myDB.select( - "SELECT airdate, showid FROM tv_episodes ep, tv_shows show WHERE season != 0 AND ep.showid = show.indexer_id AND show.paused = 0 ANd ep.airdate > ? AND ep.showid = ? AND show.sports = 1", - [fromDate.toordinal(), indexer_id]) - - # break them apart into month/year strings - sports_segments = [] - for cur_result in num_sports_results: - cur_date = datetime.date.fromordinal(int(cur_result["airdate"])) - cur_date_str = str(cur_date)[:7] - cur_indexer_id = int(cur_result["showid"]) - - cur_result_tuple = (cur_indexer_id, cur_date_str) - if cur_result_tuple not in sports_segments: - sports_segments.append(cur_result_tuple) - - return sports_segments + sqlResults = myDB.select( + "SELECT DISTINCT(season) as season FROM tv_episodes WHERE showid = ? AND season > 0 and airdate > ?", + [indexer_id, fromDate.toordinal()]) + return [int(x["season"]) for x in sqlResults] def _set_lastBacklog(self, when):