diff --git a/CHANGES.md b/CHANGES.md index ab103844..1db8c413 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,7 @@ * Change py2 octal literals into the new py2/3 syntax * Change Kodi notifier to use requests as opposed to urllib * Change to consolidate scene exceptions and name cache code +* Change check_url function to use requests instead of httplib library [develop changelog] * Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457) diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 8346df03..883becf6 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -28,7 +28,6 @@ import tempfile import time import traceback import hashlib -import httplib import urlparse import uuid import base64 @@ -788,19 +787,11 @@ def get_lan_ip(): def check_url(url): """ Check if a URL exists without downloading the whole file. - We only check the URL header. """ - # see also http://stackoverflow.com/questions/2924422 - # http://stackoverflow.com/questions/1140661 - good_codes = [httplib.OK, httplib.FOUND, httplib.MOVED_PERMANENTLY] - - host, path = urlparse.urlparse(url)[1:3] # elems [1] and [2] try: - conn = httplib.HTTPConnection(host) - conn.request('HEAD', path) - return conn.getresponse().status in good_codes - except StandardError: - return None + return requests.head(url).ok + except: + return False def anon_url(*url):