diff --git a/lib/tvrage_api/tvrage_api.py b/lib/tvrage_api/tvrage_api.py index e11d557e..2199622a 100644 --- a/lib/tvrage_api/tvrage_api.py +++ b/lib/tvrage_api/tvrage_api.py @@ -366,10 +366,20 @@ class TVRage: # get response from TVRage resp = sess.get(url, params=params) + except requests.HTTPError, e: + raise tvrage_error("HTTP error " + str(e.errno) + " while loading URL " + str(url)) + + except requests.ConnectionError, e: + lastTimeout = dt.datetime.now() + raise tvrage_error("Connection error " + str(e.message) + " while loading URL " + str(url)) + + except requests.Timeout, e: + lastTimeout = dt.datetime.now() + raise tvrage_error("Connection timed out " + str(e.message) + " while loading URL " + str(url)) + except Exception, e: - if not str(e).startswith('HTTP Error'): - lastTimeout = dt.datetime.now() - raise tvrage_error("Could not connect to server: %s" % (e)) + lastTimeout = dt.datetime.now() + raise tvrage_error("Unknown exception while loading URL " + str(url) + ": " + str(e)) if 'application/zip' in resp.headers.get("Content-Type", ''): try: diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 40560616..1bda5f4d 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -191,6 +191,10 @@ Returns a byte-string retrieved from the url provider. logger.log(u"Connection error " + str(e.message) + " while loading URL " + url, logger.WARNING) return None + except requests.Timeout, e: + logger.log(u"Connection timed out " + str(e.message) + " while loading URL " + url, logger.WARNING) + return None + except Exception: logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING) return None @@ -224,6 +228,10 @@ def download_file(url, filename): logger.log(u"Connection error " + str(e.message) + " while loading URL " + url, logger.WARNING) return False + except requests.Timeout, e: + logger.log(u"Connection timed out " + str(e.message) + " while loading URL " + url, logger.WARNING) + return False + except Exception: _remove_file_failed(filename) logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING) diff --git a/sickbeard/showUpdater.py b/sickbeard/showUpdater.py index 55ae8eeb..46b4d0a3 100644 --- a/sickbeard/showUpdater.py +++ b/sickbeard/showUpdater.py @@ -40,8 +40,8 @@ class ShowUpdater(): # update at 3 AM run_updater_time = datetime.time(hour=3) - update_datetime = datetime.time.now() - update_date = update_datetime.time + update_datetime = datetime.datetime.now() + update_date = update_datetime.date() logger.log(u"Checking update interval", logger.DEBUG) @@ -86,7 +86,7 @@ class ShowUpdater(): myDB = db.DBConnection() # last_update_date <= 90 days, sorted ASC because dates are ordinal - sql_result = myDB.select("SELECT indexer_id FROM tv_shows WHERE status = 'Ended' AND last_update_indexer <= ? ORDER BY last_update_tvdb ASC LIMIT 10;", [stale_update_date]) + sql_result = myDB.select("SELECT indexer_id FROM tv_shows WHERE status = 'Ended' AND last_update_indexer <= ? ORDER BY last_update_indexer ASC LIMIT 10;", [stale_update_date]) for cur_result in sql_result: stale_should_update.append(cur_result['indexer_id'])