E-book viewer: When reading a MOBI file that is actually a KF8 book, show the format as being KF8

This commit is contained in:
Kovid Goyal 2012-04-03 17:40:03 +05:30
parent 3a986cfd43
commit 9bb9ad53f1
3 changed files with 9 additions and 2 deletions

View File

@ -32,6 +32,7 @@ class MOBIInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log, def convert(self, stream, options, file_ext, log,
accelerators): accelerators):
self.is_kf8 = False
if os.environ.get('USE_MOBIUNPACK', None) is not None: if os.environ.get('USE_MOBIUNPACK', None) is not None:
pos = stream.tell() pos = stream.tell()
@ -62,6 +63,7 @@ class MOBIInput(InputFormatPlugin):
mr = Mobi8Reader(mr, log) mr = Mobi8Reader(mr, log)
opf = os.path.abspath(mr()) opf = os.path.abspath(mr())
self.encrypted_fonts = mr.encrypted_fonts self.encrypted_fonts = mr.encrypted_fonts
self.is_kf8 = True
return opf return opf
raw = parse_cache.pop('calibre_raw_mobi_markup', False) raw = parse_cache.pop('calibre_raw_mobi_markup', False)

View File

@ -217,6 +217,10 @@ class EbookIterator(object):
if hasattr(self.pathtoopf, 'manifest'): if hasattr(self.pathtoopf, 'manifest'):
self.pathtoopf = write_oebbook(self.pathtoopf, self.base) self.pathtoopf = write_oebbook(self.pathtoopf, self.base)
self.book_format = os.path.splitext(self.pathtoebook)[1][1:].upper()
if getattr(plumber.input_plugin, 'is_kf8', False):
self.book_format = 'KF8'
self.opf = getattr(plumber.input_plugin, 'optimize_opf_parsing', None) self.opf = getattr(plumber.input_plugin, 'optimize_opf_parsing', None)
if self.opf is None: if self.opf is None:
self.opf = OPF(self.pathtoopf, os.path.dirname(self.pathtoopf)) self.opf = OPF(self.pathtoopf, os.path.dirname(self.pathtoopf))

View File

@ -822,7 +822,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
as_unicode(r), det_msg=worker.traceback, show=True) as_unicode(r), det_msg=worker.traceback, show=True)
self.close_progress_indicator() self.close_progress_indicator()
else: else:
self.metadata.show_opf(self.iterator.opf, os.path.splitext(pathtoebook)[1][1:]) self.metadata.show_opf(self.iterator.opf,
self.iterator.book_format)
self.view.current_language = self.iterator.language self.view.current_language = self.iterator.language
title = self.iterator.opf.title title = self.iterator.opf.title
if not title: if not title:
@ -849,7 +850,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
self.current_book_has_toc = bool(self.iterator.toc) self.current_book_has_toc = bool(self.iterator.toc)
self.current_title = title self.current_title = title
self.setWindowTitle(self.base_window_title+' - '+title + self.setWindowTitle(self.base_window_title+' - '+title +
' [%s]'%os.path.splitext(pathtoebook)[1][1:].upper()) ' [%s]'%self.iterator.book_format)
self.pos.setMaximum(sum(self.iterator.pages)) self.pos.setMaximum(sum(self.iterator.pages))
self.pos.setSuffix(' / %d'%sum(self.iterator.pages)) self.pos.setSuffix(' / %d'%sum(self.iterator.pages))
self.vertical_scrollbar.setMinimum(100) self.vertical_scrollbar.setMinimum(100)