From b349bab56993a4ac94330d3406fcd5f5f3d7e904 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 3 May 2014 22:36:54 -0700 Subject: [PATCH] Fixes more issues that were still present for season pack searches and air-by-date shows. --- sickbeard/providers/btn.py | 32 ++++++++++++++--------------- sickbeard/providers/ezrss.py | 2 +- sickbeard/providers/generic.py | 8 +++++++- sickbeard/providers/hdtorrents.py | 2 +- sickbeard/providers/iptorrents.py | 2 +- sickbeard/providers/kat.py | 2 +- sickbeard/providers/newznab.py | 2 +- sickbeard/providers/nextgen.py | 2 +- sickbeard/providers/publichd.py | 2 +- sickbeard/providers/scc.py | 2 +- sickbeard/providers/speedcd.py | 3 +-- sickbeard/providers/thepiratebay.py | 2 +- sickbeard/providers/torrentday.py | 2 +- sickbeard/providers/torrentleech.py | 2 +- sickbeard/search.py | 4 ++-- sickbeard/search_queue.py | 8 +++++++- sickbeard/webserve.py | 2 +- 17 files changed, 44 insertions(+), 35 deletions(-) diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index c376486f..184b4b02 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -194,30 +194,28 @@ class BTNProvider(generic.TorrentProvider): search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] - for name in name_exceptions: + if not (ep_obj.show.air_by_date or ep_obj.show.sports): + for name in name_exceptions: - current_params = {} + current_params = {} - if self.show.indexer == 1: - current_params['tvdb'] = self.show.indexerid - elif self.show.indexer == 2: - current_params['tvrage'] = self.show.indexerid - else: - # Search by name if we don't have tvdb or tvrage id - current_params['series'] = sanitizeSceneName(name) + if self.show.indexer == 1: + current_params['tvdb'] = self.show.indexerid + elif self.show.indexer == 2: + current_params['tvrage'] = self.show.indexerid + else: + # Search by name if we don't have tvdb or tvrage id + current_params['series'] = sanitizeSceneName(name) - # Search for entire seasons: no need to do special things for air by date shows - if not (ep_obj.show.air_by_date or ep_obj.show.sports): + # Search for entire seasons: no need to do special things for air by date shows whole_season_params = current_params.copy() whole_season_params['category'] = 'Season' - whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) + if not (ep_obj.show.air_by_date or ep_obj.show.sports): + whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) + elif ep_obj.show.air_by_date or ep_obj.show.sports: + whole_season_params['name'] = self._get_episode_search_strings(ep_obj)[0]['name'] search_params.append(whole_season_params) - # Search for episodes in the season - current_params = {} - current_params['name'] = self._get_episode_search_strings(ep_obj)[0]['name'] - search_params.append(current_params) - return search_params def _get_episode_search_strings(self, ep_obj, add_string=''): diff --git a/sickbeard/providers/ezrss.py b/sickbeard/providers/ezrss.py index f8d3cd62..6170b088 100644 --- a/sickbeard/providers/ezrss.py +++ b/sickbeard/providers/ezrss.py @@ -83,7 +83,7 @@ class EZRSSProvider(generic.TorrentProvider): else: params['season'] = self._get_episode_search_strings(ep_obj)[0]['season'] - params['episode'] = self._get_episode_search_strings(ep_obj)[0]['episode'] + #params['episode'] = self._get_episode_search_strings(ep_obj)[0]['episode'] return [params] diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 8056e0dd..1b890fce 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -247,7 +247,7 @@ class GenericProvider: return (title, url) - def findSearchResults(self, show, season, episodes, manualSearch=False): + def findSearchResults(self, show, season, episodes, seasonSearch=False, manualSearch=False): self._checkAuth() self.show = show @@ -268,6 +268,12 @@ class GenericProvider: else: logger.log(u'Searching "%s" for "%s" as "%s"' % (self.name, epObj.prettyName(), epObj.prettySceneName())) + # get our season pack search results + if seasonSearch: + for curString in self._get_episode_search_strings(epObj): + itemList += self._doSearch(curString) + + # get our season/episode search results for curString in self._get_episode_search_strings(epObj): itemList += self._doSearch(curString) diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index 06955e3f..0439f512 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -121,7 +121,7 @@ class HDTorrentsProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 5f8f7f6d..1a508dd4 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -103,7 +103,7 @@ class IPTorrentsProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 23227a0e..8fab3768 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -178,7 +178,7 @@ class KATProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index 239e9c9b..c4553f25 100644 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -103,7 +103,7 @@ class NewznabProvider(generic.NZBProvider): if ep_obj.show.air_by_date or ep_obj.show.sports: cur_params['season'] = self._get_episode_search_strings(ep_obj)[0]['season'] - cur_params['episode'] = self._get_episode_search_strings(ep_obj)[0]['ep'] + #cur_params['episode'] = self._get_episode_search_strings(ep_obj)[0]['ep'] to_return.append(cur_params) diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index 82c161be..98457307 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -142,7 +142,7 @@ class NextGenProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/publichd.py b/sickbeard/providers/publichd.py index 81d69980..b7dfce33 100644 --- a/sickbeard/providers/publichd.py +++ b/sickbeard/providers/publichd.py @@ -85,7 +85,7 @@ class PublicHDProvider(generic.TorrentProvider): else: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index 44bbfe06..b290c72d 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -109,7 +109,7 @@ class SCCProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index 5e6b00b5..5a505c49 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -101,8 +101,7 @@ class SpeedCDProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - #Building the search string with the episodes we need - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 0660fea0..555553c3 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -182,7 +182,7 @@ class ThePirateBayProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 46c4cbec..76fa17cc 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -122,7 +122,7 @@ class TorrentDayProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index 8948942a..79fce736 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -104,7 +104,7 @@ class TorrentLeechProvider(generic.TorrentProvider): elif ep_obj.show.air_by_date or ep_obj.show.sports: search_string['Season'] = self._get_episode_search_strings(ep_obj)[0]['Season'] - search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] + #search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode'] return [search_string] diff --git a/sickbeard/search.py b/sickbeard/search.py index 3e931e41..0105bd5c 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -363,7 +363,7 @@ def filterSearchResults(show, results): return foundResults -def searchProviders(show, season, episodes, manualSearch=False): +def searchProviders(show, season, episodes, seasonSearch=False, manualSearch=False): logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season)) foundResults = {} @@ -374,7 +374,7 @@ def searchProviders(show, season, episodes, manualSearch=False): continue try: - curResults = curProvider.findSearchResults(show, season, episodes, manualSearch) + curResults = curProvider.findSearchResults(show, season, episodes, seasonSearch, manualSearch) except exceptions.AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) continue diff --git a/sickbeard/search_queue.py b/sickbeard/search_queue.py index 534dbc46..8bd3afe7 100644 --- a/sickbeard/search_queue.py +++ b/sickbeard/search_queue.py @@ -186,6 +186,7 @@ class BacklogQueueItem(generic_queue.QueueItem): self.show = show self.segment = segment self.wantedEpisodes = [] + self.seasonSearch = False logger.log(u"Seeing if we need any episodes from " + self.show.name + " season " + str(self.segment)) @@ -212,11 +213,16 @@ class BacklogQueueItem(generic_queue.QueueItem): anyQualities, bestQualities = common.Quality.splitQuality(self.show.quality) #@UnusedVariable self.wantedEpisodes = self._need_any_episodes(statusResults, bestQualities) + # check if we want to search for season packs instead of just season/episode + seasonEps = show.getAllEpisodes(self.segment) + if len(seasonEps) == len(self.wantedEpisodes): + self.seasonSearch = True + def execute(self): generic_queue.QueueItem.execute(self) - results = search.searchProviders(self.show, self.segment, self.wantedEpisodes) + results = search.searchProviders(self.show, self.segment, self.wantedEpisodes, seasonSearch=self.seasonSearch) # download whatever we find for curResult in results: diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 9e2cdf88..b8c4de05 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -926,7 +926,7 @@ class ConfigGeneral: sickbeard.ROOT_DIRS = rootDirString @cherrypy.expose - def saveAddShowDefaults(self, defaultFlattenFolders, defaultStatus, anyQualities, bestQualities, subtitles=False): + def saveAddShowDefaults(self, defaultStatus, anyQualities, bestQualities, defaultFlattenFolders, subtitles=False): if anyQualities: anyQualities = anyQualities.split(',')