Fix bug #799367: Could not download ebooks from store

This commit is contained in:
John Schember 2011-06-20 19:01:12 -04:00
parent 0de3e26002
commit a34a2a0e05

View File

@ -591,8 +591,10 @@ def get_download_filename(url, cookie_file=None):
cj.load(cookie_file)
br.set_cookiejar(cj)
last_part_name = ''
try:
with closing(br.open(url)) as r:
last_part_name = r.geturl().split('/')[-1]
disposition = r.info().get('Content-disposition', '')
for p in disposition.split(';'):
if 'filename' in p:
@ -612,7 +614,7 @@ def get_download_filename(url, cookie_file=None):
traceback.print_exc()
if not filename:
filename = r.geturl().split('/')[-1]
filename = last_part_name
return filename