Compare commits
3 commits
6f1dbf407e
...
e656432802
| Author | SHA1 | Date | |
|---|---|---|---|
| e656432802 | |||
| 43d5195367 | |||
| 8608ffaf75 |
1 changed files with 45 additions and 0 deletions
45
epubfile.py
45
epubfile.py
|
|
@ -14,6 +14,7 @@ import tempfile
|
||||||
import tinycss2
|
import tinycss2
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
|
import warnings
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from voussoirkit import betterhelp
|
from voussoirkit import betterhelp
|
||||||
|
|
@ -24,6 +25,8 @@ from voussoirkit import vlogging
|
||||||
|
|
||||||
log = vlogging.get_logger(__name__, 'epubfile')
|
log = vlogging.get_logger(__name__, 'epubfile')
|
||||||
|
|
||||||
|
warnings.filterwarnings("ignore", category=bs4.XMLParsedAsHTMLWarning)
|
||||||
|
|
||||||
HTML_LINK_PROPERTIES = {
|
HTML_LINK_PROPERTIES = {
|
||||||
'a': ['href'],
|
'a': ['href'],
|
||||||
'audio': ['src'],
|
'audio': ['src'],
|
||||||
|
|
@ -1503,6 +1506,12 @@ def holdit_argparse(args):
|
||||||
pipeable.stdout(epub.absolute_path)
|
pipeable.stdout(epub.absolute_path)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def manifest_argparse(args):
|
||||||
|
book = Epub(args.epub)
|
||||||
|
for item in book.get_manifest_items(soup=True):
|
||||||
|
pipeable.stdout(str(item))
|
||||||
|
return 0
|
||||||
|
|
||||||
def merge(
|
def merge(
|
||||||
input_filepaths,
|
input_filepaths,
|
||||||
demote_headers=False,
|
demote_headers=False,
|
||||||
|
|
@ -1618,6 +1627,11 @@ def normalize_argparse(args):
|
||||||
pipeable.stdout(epub.absolute_path)
|
pipeable.stdout(epub.absolute_path)
|
||||||
return 0
|
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):
|
def setfont(book, new_font, autoyes=False):
|
||||||
css_id = 'epubfile_setfont'
|
css_id = 'epubfile_setfont'
|
||||||
css_basename = 'epubfile_setfont.css'
|
css_basename = 'epubfile_setfont.css'
|
||||||
|
|
@ -1811,6 +1825,19 @@ def main(argv):
|
||||||
|
|
||||||
################################################################################################
|
################################################################################################
|
||||||
|
|
||||||
|
p_manifest = subparsers.add_parser(
|
||||||
|
'manifest',
|
||||||
|
description='''
|
||||||
|
Print all of the manifest entries in the book.
|
||||||
|
''',
|
||||||
|
)
|
||||||
|
p_manifest.add_argument(
|
||||||
|
'epub',
|
||||||
|
)
|
||||||
|
p_manifest.set_defaults(func=manifest_argparse)
|
||||||
|
|
||||||
|
################################################################################################
|
||||||
|
|
||||||
p_merge = subparsers.add_parser(
|
p_merge = subparsers.add_parser(
|
||||||
'merge',
|
'merge',
|
||||||
description='''
|
description='''
|
||||||
|
|
@ -1905,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(
|
p_setfont = subparsers.add_parser(
|
||||||
'setfont',
|
'setfont',
|
||||||
description='''
|
description='''
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue