From e65643280254cd4752c8fb0b3a7f693932b44bbc Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 4 Jul 2026 22:56:13 -0700 Subject: [PATCH] Add command 'setcover'. --- epubfile.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/epubfile.py b/epubfile.py index cc72a49..2d57a7d 100644 --- a/epubfile.py +++ b/epubfile.py @@ -1627,6 +1627,11 @@ def normalize_argparse(args): pipeable.stdout(epub.absolute_path) return 0 +def setcover_argparse(args): + book = Epub(args.epub) + book.set_cover_image(args.cover_id) + return 0 + def setfont(book, new_font, autoyes=False): css_id = 'epubfile_setfont' css_basename = 'epubfile_setfont.css' @@ -1927,6 +1932,24 @@ def main(argv): ################################################################################################ + p_setcover = subparsers.add_parser( + 'setcover', + description=''' + Set the book's cover image to the specified manifest ID. + + You can use the manifest command first to see what's in the book. + ''', + ) + p_setcover.add_argument( + 'epub', + ) + p_setcover.add_argument( + 'cover_id', + ) + p_setcover.set_defaults(func=setcover_argparse) + + ################################################################################################ + p_setfont = subparsers.add_parser( 'setfont', description='''