mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
...
This commit is contained in:
parent
f1bda707e9
commit
28cdb7c93f
@ -285,20 +285,7 @@ class EPUBInput(InputFormatPlugin):
|
||||
raise ValueError(f'{path} is not a valid EPUB file (could not find opf)')
|
||||
|
||||
if is_kepub:
|
||||
from calibre.ebooks.oeb.polish.container import Container
|
||||
from calibre.ebooks.oeb.polish.errors import drm_message
|
||||
from calibre.ebooks.oeb.polish.kepubify import check_for_kobo_drm, unkepubify_container
|
||||
container = Container(os.getcwd(), opf, log)
|
||||
if self.for_viewer:
|
||||
log('Checking for Kobo DRM...')
|
||||
with drm_message(_('The file {} is locked with DRM. It cannot be viewed').format(path)):
|
||||
check_for_kobo_drm(container)
|
||||
else:
|
||||
log('Removing Kobo markup...')
|
||||
with drm_message(_('The file {} is locked with DRM. It cannot be converted').format(path)):
|
||||
unkepubify_container(container)
|
||||
container.commit()
|
||||
del container
|
||||
self.unkepubify(path, opf, log)
|
||||
|
||||
opf = os.path.relpath(opf, os.getcwd())
|
||||
parts = os.path.split(opf)
|
||||
@ -370,6 +357,21 @@ class EPUBInput(InputFormatPlugin):
|
||||
|
||||
return os.path.abspath('content.opf')
|
||||
|
||||
def unkepubify(self, path: str, opf: str, log) -> None:
|
||||
from calibre.ebooks.oeb.polish.container import Container
|
||||
from calibre.ebooks.oeb.polish.errors import drm_message
|
||||
from calibre.ebooks.oeb.polish.kepubify import check_for_kobo_drm, unkepubify_container
|
||||
container = Container(os.getcwd(), opf, log)
|
||||
if self.for_viewer:
|
||||
log('Checking for Kobo DRM...')
|
||||
with drm_message(_('The file {} is locked with DRM. It cannot be viewed').format(path)):
|
||||
check_for_kobo_drm(container)
|
||||
else:
|
||||
log('Removing Kobo markup...')
|
||||
with drm_message(_('The file {} is locked with DRM. It cannot be converted').format(path)):
|
||||
unkepubify_container(container)
|
||||
container.commit()
|
||||
|
||||
def convert_epub3_nav(self, nav_path, opf, log, opts):
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user