1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -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/>.
import urllib
import re
from xml.dom.minidom import parseString
import sickbeard
import generic
from sickbeard.common import Quality
from sickbeard import logger
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.exceptions import ex
@ -46,7 +42,7 @@ class DTTProvider(generic.TorrentProvider):
return 'dailytvtorrents.gif'
def getQuality(self, item):
url = item.getElementsByTagName('enclosure')[0].getAttribute('url')
url = item.enclosures[0].href
quality = Quality.sceneQuality(url)
return quality

View File

@ -161,12 +161,12 @@ class NewznabProvider(generic.NZBProvider):
return True
def _checkAuthFromData(self, parsedXML):
def _checkAuthFromData(self, data):
if parsedXML is None:
if data is None:
return self._checkAuth()
status = parsedXML.status
status = data.status
if status:
if status == 200:
return True
@ -178,7 +178,7 @@ class NewznabProvider(generic.NZBProvider):
raise AuthException(
"Your account isn't allowed to use the API on " + self.name + ", contact the administrator")
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)
return False
@ -302,5 +302,5 @@ class NewznabCache(tvcache.TVCache):
return data
def _checkAuth(self, parsedXML):
return self.provider._checkAuthFromData(parsedXML)
def _checkAuth(self, data):
return self.provider._checkAuthFromData(data)

View File

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

View File

@ -76,20 +76,16 @@ class NZBsProvider(generic.NZBProvider):
logger.log(u"Search string: " + searchURL, logger.DEBUG)
data = self.getURL(searchURL)
data = self.getRSSFeed(searchURL)
# Pause to avoid 503's
time.sleep(5)
if data == None:
logger.log(u"Error trying to load NZBs.org RSS feed: " + searchURL, logger.ERROR)
return []
try:
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 []
items = data.entries
results = []

View File

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

View File

@ -54,12 +54,12 @@ class TvTorrentsProvider(generic.TorrentProvider):
return True
def _checkAuthFromData(self, parsedXML):
def _checkAuthFromData(self, data):
if parsedXML is None:
if data is None:
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:
logger.log(u"Incorrect authentication credentials for " + self.name + " : " + str(description_text),
@ -92,8 +92,8 @@ class TvTorrentsCache(tvcache.TVCache):
return data
def _checkAuth(self, parsedXML):
return self.provider._checkAuthFromData(parsedXML)
def _checkAuth(self, data):
return self.provider._checkAuthFromData(data)
provider = TvTorrentsProvider()

View File

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