Fix #1846 (Calibre can not download images with space in their name)

This commit is contained in:
Kovid Goyal 2009-02-13 10:42:23 -08:00
parent 578cc310c2
commit e60810d330
2 changed files with 6 additions and 2 deletions

View file

@ -7,6 +7,8 @@
'''
import urllib
from calibre.web.feeds.news import BasicNewsRecipe
class Granma(BasicNewsRecipe):
title = 'Diario Granma'
__author__ = 'Darko Miletic'
@ -49,4 +51,4 @@ def preprocess_html(self, soup):
for item in soup.findAll(style=True):
del item['style']
return soup

View file

@ -8,7 +8,7 @@
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 @@ def fetch_url(self, url):
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: