diff --git a/sickbeard/clients/generic.py b/sickbeard/clients/generic.py index 227a2d83..7a1ef698 100644 --- a/sickbeard/clients/generic.py +++ b/sickbeard/clients/generic.py @@ -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) diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index ea17708c..ddbbdcb2 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -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