From a455bcb7c63d2da85f3b88a134702f2a4c99b663 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 25 Apr 2014 17:03:24 -0700 Subject: [PATCH] Fixes for RSS searches --- sickbeard/providers/generic.py | 15 +++++++++++++++ sickbeard/providers/rsstorrent.py | 11 +---------- sickbeard/providers/womble.py | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index b9e6e007..d7070b66 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -28,6 +28,8 @@ import copy import itertools import operator import collections +import urlparse +from lib.feedparser import feedparser import sickbeard @@ -117,6 +119,19 @@ class GenericProvider: return data + def getRSSFeed(self, url): + parsed = list(urlparse.urlparse(url)) + parsed[2] = re.sub("/{2,}", "/", parsed[2]) # replace two or more / with one + + f = feedparser.parse(url) + data = f.entries + + if not data: + logger.log(u"Error loading " + self.name + " URL: " + ex(e), logger.ERROR) + return None + + return data + def downloadResult(self, result): """ Save the result to disk. diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index 374e89de..dcb19460 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -37,7 +37,6 @@ from lib.feedparser import feedparser class TorrentRssProvider(generic.TorrentProvider): def __init__(self, name, url): - generic.TorrentProvider.__init__(self, name) self.cache = TorrentRssCache(self) self.url = re.sub('\/$', '', url) @@ -147,21 +146,13 @@ class TorrentRssProvider(generic.TorrentProvider): class TorrentRssCache(tvcache.TVCache): def __init__(self, provider): - tvcache.TVCache.__init__(self, provider) self.minTime = 15 def _getRSSData(self): url = self.provider.url - parsed = list(urlparse.urlparse(url)) - parsed[2] = re.sub("/{2,}", "/", parsed[2]) # replace two or more / with one - logger.log(u"TorrentRssCache cache update URL: " + self.provider.url, logger.DEBUG) - try: - data = feedparser.parse(url) - return data.entries - except Exception, e: - logger.log(u"Error loading " + self.provider + " URL: " + ex(e), logger.ERROR) + return self.provider.getRSSFeed(url) def _parseItem(self, item): diff --git a/sickbeard/providers/womble.py b/sickbeard/providers/womble.py index 89231751..fa375831 100644 --- a/sickbeard/providers/womble.py +++ b/sickbeard/providers/womble.py @@ -42,7 +42,7 @@ class WombleCache(tvcache.TVCache): def _getRSSData(self): url = self.provider.url + 'rss/?sec=TV-x264&fr=false' logger.log(u"Womble's Index cache update URL: " + url, logger.DEBUG) - data = self.provider.getURL(url) + data = self.provider.getRSSFeed(url) return data def _checkAuth(self, data):