From 071b97a0de5240beaee9ac9df555a1e161e35e4c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 6 Sep 2014 10:17:01 +0530 Subject: [PATCH] Fix downloading ebooks from Project Gutenberg via the builtin browser not working because of changes to the Project Gutenberg website. Fixes #1366240 [EPUB download from Project Gutenberg not recognized, errors copying to itself](https://bugs.launchpad.net/calibre/+bug/1366240) --- src/calibre/web/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/web/__init__.py b/src/calibre/web/__init__.py index 761da488f5..ac125f40e7 100644 --- a/src/calibre/web/__init__.py +++ b/src/calibre/web/__init__.py @@ -6,10 +6,12 @@ class Recipe(object): pass def get_download_filename_from_response(response): + from urlparse import urlparse from urllib2 import unquote as urllib2_unquote filename = last_part_name = '' try: - last_part_name = response.geturl().split('/')[-1] + purl = urlparse(response.geturl()) + last_part_name = purl.path.split('/')[-1] disposition = response.info().get('Content-disposition', '') for p in disposition.split(';'): if 'filename' in p: