View Single Post
Old 10-20-2020, 12:18 PM   #398
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,045
Karma: 4604637
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Nope. Just calls calibre's convert. Literally.
Code:
from calibre.ebooks.conversion.cli import main as ebook_convert_cli_main
...
container = get_container(fn)
if container.opf_version_parsed.major >= 3:
    print("=" * 50)
    print("Found EPUB3 for %s, automatically creating a temporary EPUB2 for merging...\n"%title)
    # this temp file is deleted when the BG process quits,
    # so don't expect it to still be there.
    epub2 = PersistentTemporaryFile(prefix="epub2_",
                                    suffix=".epub",
                                    dir=args['tdir'])
    fn2 = epub2.name
    # ebook-convert epub3.epub epub2.epub --epub-version=2
    ebook_convert_cli_main(['epubmerge calling convert',fn,fn2,'--epub-version=2','--no-default-epub-cover'])
    args['inputepubfns'][j] = fn2
    print("Converted to temporary EPUB2: %s"%fn2)
JimmXinu is offline   Reply With Quote