From 05dcdd72d7771775034f22b07c49c660b48db1a1 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 6 Jun 2014 16:55:14 -0700 Subject: [PATCH] Fix for air-by-date/sports/anime provider searches --- sickbeard/providers/btn.py | 9 ++++---- sickbeard/providers/ezrss.py | 12 ++++++++--- sickbeard/providers/hdbits.py | 31 ++++++++++++++++++++++----- sickbeard/providers/hdtorrents.py | 9 +++++++- sickbeard/providers/iptorrents.py | 9 +++++++- sickbeard/providers/kat.py | 33 ++++++++++++++--------------- sickbeard/providers/nextgen.py | 9 +++++++- sickbeard/providers/scc.py | 9 +++++++- sickbeard/providers/speedcd.py | 9 +++++++- sickbeard/providers/thepiratebay.py | 33 +++++++++++++++++------------ sickbeard/providers/torrentday.py | 10 ++++++++- sickbeard/providers/torrentleech.py | 9 +++++++- 12 files changed, 132 insertions(+), 50 deletions(-) diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index 66e6bbb4..1445eac8 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -219,8 +219,7 @@ class BTNProvider(generic.TorrentProvider): # Search for the year of the air by date show whole_season_params['name'] = str(ep_obj.airdate).split('-')[0] elif ep_obj.show.is_anime: - whole_season_params['name'] = 'S' + str(ep_obj.scene_season) - #whole_season_params['name'] = "%d" % ep_obj.scene_absolute_number + whole_season_params['name'] = "%d" % ep_obj.scene_absolute_number else: whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) @@ -253,8 +252,10 @@ class BTNProvider(generic.TorrentProvider): # BTN uses dots in dates, we just search for the date since that # combined with the series identifier should result in just one episode - search_params['name'] = date_str.replace('-', '.') - elif not self.show.is_anime: + search_params['name'] = ep_obj.airdate.strftime('%b') + elif self.show.anime: + search_params['name'] = "%i" % int(ep_obj.scene_absolute_number) + else: # Do a general name search for the episode, formatted like SXXEYY search_params['name'] = "S%02dE%02d" % (ep_obj.scene_season, ep_obj.scene_episode) diff --git a/sickbeard/providers/ezrss.py b/sickbeard/providers/ezrss.py index 9da51227..316f83e0 100644 --- a/sickbeard/providers/ezrss.py +++ b/sickbeard/providers/ezrss.py @@ -81,8 +81,12 @@ class EZRSSProvider(generic.TorrentProvider): params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8') - if ep_obj.show.air_by_date or ep_obj.show.sports: - params['season'] = str(ep_obj.airdate).split('-')[0] + if ep_obj.show.air_by_date: + params['date'] = str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.sports: + params['date'] = str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + params['season'] = "%d" % ep_obj.scene_absolute_number else: params['season'] = ep_obj.scene_season @@ -99,8 +103,10 @@ class EZRSSProvider(generic.TorrentProvider): if self.show.air_by_date: params['date'] = str(ep_obj.airdate) - if self.show.sports: + elif self.show.sports: params['date'] = str(ep_obj.airdate) + elif self.show.anime: + params['episode'] = "%i" % int(ep_obj.scene_absolute_number) else: params['season'] = ep_obj.scene_season params['episode'] = ep_obj.scene_episode diff --git a/sickbeard/providers/hdbits.py b/sickbeard/providers/hdbits.py index 925bff1c..ab5829c1 100644 --- a/sickbeard/providers/hdbits.py +++ b/sickbeard/providers/hdbits.py @@ -158,11 +158,27 @@ class HDBitsProvider(generic.TorrentProvider): } if episode: - post_data['tvdb'] = { - 'id': show.indexerid, - 'season': episode.scene_season, - 'episode': episode.scene_episode - } + if show.air_by_date: + post_data['tvdb'] = { + 'id': show.indexerid, + 'episode': str(episode.airdate).replace('-', '|') + } + elif show.sports: + post_data['tvdb'] = { + 'id': show.indexerid, + 'episode': episode.airdate.strftime('%b') + } + elif show.anime: + post_data['tvdb'] = { + 'id': show.indexerid, + 'episode': "%i" % int(episode.scene_absolute_number) + } + else: + post_data['tvdb'] = { + 'id': show.indexerid, + 'season': episode.scene_season, + 'episode': episode.scene_episode + } if season: if show.air_by_date or show.sports: @@ -170,6 +186,11 @@ class HDBitsProvider(generic.TorrentProvider): 'id': show.indexerid, 'season': str(episode.airdate)[:7], } + elif show.anime: + post_data['tvdb'] = { + 'id': show.indexerid, + 'season': "%d" % episode.scene_absolute_number, + } else: post_data['tvdb'] = { 'id': show.indexerid, diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index 5de98cae..03fbc45d 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -125,7 +125,9 @@ class HDTorrentsProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -151,6 +153,11 @@ class HDTorrentsProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 37afda01..e6e50bdc 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -102,7 +102,9 @@ class IPTorrentsProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -128,6 +130,11 @@ class IPTorrentsProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 6bd2aec3..a27f8af6 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -174,23 +174,22 @@ class KATProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - if not (ep_obj.show.air_by_date or ep_obj.show.sports): - for show_name in set(allPossibleShowNames(self.show)): - if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] - search_string['Season'].append(ep_string) - ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0] - search_string['Season'].append(ep_string) - elif ep_obj.show.anime: - ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number - search_string['Season'].append(ep_string) - else: - ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int( - ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE - search_string['Season'].append(ep_string) - ep_string = show_name + ' Season ' + str( - ep_obj.scene_season) + ' -Ep*' + ' category:tv' # 2) showName Season X - search_string['Season'].append(ep_string) + for show_name in set(allPossibleShowNames(self.show)): + if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + search_string['Season'].append(ep_string) + ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0] + search_string['Season'].append(ep_string) + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number + search_string['Season'].append(ep_string) + else: + ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int( + ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE + search_string['Season'].append(ep_string) + ep_string = show_name + ' Season ' + str( + ep_obj.scene_season) + ' -Ep*' + ' category:tv' # 2) showName Season X + search_string['Season'].append(ep_string) return [search_string] diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index c988c827..41fdbfa6 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -141,7 +141,9 @@ class NextGenProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -167,6 +169,11 @@ class NextGenProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index 7d7c9110..188b6c31 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -112,7 +112,9 @@ class SCCProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -138,6 +140,11 @@ class SCCProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index b42406c9..52e18dd4 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -102,7 +102,9 @@ class SpeedCDProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -128,6 +130,11 @@ class SpeedCDProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 3b1c56c9..d3e58fa2 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -167,17 +167,22 @@ class ThePirateBayProvider(generic.TorrentProvider): def _get_season_search_strings(self, ep_obj): search_string = {'Season': []} - for show_name in set(allPossibleShowNames(self.show)) if not (ep_obj.show.air_by_date or ep_obj.show.sports) else []: - if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] - else: - ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX - search_string['Season'].append(ep_string) - + for show_name in set(allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + search_string['Season'].append(ep_string) ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0] + search_string['Season'].append(ep_string) + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number + search_string['Season'].append(ep_string) else: - ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' #2) showName Season X + ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int( + ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE + search_string['Season'].append(ep_string) + ep_string = show_name + ' Season ' + str( + ep_obj.scene_season) + ' -Ep*' + ' category:tv' # 2) showName Season X + search_string['Season'].append(ep_string) search_string['Season'].append(ep_string) @@ -198,18 +203,18 @@ class ThePirateBayProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(allPossibleShowNames(self.show)): ep_string = sanitizeSceneName(show_name) + ' ' + \ sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season, 'episodenumber': ep_obj.scene_episode} + '|' + \ sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season, - 'episodenumber': ep_obj.scene_episode} + '|' + \ - sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep_obj.scene_season, - 'episodenumber': ep_obj.scene_episode} - - ep_string += ' %s' % add_string - + 'episodenumber': ep_obj.scene_episode} + ' %s' % add_string search_string['Episode'].append(re.sub('\s+', ' ', ep_string)) return [search_string] diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 48660d10..01d878d0 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -133,7 +133,10 @@ class TorrentDayProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number + search_string['Season'].append(ep_string) else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -159,6 +162,11 @@ class TorrentDayProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index db694040..7f586b2d 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -107,7 +107,9 @@ class TorrentLeechProvider(generic.TorrentProvider): search_string = {'Season': []} for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports: - ep_string = show_name + str(ep_obj.airdate).split('-')[0] + ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] + elif ep_obj.show.anime: + ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX @@ -133,6 +135,11 @@ class TorrentLeechProvider(generic.TorrentProvider): str(ep_obj.airdate).replace('-', '|') + '|' + \ ep_obj.airdate.strftime('%b') search_string['Episode'].append(ep_string) + elif self.show.anime: + for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): + ep_string = sanitizeSceneName(show_name) + ' ' + \ + "%i" % int(ep_obj.scene_absolute_number) + search_string['Episode'].append(ep_string) else: for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \