mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-17 23:15:08 +01:00
Refactor opf to azw3 conversion for re-use
This commit is contained in:
parent
89236b5100
commit
a67fe73a30
1 changed files with 13 additions and 10 deletions
|
|
@ -1005,6 +1005,18 @@ def do_explode(path, dest):
|
|||
|
||||
return opf, obfuscated_fonts
|
||||
|
||||
def opf_to_azw3(opf, outpath, log):
|
||||
from calibre.ebooks.conversion.plumber import Plumber, create_oebbook
|
||||
plumber = Plumber(opf, outpath, log)
|
||||
plumber.setup_options()
|
||||
inp = plugin_for_input_format('azw3')
|
||||
outp = plugin_for_output_format('azw3')
|
||||
plumber.opts.mobi_passthrough = True
|
||||
oeb = create_oebbook(default_log, opf, plumber.opts)
|
||||
set_cover(oeb)
|
||||
outp.convert(oeb, outpath, inp, plumber.opts, default_log)
|
||||
|
||||
|
||||
class AZW3Container(Container):
|
||||
|
||||
book_type = 'azw3'
|
||||
|
|
@ -1068,16 +1080,7 @@ def commit(self, outpath=None, keep_parsed=False):
|
|||
super(AZW3Container, self).commit(keep_parsed=keep_parsed)
|
||||
if outpath is None:
|
||||
outpath = self.pathtoazw3
|
||||
from calibre.ebooks.conversion.plumber import Plumber, create_oebbook
|
||||
opf = self.name_path_map[self.opf_name]
|
||||
plumber = Plumber(opf, outpath, self.log)
|
||||
plumber.setup_options()
|
||||
inp = plugin_for_input_format('azw3')
|
||||
outp = plugin_for_output_format('azw3')
|
||||
plumber.opts.mobi_passthrough = True
|
||||
oeb = create_oebbook(default_log, opf, plumber.opts)
|
||||
set_cover(oeb)
|
||||
outp.convert(oeb, outpath, inp, plumber.opts, default_log)
|
||||
opf_to_azw3(self.name_path_map[self.opf_name], outpath, self.log)
|
||||
|
||||
@property
|
||||
def path_to_ebook(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue