mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change check_url function to use requests instead of httplib library
This commit is contained in:
parent
038ecd2307
commit
a4cc931abc
2 changed files with 4 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue