1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Fix for invalid torrent files causing NoneType errors.

This commit is contained in:
echel0n 2014-07-27 23:00:25 -07:00
parent 480199085e
commit 52010d9951
2 changed files with 10 additions and 14 deletions

View File

@ -165,6 +165,9 @@ class GenericClient(object):
try:
result.hash = self._get_torrent_hash(result)
if not result.hash:
logger.log(self.name + u': Unable to get hash for Torrent', logger.DEBUG)
return False
if result.url.startswith('magnet'):
r_code = self._add_torrent_uri(result)

View File

@ -1233,6 +1233,11 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
}
resp = session.get(url, data=post_data, timeout=timeout)
if not resp.ok:
logger.log(u"Requested url " + url + " returned status code is " + str(
resp.status_code) + ': ' + clients.http_error_code[resp.status_code], logger.WARNING)
return
except requests.exceptions.HTTPError, e:
logger.log(u"HTTP error " + str(e.errno) + " while loading URL " + url, logger.WARNING)
return
@ -1246,17 +1251,11 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING)
return
if not resp.ok:
logger.log(u"Requested url " + url + " returned status code is " + str(
resp.status_code) + ': ' + clients.http_error_code[resp.status_code], logger.WARNING)
return
if json:
return resp.json()
return resp.content
def download_file(url, filename, session=None):
# create session
session = CacheControl(sess=session, cache=caches.FileCache(os.path.join(sickbeard.CACHE_DIR, 'sessions')))
@ -1281,6 +1280,8 @@ def download_file(url, filename, session=None):
try:
resp = session.get(url)
if not resp.ok:
logger.log(u"Requested url " + url + " returned status code is " + str(
resp.status_code) + ': ' + clients.http_error_code[resp.status_code], logger.WARNING)
return False
with open(filename, 'wb') as fp:
@ -1311,14 +1312,6 @@ def download_file(url, filename, session=None):
logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING)
return False
if not resp:
logger.log(u"No data returned from " + url, logger.DEBUG)
return False
elif not resp.ok:
logger.log(u"Requested url " + url + " returned status code is " + str(
resp.status_code) + ': ' + clients.http_error_code[resp.status_code], logger.WARNING)
return False
return True