1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

More RSS fixes

This commit is contained in:
echel0n 2014-04-25 18:49:38 -07:00
parent 3ee6d45fcd
commit 7a22f6c77a
7 changed files with 25 additions and 45 deletions

View File

@ -17,17 +17,13 @@
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. # along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import urllib import urllib
import re
from xml.dom.minidom import parseString
import sickbeard import sickbeard
import generic import generic
from sickbeard.common import Quality from sickbeard.common import Quality
from sickbeard import logger from sickbeard import logger
from sickbeard import tvcache from sickbeard import tvcache
from sickbeard.helpers import sanitizeSceneName, get_xml_text from sickbeard.helpers import sanitizeSceneName
from sickbeard import show_name_helpers from sickbeard import show_name_helpers
from sickbeard.exceptions import ex from sickbeard.exceptions import ex
@ -46,7 +42,7 @@ class DTTProvider(generic.TorrentProvider):
return 'dailytvtorrents.gif' return 'dailytvtorrents.gif'
def getQuality(self, item): def getQuality(self, item):
url = item.getElementsByTagName('enclosure')[0].getAttribute('url') url = item.enclosures[0].href
quality = Quality.sceneQuality(url) quality = Quality.sceneQuality(url)
return quality return quality

View File

@ -161,12 +161,12 @@ class NewznabProvider(generic.NZBProvider):
return True return True
def _checkAuthFromData(self, parsedXML): def _checkAuthFromData(self, data):
if parsedXML is None: if data is None:
return self._checkAuth() return self._checkAuth()
status = parsedXML.status status = data.status
if status: if status:
if status == 200: if status == 200:
return True return True
@ -178,7 +178,7 @@ class NewznabProvider(generic.NZBProvider):
raise AuthException( raise AuthException(
"Your account isn't allowed to use the API on " + self.name + ", contact the administrator") "Your account isn't allowed to use the API on " + self.name + ", contact the administrator")
else: else:
logger.log(u"Unknown error given from " + self.name + ": " + parsedXML.attrib['description'], logger.log(u"Unknown error given from " + self.name + ": " + data.description,
logger.ERROR) logger.ERROR)
return False return False
@ -302,5 +302,5 @@ class NewznabCache(tvcache.TVCache):
return data return data
def _checkAuth(self, parsedXML): def _checkAuth(self, data):
return self.provider._checkAuthFromData(parsedXML) return self.provider._checkAuthFromData(data)

View File

@ -17,26 +17,18 @@
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. # along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import urllib import urllib
from xml.dom.minidom import parseString
import re import re
import sys
import sickbeard import sickbeard
import generic import generic
from sickbeard import show_name_helpers, helpers from sickbeard import show_name_helpers
from sickbeard import logger from sickbeard import logger
from sickbeard.common import Quality from sickbeard.common import Quality
from sickbeard.exceptions import ex
from sickbeard.name_parser.parser import NameParser, InvalidNameException from sickbeard.name_parser.parser import NameParser, InvalidNameException
from sickbeard import tvcache from sickbeard import tvcache
REMOTE_DBG = False REMOTE_DBG = False
class NyaaProvider(generic.TorrentProvider): class NyaaProvider(generic.TorrentProvider):
def __init__(self): def __init__(self):
@ -58,7 +50,7 @@ class NyaaProvider(generic.TorrentProvider):
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
self.debug() self.debug()
title = helpers.get_xml_text(item.getElementsByTagName('title')[0]).replace("/", " ") title = item.title
quality = Quality.sceneQuality(title) quality = Quality.sceneQuality(title)
return quality return quality
@ -87,19 +79,16 @@ class NyaaProvider(generic.TorrentProvider):
logger.log(u"Search string: " + searchURL, logger.DEBUG) logger.log(u"Search string: " + searchURL, logger.DEBUG)
data = self.getURL(searchURL) data = self.getURL(searchURL)
if not data: if not data:
return [] logger.log(u"Error trying to load NyaaTorrents RSS feed: " + searchURL, logger.ERROR)
try:
parsedXML = parseString(data)
items = parsedXML.getElementsByTagName('item')
except Exception, e:
logger.log(u"Error trying to load NyaaTorrents RSS feed: " + ex(e), logger.ERROR)
logger.log(u"RSS data: " + data, logger.DEBUG) logger.log(u"RSS data: " + data, logger.DEBUG)
return [] return []
items = data.entries
results = [] results = []
for curItem in items: for curItem in items:

View File

@ -76,20 +76,16 @@ class NZBsProvider(generic.NZBProvider):
logger.log(u"Search string: " + searchURL, logger.DEBUG) logger.log(u"Search string: " + searchURL, logger.DEBUG)
data = self.getURL(searchURL) data = self.getRSSFeed(searchURL)
# Pause to avoid 503's # Pause to avoid 503's
time.sleep(5) time.sleep(5)
if data == None: if data == None:
logger.log(u"Error trying to load NZBs.org RSS feed: " + searchURL, logger.ERROR)
return [] return []
try: items = data.entries
parsedXML = parseString(data)
items = parsedXML.getElementsByTagName('item')
except Exception, e:
logger.log(u"Error trying to load NZBs.org RSS feed: " + ex(e), logger.ERROR)
return []
results = [] results = []

View File

@ -179,8 +179,7 @@ class OmgwtfnzbsCache(tvcache.TVCache):
return data return data
def _checkAuth(self, parsedXML): def _checkAuth(self, data):
return self.provider._checkAuthFromData(parsedXML) return self.provider._checkAuthFromData(data)
provider = OmgwtfnzbsProvider() provider = OmgwtfnzbsProvider()

View File

@ -54,12 +54,12 @@ class TvTorrentsProvider(generic.TorrentProvider):
return True return True
def _checkAuthFromData(self, parsedXML): def _checkAuthFromData(self, data):
if parsedXML is None: if data is None:
return self._checkAuth() return self._checkAuth()
description_text = helpers.get_xml_text(parsedXML.find('.//channel/description')) description_text = data.description
if "User can't be found" in description_text or "Invalid Hash" in description_text: if "User can't be found" in description_text or "Invalid Hash" in description_text:
logger.log(u"Incorrect authentication credentials for " + self.name + " : " + str(description_text), logger.log(u"Incorrect authentication credentials for " + self.name + " : " + str(description_text),
@ -92,8 +92,8 @@ class TvTorrentsCache(tvcache.TVCache):
return data return data
def _checkAuth(self, parsedXML): def _checkAuth(self, data):
return self.provider._checkAuthFromData(parsedXML) return self.provider._checkAuthFromData(data)
provider = TvTorrentsProvider() provider = TvTorrentsProvider()

View File

@ -80,7 +80,7 @@ class TVCache():
return data return data
def _checkAuth(self, parsedXML): def _checkAuth(self, data):
return True return True
def _checkItemAuth(self, title, url): def _checkItemAuth(self, title, url):