mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add support for viewing and converting KEPUB files
This commit is contained in:
parent
91731ab5b8
commit
fce03aaa38
@ -18,7 +18,7 @@ What formats does calibre support conversion to/from?
|
|||||||
calibre supports the conversion of many input formats to many output formats.
|
calibre supports the conversion of many input formats to many output formats.
|
||||||
It can convert every input format in the following list, to every output format.
|
It can convert every input format in the following list, to every output format.
|
||||||
|
|
||||||
*Input Formats:* AZW, AZW3, AZW4, CBZ, CBR, CB7, CBC, CHM, DJVU, DOCX, EPUB, FB2, FBZ, HTML, HTMLZ, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZ
|
*Input Formats:* AZW, AZW3, AZW4, CBZ, CBR, CB7, CBC, CHM, DJVU, DOCX, EPUB, FB2, FBZ, HTML, HTMLZ, KEPUB, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZ
|
||||||
|
|
||||||
*Output Formats:* AZW3, EPUB, DOCX, FB2, HTMLZ, OEB, LIT, LRF, MOBI, PDB, PMLZ, RB, PDF, RTF, SNB, TCR, TXT, TXTZ, ZIP
|
*Output Formats:* AZW3, EPUB, DOCX, FB2, HTMLZ, OEB, LIT, LRF, MOBI, PDB, PMLZ, RB, PDF, RTF, SNB, TCR, TXT, TXTZ, ZIP
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ It can convert every input format in the following list, to every output format.
|
|||||||
|
|
||||||
What are the best source formats to convert?
|
What are the best source formats to convert?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
In order of decreasing preference: LIT, MOBI, AZW, EPUB, AZW3, FB2, FBZ, DOCX, HTML, PRC, ODT, RTF, PDB, TXT, PDF
|
In order of decreasing preference: LIT, MOBI, AZW, EPUB, KEPUB, AZW3, FB2, FBZ, DOCX, HTML, PRC, ODT, RTF, PDB, TXT, PDF
|
||||||
|
|
||||||
I converted a PDF file, but the result has various problems?
|
I converted a PDF file, but the result has various problems?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -33,7 +33,7 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
name = 'EPUB Input'
|
name = 'EPUB Input'
|
||||||
author = 'Kovid Goyal'
|
author = 'Kovid Goyal'
|
||||||
description = _('Convert EPUB files (.epub) to HTML')
|
description = _('Convert EPUB files (.epub) to HTML')
|
||||||
file_types = {'epub'}
|
file_types = {'epub', 'kepub'}
|
||||||
output_encoding = None
|
output_encoding = None
|
||||||
commit_name = 'epub_input'
|
commit_name = 'epub_input'
|
||||||
|
|
||||||
@ -261,6 +261,7 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
from calibre.ebooks import DRMError
|
from calibre.ebooks import DRMError
|
||||||
from calibre.ebooks.metadata.opf2 import OPF
|
from calibre.ebooks.metadata.opf2 import OPF
|
||||||
from calibre.utils.zipfile import ZipFile
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
is_kepub = file_ext.lower() == 'kepub'
|
||||||
try:
|
try:
|
||||||
zf = ZipFile(stream)
|
zf = ZipFile(stream)
|
||||||
zf.extractall(os.getcwd())
|
zf.extractall(os.getcwd())
|
||||||
@ -283,6 +284,15 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
if opf is None:
|
if opf is None:
|
||||||
raise ValueError(f'{path} is not a valid EPUB file (could not find opf)')
|
raise ValueError(f'{path} is not a valid EPUB file (could not find opf)')
|
||||||
|
|
||||||
|
if is_kepub and not self.for_viewer:
|
||||||
|
log('Removing Kobo markup...')
|
||||||
|
from calibre.ebooks.oeb.polish.container import Container
|
||||||
|
from calibre.ebooks.oeb.polish.kepubify import unkepubify_container
|
||||||
|
container = Container(os.getcwd(), opf, log)
|
||||||
|
unkepubify_container(container)
|
||||||
|
container.commit()
|
||||||
|
del container
|
||||||
|
|
||||||
opf = os.path.relpath(opf, os.getcwd())
|
opf = os.path.relpath(opf, os.getcwd())
|
||||||
parts = os.path.split(opf)
|
parts = os.path.split(opf)
|
||||||
opf = OPF(opf, os.path.dirname(os.path.abspath(opf)))
|
opf = OPF(opf, os.path.dirname(os.path.abspath(opf)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user