KF8 Output: Split on page breaks to produce KF8 files that work better with viewers that dont support CSS page breaks. Also remove no longer used MOBI_UNPACK code from MOBI input

This commit is contained in:
Kovid Goyal 2012-04-26 22:51:06 +05:30
parent c7ff97e1a0
commit 7468f24996
2 changed files with 7 additions and 24 deletions

View File

@ -7,22 +7,6 @@ import os
from calibre.customize.conversion import InputFormatPlugin
def run_mobi_unpack(stream, options, log, accelerators):
from mobiunpack.mobi_unpack import Mobi8Reader
from calibre.customize.ui import plugin_for_input_format
from calibre.ptempfile import PersistentTemporaryDirectory
wdir = PersistentTemporaryDirectory('_unpack_space')
m8r = Mobi8Reader(stream, wdir)
if m8r.isK8():
epub_path = m8r.processMobi8()
epub_input = plugin_for_input_format('epub')
for opt in epub_input.options:
setattr(options, opt.option.name, opt.recommended_value)
options.input_encoding = m8r.getCodec()
return epub_input.convert(open(epub_path,'rb'), options,
'epub', log, accelerators)
class MOBIInput(InputFormatPlugin):
name = 'MOBI Input'
@ -34,14 +18,6 @@ class MOBIInput(InputFormatPlugin):
accelerators):
self.is_kf8 = False
if os.environ.get('USE_MOBIUNPACK', None) is not None:
pos = stream.tell()
try:
return run_mobi_unpack(stream, options, log, accelerators)
except Exception:
log.exception('mobi_unpack code not working')
stream.seek(pos)
from calibre.ebooks.mobi.reader.mobi6 import MobiReader
from lxml import html
parse_cache = {}

View File

@ -174,6 +174,13 @@ class MOBIOutput(OutputFormatPlugin):
add_fonts=create_kf8)
self.check_for_periodical()
if create_kf8:
# Split on pagebreaks so that the resulting KF8 works better with
# calibre's viewer, which does not support CSS page breaks
from calibre.ebooks.oeb.transforms.split import Split
Split()(self.oeb, self.opts)
kf8 = self.create_kf8(resources, for_joint=mobi_type=='both'
) if create_kf8 else None
if mobi_type == 'new':