mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure filename is always set and report any errors while trying to get the filename from a url.
This commit is contained in:
parent
77a9964fac
commit
5de6672807
@ -519,6 +519,7 @@ def get_download_filename(url, cookie_file=None):
|
|||||||
cj.load(cookie_file)
|
cj.load(cookie_file)
|
||||||
br.set_cookiejar(cj)
|
br.set_cookiejar(cj)
|
||||||
|
|
||||||
|
try:
|
||||||
with closing(br.open(url)) as r:
|
with closing(br.open(url)) as r:
|
||||||
disposition = r.info().get('Content-disposition', '')
|
disposition = r.info().get('Content-disposition', '')
|
||||||
for p in disposition.split(';'):
|
for p in disposition.split(';'):
|
||||||
@ -534,6 +535,10 @@ def get_download_filename(url, cookie_file=None):
|
|||||||
filename = filename[:-1]
|
filename = filename[:-1]
|
||||||
filename = urllib2_unquote(filename)
|
filename = urllib2_unquote(filename)
|
||||||
break
|
break
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
if not filename:
|
if not filename:
|
||||||
filename = r.geturl().split('/')[-1]
|
filename = r.geturl().split('/')[-1]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user