From 8141d8a17095efaf53d1224706b33087fec400ba Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 20 May 2014 20:22:48 -0700 Subject: [PATCH] Fixed issues for custom RSS torrent providers --- sickbeard/providers/__init__.py | 27 ++++++++++++++++++++++++--- sickbeard/providers/newznab.py | 5 ----- sickbeard/providers/rsstorrent.py | 13 +++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py index 8acf2bce..1dc2f50e 100644 --- a/sickbeard/providers/__init__.py +++ b/sickbeard/providers/__init__.py @@ -114,7 +114,8 @@ def makeNewznabProvider(configString): newznab = sys.modules['sickbeard.providers.newznab'] - newProvider = newznab.NewznabProvider(name, url, key=key, catIDs=catIDs, search_mode=search_mode, search_fallback=search_fallback) + newProvider = newznab.NewznabProvider(name, url, key=key, catIDs=catIDs, search_mode=search_mode, + search_fallback=search_fallback) newProvider.enabled = enabled == '1' return newProvider @@ -122,6 +123,15 @@ def makeNewznabProvider(configString): def getTorrentRssProviderList(data): providerList = filter(lambda x: x, [makeTorrentRssProvider(x) for x in data.split('!!!')]) + + seen_values = set() + providerListDeduped = [] + for d in providerList: + value = d.name + if value not in seen_values: + providerListDeduped.append(d) + seen_values.add(value) + return filter(lambda x: x, providerList) @@ -129,11 +139,22 @@ def makeTorrentRssProvider(configString): if not configString: return None - name, url, enabled = configString.split('|') + search_mode = 'eponly' + search_fallback = 0 + backlog_only = 0 + + try: + name, url, enabled, search_mode, search_fallback, backlog_only = configString.split('|') + except ValueError: + try: + name, url, enabled = configString.split('|') + except ValueError: + logger.log(u"Skipping RSS Torrent provider string: '" + configString + "', incorrect format", logger.ERROR) + return None torrentRss = sys.modules['sickbeard.providers.rsstorrent'] - newProvider = torrentRss.TorrentRssProvider(name, url) + newProvider = torrentRss.TorrentRssProvider(name, url, search_mode, search_fallback, backlog_only) newProvider.enabled = enabled == '1' return newProvider diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index dec57370..b279e10d 100644 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -53,11 +53,6 @@ class NewznabProvider(generic.NZBProvider): self.search_mode = search_mode self.search_fallback = search_fallback - if self.search_fallback == '0': - self.search_fallback = False - else: - self.search_fallback = True - # a 0 in the key spot indicates that no key is needed if self.key == '0': self.needs_auth = False diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index e79aef37..ccf44e13 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -35,15 +35,20 @@ from lib.requests import exceptions from lib.bencode import bdecode class TorrentRssProvider(generic.TorrentProvider): - def __init__(self, name, url): + def __init__(self, name, url, search_mode='eponly', search_fallback=False, backlog_only=False): generic.TorrentProvider.__init__(self, name) self.cache = TorrentRssCache(self) - self.url = re.sub('\/$', '', url) + #self.url = re.sub('\/$', '', url) + self.url = url self.enabled = True self.supportsBacklog = False + self.search_mode = search_mode + self.search_fallback = search_fallback + self.backlog_only = backlog_only + def configStr(self): - return self.name + '|' + self.url + '|' + str(int(self.enabled)) + return self.name + '|' + self.url + '|' + str(int(self.enabled)) + '|' + self.search_mode + '|' + str(int(self.search_fallback)) + '|' + str(int(self.backlog_only)) def imageName(self): if ek.ek(os.path.isfile, ek.ek(os.path.join, sickbeard.PROG_DIR, 'data', 'images', 'providers', self.getID() + '.png')): @@ -164,5 +169,5 @@ class TorrentRssCache(tvcache.TVCache): logger.log(u"The XML returned from the RSS feed is incomplete, this result is unusable", logger.ERROR) return None - logger.log(u"RSS Feed provider: [" + self.provider.name + "] Attempting to add item to cache: " + title, logger.DEBUG) + logger.log(u"Attempting to add item to cache: " + title, logger.DEBUG) return self._addCacheEntry(title, url) \ No newline at end of file