mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-22 01:23:43 +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 py2 octal literals into the new py2/3 syntax
|
||||||
* Change Kodi notifier to use requests as opposed to urllib
|
* Change Kodi notifier to use requests as opposed to urllib
|
||||||
* Change to consolidate scene exceptions and name cache code
|
* Change to consolidate scene exceptions and name cache code
|
||||||
|
* Change check_url function to use requests instead of httplib library
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)
|
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)
|
||||||
|
|
|
@ -28,7 +28,6 @@ import tempfile
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import hashlib
|
import hashlib
|
||||||
import httplib
|
|
||||||
import urlparse
|
import urlparse
|
||||||
import uuid
|
import uuid
|
||||||
import base64
|
import base64
|
||||||
|
@ -788,19 +787,11 @@ def get_lan_ip():
|
||||||
def check_url(url):
|
def check_url(url):
|
||||||
"""
|
"""
|
||||||
Check if a URL exists without downloading the whole file.
|
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:
|
try:
|
||||||
conn = httplib.HTTPConnection(host)
|
return requests.head(url).ok
|
||||||
conn.request('HEAD', path)
|
except:
|
||||||
return conn.getresponse().status in good_codes
|
return False
|
||||||
except StandardError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def anon_url(*url):
|
def anon_url(*url):
|
||||||
|
|
Loading…
Reference in a new issue