Skip to content

Commit

Permalink
Fixed fetching files on newer versions of Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Sworddragon committed Jun 19, 2014
1 parent e1739f5 commit 2f454b2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions scripts/twlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
url_lib = urllib.request

def fetch_file(url):
print("trying %s" % url)
try:
print("trying %s" % url)
local = dict(url_lib.urlopen(url).info())["content-disposition"].split("=")[1]
local = dict(url_lib.urlopen(url).info())
if "Content-Disposition" in local:
key_name = "Content-Disposition"
elif "content-disposition" in local:
key_name = "content-disposition"
else:
return False
local = local[key_name].split("=")[1]
url_lib.urlretrieve(url, local)
return local
except:
except IOError:
return False

0 comments on commit 2f454b2

Please sign in to comment.