- subprocess.check_call(['ebook-convert', epub.get_filename(), output_file.name,
- '--no-inline-toc', '--cover=%s' % cover_file.name], **kwargs)
- os.unlink(cover_file.name)
- return OutputFile.from_filename(output_file.name)
\ No newline at end of file
+
+ if use_kindlegen:
+ output_file_basename = os.path.basename(output_file.name)
+ subprocess.check_call(['kindlegen', '-c2', epub.get_filename(),
+ '-o', output_file_basename], **kwargs)
+ else:
+ subprocess.check_call(['ebook-convert', epub.get_filename(),
+ output_file.name, '--no-inline-toc',
+ '--mobi-file-type=both',
+ '--mobi-ignore-margins'], **kwargs)
+ return OutputFile.from_filename(output_file.name)