mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Allow running kepubify/unkepubify via calibre-debug
This commit is contained in:
parent
c9a4bb9525
commit
ee44d2ccd4
@ -121,6 +121,10 @@ as a shebang in scripts, like this:
|
|||||||
'calibre-debug --diff file1 file2'))
|
'calibre-debug --diff file1 file2'))
|
||||||
parser.add_option('--default-programs', default=None, choices=['register', 'unregister'],
|
parser.add_option('--default-programs', default=None, choices=['register', 'unregister'],
|
||||||
help=_('(Un)register calibre from Windows Default Programs.') + ' --default-programs=(register|unregister)')
|
help=_('(Un)register calibre from Windows Default Programs.') + ' --default-programs=(register|unregister)')
|
||||||
|
parser.add_option('--kepubify', default=False, action='store_true', help=_(
|
||||||
|
'Convert the specified EPUB file to KEPUB without doing a full conversion. This is what the Kobo driver does when sending files to the device.'))
|
||||||
|
parser.add_option('--un-kepubify', default=False, action='store_true', help=_(
|
||||||
|
'Convert the specified KEPUB file to EPUB without doing a full conversion. This is what the Kobo driver does when importing files from the device.'))
|
||||||
parser.add_option('--fix-multiprocessing', default=False, action='store_true',
|
parser.add_option('--fix-multiprocessing', default=False, action='store_true',
|
||||||
help=_('For internal use'))
|
help=_('For internal use'))
|
||||||
|
|
||||||
@ -310,6 +314,12 @@ def main(args=sys.argv):
|
|||||||
elif opts.import_calibre_data:
|
elif opts.import_calibre_data:
|
||||||
from calibre.utils.exim import run_importer
|
from calibre.utils.exim import run_importer
|
||||||
run_importer()
|
run_importer()
|
||||||
|
elif opts.kepubify:
|
||||||
|
from calibre.ebooks.oeb.polish.kepubify import kepubify_main
|
||||||
|
kepubify_main(args)
|
||||||
|
elif opts.un_kepubify:
|
||||||
|
from calibre.ebooks.oeb.polish.kepubify import unkepubify_main
|
||||||
|
unkepubify_main(args)
|
||||||
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}:
|
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}:
|
||||||
run_script(args[1], args[2:])
|
run_script(args[1], args[2:])
|
||||||
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}:
|
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}:
|
||||||
|
@ -605,11 +605,23 @@ def develop():
|
|||||||
input('Press Enter to quit')
|
input('Press Enter to quit')
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def kepubify_main(args=sys.argv):
|
||||||
for path in args[1:]:
|
for path in args[1:]:
|
||||||
outpath = kepubify_path(path)
|
outpath = ''
|
||||||
print(f'{path} converted and saved as: {outpath}')
|
if path.endswith('.epub'):
|
||||||
|
outpath = path[:-4] + 'kepub.epub'
|
||||||
|
kepub_path = kepubify_path(path, outpath, allow_overwrite=True)
|
||||||
|
print(f'{path} converted to: {kepub_path}')
|
||||||
|
|
||||||
|
|
||||||
|
def unkepubify_main(args=sys.argv):
|
||||||
|
for path in args[1:]:
|
||||||
|
outpath = ''
|
||||||
|
if path.endswith('.kepub.epub'):
|
||||||
|
outpath = path[:-len('kepub.epub')] + 'epub'
|
||||||
|
kepub_path = unkepubify_path(path, outpath, allow_overwrite=True)
|
||||||
|
print(f'{path} converted to: {kepub_path}')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
kepubify_main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user