From 8b678445cc45638d3c2ab15afe6901fbe7e0ec89 Mon Sep 17 00:00:00 2001 From: KontiSR Date: Fri, 19 Sep 2014 12:05:50 +0200 Subject: [PATCH 1/2] Fix exception for when no results returned. --- sickbeard/providers/tokyotoshokan.py | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sickbeard/providers/tokyotoshokan.py b/sickbeard/providers/tokyotoshokan.py index 35034595..12286b07 100644 --- a/sickbeard/providers/tokyotoshokan.py +++ b/sickbeard/providers/tokyotoshokan.py @@ -105,20 +105,21 @@ class TokyoToshokanProvider(generic.TorrentProvider): with BS4Parser(data, features=["html5lib", "permissive"]) as soup: torrent_table = soup.find('table', attrs={'class': 'listing'}) torrent_rows = torrent_table.find_all('tr') if torrent_table else [] - if torrent_rows[0].find('td', attrs={'class': 'centertext'}): - a = 1 - else: - a = 0 - - for top, bottom in zip(torrent_rows[a::2], torrent_rows[a::2]): - title = top.find('td', attrs={'class': 'desc-top'}).text - url = top.find('td', attrs={'class': 'desc-top'}).find('a')['href'] - - if not title or not url: - continue - - item = title.lstrip(), url - results.append(item) + if torrent_rows: + if torrent_rows[0].find('td', attrs={'class': 'centertext'}): + a = 1 + else: + a = 0 + + for top, bottom in zip(torrent_rows[a::2], torrent_rows[a::2]): + title = top.find('td', attrs={'class': 'desc-top'}).text + url = top.find('td', attrs={'class': 'desc-top'}).find('a')['href'] + + if not title or not url: + continue + + item = title.lstrip(), url + results.append(item) except Exception, e: logger.log(u"Failed to parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR) From 4b1b3c6488d68cb73b4d535a561bace7447ee847 Mon Sep 17 00:00:00 2001 From: KontiSR Date: Fri, 19 Sep 2014 12:06:59 +0200 Subject: [PATCH 2/2] When no absolute episode number retrieved, fall backto the scene_episode. Else search will be done for episode: 00 --- sickbeard/show_name_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sickbeard/show_name_helpers.py b/sickbeard/show_name_helpers.py index f5df5d65..f5657083 100644 --- a/sickbeard/show_name_helpers.py +++ b/sickbeard/show_name_helpers.py @@ -190,7 +190,7 @@ def makeSceneSearchString(show, ep_obj): if (show.air_by_date or show.sports) and ep_obj.airdate != datetime.date.fromordinal(1): epStrings = [str(ep_obj.airdate)] elif show.is_anime: - epStrings = ["%02i" % int(ep_obj.scene_absolute_number)] + epStrings = ["%02i" % int(ep_obj.scene_absolute_number if ep_obj.scene_absolute_number > 0 else ep_obj.scene_episode)] else: epStrings = ["S%02iE%02i" % (int(ep_obj.scene_season), int(ep_obj.scene_episode)), "%ix%02i" % (int(ep_obj.scene_season), int(ep_obj.scene_episode))]