Tweak book: Fix handling of covers when tweaking KF8 books

This commit is contained in:
Kovid Goyal 2012-05-17 12:28:03 +05:30
parent 2b3bf30dc9
commit 9918fb99a8

View File

@ -71,6 +71,14 @@ def explode(path, dest, question=lambda x:True):
return fork_job('calibre.ebooks.mobi.tweak', 'do_explode', args=(path, return fork_job('calibre.ebooks.mobi.tweak', 'do_explode', args=(path,
dest), no_output=True)['result'] dest), no_output=True)['result']
def set_cover(oeb):
if 'cover' not in oeb.guide: return
cover = oeb.guide['cover']
if cover.href in oeb.manifest.hrefs:
item = oeb.manifest.hrefs[cover.href]
oeb.metadata.clear('cover')
oeb.metadata.add('cover', item.id)
def do_rebuild(opf, dest_path): def do_rebuild(opf, dest_path):
plumber = Plumber(opf, dest_path, default_log) plumber = Plumber(opf, dest_path, default_log)
plumber.setup_options() plumber.setup_options()
@ -79,6 +87,7 @@ def do_rebuild(opf, dest_path):
plumber.opts.mobi_passthrough = True plumber.opts.mobi_passthrough = True
oeb = create_oebbook(default_log, opf, plumber.opts) oeb = create_oebbook(default_log, opf, plumber.opts)
set_cover(oeb)
outp.convert(oeb, dest_path, inp, plumber.opts, default_log) outp.convert(oeb, dest_path, inp, plumber.opts, default_log)
def rebuild(src_dir, dest_path): def rebuild(src_dir, dest_path):