mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Handle special case for Dropbox links when expanding URLS
This commit is contained in:
parent
11ca3a2190
commit
11703f50fe
@ -22,6 +22,16 @@ class URLShortener (object):
|
||||
def unshorten(self, url):
|
||||
try:
|
||||
r=requests.head(url)
|
||||
return r.headers['location']
|
||||
if 'location' in r.headers.keys():
|
||||
if 'dropbox.com' in r.headers['location']:
|
||||
return handle_dropbox(r.headers['location'])
|
||||
else:
|
||||
return r.headers['location']
|
||||
except:
|
||||
return url #we cannot expand
|
||||
|
||||
def handle_dropbox(url):
|
||||
if url.endswith("dl=1"):
|
||||
return url
|
||||
else:
|
||||
return url.replace("dl=0", "dl=1")
|
||||
|
Loading…
Reference in New Issue
Block a user