mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Minor fixes
This commit is contained in:
parent
f4cab917ea
commit
0c78971db1
@ -5,17 +5,12 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import textwrap, cStringIO
|
||||
import textwrap
|
||||
from urllib import unquote
|
||||
|
||||
from lxml import etree
|
||||
try:
|
||||
from PIL import Image as PILImage
|
||||
PILImage
|
||||
except ImportError:
|
||||
import Image as PILImage
|
||||
|
||||
from calibre import guess_type
|
||||
from calibre.utils.magick.draw import identify_data
|
||||
|
||||
class CoverManager(object):
|
||||
|
||||
@ -126,9 +121,7 @@ class CoverManager(object):
|
||||
if x.href == urlnormalize(href):
|
||||
try:
|
||||
raw = x.data
|
||||
f = cStringIO.StringIO(raw)
|
||||
im = PILImage.open(f)
|
||||
return im.size
|
||||
return identify_data(raw)[:2]
|
||||
except:
|
||||
self.log.exception('Failed to read image dimensions')
|
||||
return None, None
|
||||
|
@ -101,6 +101,8 @@ class PDFOutput(OutputFormatPlugin):
|
||||
for item in m:
|
||||
if item.href == urlnormalize(href):
|
||||
self.cover_data = item.data
|
||||
if not isinstance(self.cover_data, basestring):
|
||||
self.cover_data = None
|
||||
|
||||
def convert_text(self, oeb_book):
|
||||
self.log.debug('Serializing oeb input to disk for processing...')
|
||||
|
@ -176,6 +176,7 @@ class DoDownload(QObject):
|
||||
set_metadata=set_metadata,
|
||||
get_social_metadata=get_social_metadata)
|
||||
self.timer = QTimer(self)
|
||||
self.get_covers = get_covers
|
||||
self.timer.timeout.connect(self.do_one, type=Qt.QueuedConnection)
|
||||
self.db = db
|
||||
self.updated = set([])
|
||||
@ -222,7 +223,10 @@ class DoDownload(QObject):
|
||||
id_, typ, ok, title = r
|
||||
what = _('cover') if typ == 'cover' else _('metadata')
|
||||
which = _('Downloaded') if ok else _('Failed to get')
|
||||
self.pd.set_msg(_('%s %s for: %s') % (which, what, title))
|
||||
if self.get_covers or typ != 'cover' or ok:
|
||||
# Do not show message when cover fetch fails if user didn't ask to
|
||||
# download covers
|
||||
self.pd.set_msg(_('%s %s for: %s') % (which, what, title))
|
||||
self.pd.value += 1
|
||||
if ok:
|
||||
self.updated.add(id_)
|
||||
|
Loading…
x
Reference in New Issue
Block a user