mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
URL expansion and audio playback should work well together now. When calling get method, stream parameter is set to True, so the body is not downloaded. We work with response headers, the only thing we need
This commit is contained in:
parent
6ba1fe9eac
commit
2fb88924fd
@ -28,7 +28,9 @@ class URLShortener (object):
|
|||||||
else:
|
else:
|
||||||
return r.headers['location']
|
return r.headers['location']
|
||||||
else: # if the head method does not work, use get instead. Performance may decrease
|
else: # if the head method does not work, use get instead. Performance may decrease
|
||||||
r=requests.get(url, allow_redirects=False)
|
r=requests.get(url, allow_redirects=False, stream=True)
|
||||||
|
# release the connection without downloading the content, we only need the response headers
|
||||||
|
r.close()
|
||||||
return r.headers['location']
|
return r.headers['location']
|
||||||
except:
|
except:
|
||||||
return url #we cannot expand
|
return url #we cannot expand
|
||||||
|
Loading…
Reference in New Issue
Block a user