From 7bbad887d0d6c3caa4905a2c225f9f0cf74e1142 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 May 2009 22:11:40 -0700 Subject: [PATCH] ... --- src/calibre/ebooks/pdf/input.py | 2 +- src/calibre/utils/podofo/__init__.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/pdf/input.py b/src/calibre/ebooks/pdf/input.py index e7949f36ac..06e3e7e9ae 100644 --- a/src/calibre/ebooks/pdf/input.py +++ b/src/calibre/ebooks/pdf/input.py @@ -26,7 +26,7 @@ class PDFInput(InputFormatPlugin): if self._preprocess_html_for_viewer: from calibre.ebooks.conversion.preprocess import HTMLPreProcessor prepro = HTMLPreProcessor(lambda x:x, False) - html = prepro(html) + html = prepro(html.decode('utf-8')).encode('utf-8') with open('index.html', 'wb') as index: index.write(html) diff --git a/src/calibre/utils/podofo/__init__.py b/src/calibre/utils/podofo/__init__.py index 1b68b9a00a..8654a95c04 100644 --- a/src/calibre/utils/podofo/__init__.py +++ b/src/calibre/utils/podofo/__init__.py @@ -36,8 +36,11 @@ def get_metadata(stream): job.update() server.close() if job.result is None: - raise ValueError('Failed to read metadata: PoDoFo crashed') + raise ValueError('Failed to read metadata: ' + job.details) title, authors, creator = job.result + if title == '_': + title = getattr(stream, 'name', _('Unknown')) + title = os.path.splitext(title)[0] mi = MetaInformation(title, authors) if creator: @@ -50,8 +53,7 @@ def get_metadata_(path): p.open(path) title = p.title if not title: - title = getattr(stream, 'name', _('Unknown')) - title = os.path.splitext(os.path.basename(title))[0] + title = '_' author = p.author authors = string_to_authors(author) if author else [_('Unknown')] creator = p.creator