diff --git a/src/calibre/ebooks/oeb/polish/main.py b/src/calibre/ebooks/oeb/polish/main.py index f8070bacf9..af30ac1e30 100644 --- a/src/calibre/ebooks/oeb/polish/main.py +++ b/src/calibre/ebooks/oeb/polish/main.py @@ -15,6 +15,7 @@ from calibre.ebooks.oeb.polish.container import get_container from calibre.ebooks.oeb.polish.stats import StatsCollector from calibre.ebooks.oeb.polish.subset import subset_all_fonts, iter_subsettable_fonts from calibre.ebooks.oeb.polish.images import compress_images +from calibre.ebooks.oeb.polish.upgrade import upgrade_book from calibre.ebooks.oeb.polish.embed import embed_all_fonts from calibre.ebooks.oeb.polish.cover import set_cover from calibre.ebooks.oeb.polish.replace import smarten_punctuation @@ -33,6 +34,7 @@ ALL_OPTS = { 'smarten_punctuation':False, 'remove_unused_css':False, 'compress_images': False, + 'upgrade_book': False, } CUSTOMIZATION = { @@ -112,6 +114,10 @@ that need to parse them all.
affecting image quality. '''), +'upgrade_book': _('''\ +Upgrade the internal structures of the book, if possible. For instance, +upgrades EPUB 2 books to EPUB 3 books.
+'''), } @@ -225,6 +231,12 @@ def polish_one(ebook, opts, report, customization=None): changed = True report('') + if opts.upgrade_book: + rt(_('Upgrading book, if possible')) + if upgrade_book(ebook, report): + changed = True + report('') + return changed @@ -292,6 +304,7 @@ def option_parser(): o('--smarten-punctuation', '-p', help=CLI_HELP['smarten_punctuation']) o('--remove-unused-css', '-u', help=CLI_HELP['remove_unused_css']) o('--compress-images', '-i', help=CLI_HELP['compress_images']) + o('--upgrade-book', '-U', help=CLI_HELP['upgrade_book']) o('--verbose', help=_('Produce more verbose output, useful for debugging.'))