From e60810d330861bbda60242bd30f17c08c1139e00 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 13 Feb 2009 10:42:23 -0800 Subject: [PATCH] Fix #1846 (Calibre can not download images with space in their name) --- src/calibre/web/feeds/recipes/recipe_granma.py | 4 +++- src/calibre/web/fetch/simple.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/web/feeds/recipes/recipe_granma.py b/src/calibre/web/feeds/recipes/recipe_granma.py index c758477a52..958d95c2df 100644 --- a/src/calibre/web/feeds/recipes/recipe_granma.py +++ b/src/calibre/web/feeds/recipes/recipe_granma.py @@ -7,6 +7,8 @@ granma.cubaweb.cu ''' import urllib +from calibre.web.feeds.news import BasicNewsRecipe + class Granma(BasicNewsRecipe): title = 'Diario Granma' __author__ = 'Darko Miletic' @@ -49,4 +51,4 @@ class Granma(BasicNewsRecipe): for item in soup.findAll(style=True): del item['style'] return soup - \ No newline at end of file + diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index f846c7f2e5..4da3f4019c 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -8,7 +8,7 @@ Fetch a webpage and its links recursively. The webpages are saved to disk in UTF-8 encoding with any charset declarations removed. ''' import sys, socket, os, urlparse, logging, re, time, copy, urllib2, threading, traceback -from urllib import url2pathname +from urllib import url2pathname, quote from threading import RLock from httplib import responses from PIL import Image @@ -179,6 +179,8 @@ class RecursiveFetcher(object, LoggingInterface): delta = time.time() - self.last_fetch_at if delta < self.delay: time.sleep(delta) + if re.search(r'\s+', url) is not None: + url = quote(url) with self.browser_lock: try: with closing(self.browser.open(url)) as f: