mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 11:32:20 -05:00
Fix for invalid torrent files causing NoneType errors.
This commit is contained in:
parent
480199085e
commit
52010d9951
@ -165,6 +165,9 @@ class GenericClient(object):
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
result.hash = self._get_torrent_hash(result)
|
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'):
|
if result.url.startswith('magnet'):
|
||||||
r_code = self._add_torrent_uri(result)
|
r_code = self._add_torrent_uri(result)
|
||||||
|
@ -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)
|
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:
|
except requests.exceptions.HTTPError, e:
|
||||||
logger.log(u"HTTP error " + str(e.errno) + " while loading URL " + url, logger.WARNING)
|
logger.log(u"HTTP error " + str(e.errno) + " while loading URL " + url, logger.WARNING)
|
||||||
return
|
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)
|
logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING)
|
||||||
return
|
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:
|
if json:
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
|
||||||
return resp.content
|
return resp.content
|
||||||
|
|
||||||
|
|
||||||
def download_file(url, filename, session=None):
|
def download_file(url, filename, session=None):
|
||||||
# create session
|
# create session
|
||||||
session = CacheControl(sess=session, cache=caches.FileCache(os.path.join(sickbeard.CACHE_DIR, 'sessions')))
|
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:
|
try:
|
||||||
resp = session.get(url)
|
resp = session.get(url)
|
||||||
if not resp.ok:
|
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
|
return False
|
||||||
|
|
||||||
with open(filename, 'wb') as fp:
|
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)
|
logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING)
|
||||||
return False
|
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
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user