From ad339a9b2e25b85a68889def0f7fe94e8ddf90e9 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 22 Apr 2014 01:02:43 -0700 Subject: [PATCH 1/3] Multiple bugfixes for provider code --- sickbeard/providers/btn.py | 4 ++-- sickbeard/providers/dtt.py | 2 +- sickbeard/providers/generic.py | 3 ++- sickbeard/providers/hdtorrents.py | 2 +- sickbeard/providers/iptorrents.py | 2 +- sickbeard/providers/kat.py | 6 +++--- sickbeard/providers/newznab.py | 6 +++--- sickbeard/providers/nextgen.py | 2 +- sickbeard/providers/nyaatorrents.py | 4 ++-- sickbeard/providers/publichd.py | 2 +- sickbeard/providers/rsstorrent.py | 3 +-- sickbeard/providers/scc.py | 2 +- sickbeard/providers/thepiratebay.py | 5 +++-- sickbeard/providers/torrentday.py | 2 +- sickbeard/providers/torrentleech.py | 2 +- sickbeard/scene_numbering.py | 3 ++- sickbeard/show_name_helpers.py | 2 +- sickbeard/tv.py | 2 +- 18 files changed, 28 insertions(+), 26 deletions(-) diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index 103b2cf9..9e8b3c1f 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Author: Dani�l Heimans +# Author: Daniel Heimans # URL: http://code.google.com/p/sickbeard # # This file is part of Sick Beard. @@ -225,7 +225,7 @@ class BTNProvider(generic.TorrentProvider): if show.air_by_date: # Search for the year of the air by date show - partial_season_params['name'] = str(season.split('-')[0]) + partial_season_params['name'] = str(season).split('-')[0] else: # Search for any result which has Sxx in the name partial_season_params['name'] = 'S%02d' % int(season) diff --git a/sickbeard/providers/dtt.py b/sickbeard/providers/dtt.py index 4e4d1fe1..ea452715 100644 --- a/sickbeard/providers/dtt.py +++ b/sickbeard/providers/dtt.py @@ -57,7 +57,7 @@ class DTTProvider(generic.TorrentProvider): def _dtt_show_id(self, show_name): return sanitizeSceneName(show_name).replace('.', '-').lower() - def _get_season_search_strings(self, show, season, wantedEp, searchSeason=False): + def _get_season_search_strings(self, show, season, wantedEp=None, searchSeason=False): search_string = [] for show_name in set(show_name_helpers.allPossibleShowNames(show)): diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 985e7d2b..b9e6e007 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -1,3 +1,4 @@ +# coding=utf-8 # Author: Nic Wolfe # URL: http://code.google.com/p/sickbeard/ # @@ -308,7 +309,7 @@ class GenericProvider: searchSeason = True for sceneSeason, sceneEpisodes in sceneSeasons.iteritems(): - for curString in self._get_season_search_strings(show, str(sceneSeason), sceneEpisodes, searchSeason): + for curString in self._get_season_search_strings(show, sceneSeason, sceneEpisodes, searchSeason): itemList += self._doSearch(curString) for item in itemList: diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index ffd5c924..e4e1b8b3 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -277,7 +277,7 @@ class HDTorrentsProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not self.session: self._doLogin() diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 873d05a7..7681db47 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -221,7 +221,7 @@ class IPTorrentsProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not self.session: self._doLogin() diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 730793dc..3e700549 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -1,3 +1,4 @@ +# coding=utf-8 # Author: Mr_Orange # URL: http://code.google.com/p/sickbeard/ # @@ -174,8 +175,7 @@ class KATProvider(generic.TorrentProvider): if searchSeason: search_string = {'Season': [], 'Episode': []} for show_name in set(allPossibleShowNames(show)): - ep_string = show_name + ' S%02d' % int(season) + ' -S%02d' % int( - season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE + ep_string = show_name + ' S%02d' % int(season) + ' -S%02d' % int(season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE search_string['Season'].append(ep_string) ep_string = show_name + ' Season ' + str(season) + ' -Ep*' + ' category:tv' #2) ShowName Season X @@ -305,7 +305,7 @@ class KATProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): try: # Remove double-slashes from url diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index 4f6bc088..617e12a1 100644 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -99,11 +99,11 @@ class NewznabProvider(generic.NZBProvider): # air-by-date means &season=2010&q=2010.03, no other way to do it atm if show.air_by_date: - cur_params['season'] = season.split('-')[0] + cur_params['season'] = str(season).split('-')[0] if 'q' in cur_params: - cur_params['q'] += '.' + season.replace('-', '.') + cur_params['q'] += '.' + str(season).replace('-', '.') else: - cur_params['q'] = season.replace('-', '.') + cur_params['q'] = str(season).replace('-', '.') else: cur_params['season'] = str(season) diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index 234b088c..fa37092c 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -265,7 +265,7 @@ class NextGenProvider(generic.TorrentProvider): return title, url - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not self.session: self._doLogin() diff --git a/sickbeard/providers/nyaatorrents.py b/sickbeard/providers/nyaatorrents.py index d40f9ad5..6726d227 100644 --- a/sickbeard/providers/nyaatorrents.py +++ b/sickbeard/providers/nyaatorrents.py @@ -59,7 +59,7 @@ class NyaaProvider(generic.TorrentProvider): def getQuality(self, item, anime=False): self.debug() title = helpers.get_xml_text(item.getElementsByTagName('title')[0]).replace("/", " ") - quality = Quality.sceneQuality(title, anime) + quality = Quality.sceneQuality(title) return quality def findSeasonResults(self, show, season): @@ -69,7 +69,7 @@ class NyaaProvider(generic.TorrentProvider): return results - def _get_season_search_strings(self, show, season, wantedEp, searchSeason=False): + def _get_season_search_strings(self, show, season, wantedEp=None, searchSeason=False): names = [] names.extend(show_name_helpers.makeSceneShowSearchStrings(show)) return names diff --git a/sickbeard/providers/publichd.py b/sickbeard/providers/publichd.py index 0d342ae0..899bcacc 100644 --- a/sickbeard/providers/publichd.py +++ b/sickbeard/providers/publichd.py @@ -204,7 +204,7 @@ class PublicHDProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): try: # Remove double-slashes from url diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index b1171589..93aa3aec 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -51,8 +51,7 @@ class TorrentRssProvider(generic.TorrentProvider): return self.name + '|' + self.url + '|' + str(int(self.enabled)) def imageName(self): - if ek.ek(os.path.isfile, - ek.ek(os.path.join, sickbeard.PROG_DIR, 'data', 'images', 'providers', self.getID() + '.png')): + if ek.ek(os.path.isfile, ek.ek(os.path.join, sickbeard.PROG_DIR, 'data', 'images', 'providers', self.getID() + '.png')): return self.getID() + '.png' return 'torrentrss.png' diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index c0400053..1e563c13 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -224,7 +224,7 @@ class SCCProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not self.session: self._doLogin() diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 842ec406..3f6c1548 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -33,6 +33,7 @@ from sickbeard import classes from sickbeard import logger from sickbeard import tvcache from sickbeard import helpers +from sickbeard import clients from sickbeard.show_name_helpers import allPossibleShowNames, sanitizeSceneName from sickbeard.common import Overview from sickbeard.exceptions import ex @@ -296,7 +297,7 @@ class ThePirateBayProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not headers: headers = {} @@ -316,7 +317,7 @@ class ThePirateBayProvider(generic.TorrentProvider): if r.status_code != 200: logger.log(self.name + u" page requested with url " + url + " returned status code is " + str( - r.status_code) + ': ' + requests.clients.http_error_code[r.status_code], logger.WARNING) + r.status_code) + ': ' + clients.http_error_code[r.status_code], logger.WARNING) return None return r.content diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index c8199b95..91eff4fe 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -218,7 +218,7 @@ class TorrentDayProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not self.session: self._doLogin() diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index 1b3c5532..bbb05e00 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -218,7 +218,7 @@ class TorrentLeechProvider(generic.TorrentProvider): return (title, url) - def getURL(self, url, headers=None): + def getURL(self, url, post_data=None, headers=None): if not self.session: self._doLogin() diff --git a/sickbeard/scene_numbering.py b/sickbeard/scene_numbering.py index 12be1153..3fb47e8e 100644 --- a/sickbeard/scene_numbering.py +++ b/sickbeard/scene_numbering.py @@ -1,3 +1,5 @@ +# Author: Nic Wolfe +# URL: http://code.google.com/p/sickbeard/ # # This file is part of Sick Beard. # @@ -34,7 +36,6 @@ from sickbeard import db from sickbeard import helpers from sickbeard.exceptions import ex from lib import requests -from lib.requests import exceptions MAX_XEM_AGE_SECS = 86400 # 1 day diff --git a/sickbeard/show_name_helpers.py b/sickbeard/show_name_helpers.py index 6a776723..c2f14cd5 100644 --- a/sickbeard/show_name_helpers.py +++ b/sickbeard/show_name_helpers.py @@ -133,7 +133,7 @@ def makeSceneSeasonSearchString(show, segment, extraSearchType=None): [show.indexerid]) numseasons = int(numseasonsSQlResult[0][0]) - seasonStrings = ["S%02d" % segment] + seasonStrings = ["S%02d" % int(segment)] showNames = set(makeSceneShowSearchStrings(show)) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index f7514b1e..3ea8b5aa 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -136,7 +136,7 @@ class TVShow(object): if not self.air_by_date: sql_selection = sql_selection + " AND season = " + str(season) else: - segment_year, segment_month = map(int, season.split('-')) + segment_year, segment_month = map(int, str(season).split('-')) min_date = datetime.date(segment_year, segment_month, 1) # it's easier to just hard code this than to worry about rolling the year over or making a month length map From 77696cad66c91982d238965858228cfb4028f3ec Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 22 Apr 2014 03:13:44 -0700 Subject: [PATCH 2/3] Fix for rss torrent feeds, resolves issue #32 --- sickbeard/providers/rsstorrent.py | 1 - sickbeard/webserve.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index 93aa3aec..edfb267f 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -113,7 +113,6 @@ class TorrentRssProvider(generic.TorrentProvider): if url.startswith('magnet:') and re.search('urn:btih:([\w]{32,40})', url): return (True, 'RSS feed Parsed correctly') else: - torrent_file = self.getURL(url) try: bdecode(torrent_file) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index cb7d46b4..de74663d 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -1364,9 +1364,8 @@ class ConfigProviders: return providerDict[name].getID() + '|' + providerDict[name].configStr() else: - newProvider = rsstorrent.TorrentRssProvider(name, url) - sickbeard.TorrentRssProviderList.append(newProvider) + sickbeard.torrentRssProviderList.append(newProvider) return newProvider.getID() + '|' + newProvider.configStr() @cherrypy.expose From e7cf923cc03c42a982f09cd75c337ea4068dcb3c Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 22 Apr 2014 03:30:18 -0700 Subject: [PATCH 3/3] Removes primary keys and unique keys from xem_numbering table in cache.db --- sickbeard/databases/cache_db.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sickbeard/databases/cache_db.py b/sickbeard/databases/cache_db.py index d5e23b80..cbfb5a3e 100644 --- a/sickbeard/databases/cache_db.py +++ b/sickbeard/databases/cache_db.py @@ -108,3 +108,8 @@ class ConvertIndexerToInteger(ConvertSceneNamesToIndexerID): ql.append(["UPDATE xem_refresh SET indexer = ? WHERE LOWER(indexer) = ?", ["1", "tvdb"]]) ql.append(["UPDATE xem_refresh SET indexer = ? WHERE LOWER(indexer) = ?", ["2", "tvrage"]]) self.connection.mass_action(ql) + +class RemoveKeysFromXemNumbering(ConvertIndexerToInteger): + def execute(self): + self.connection.action("ALTER TABLE xem_numbering DROP UNIQUE (indexer, indexer_id, season, episode)") + self.connection.action("ALTER TABLE xem_numbering DROP PRIMARY KEY") \ No newline at end of file