Browse Source

feat: automatic modification of CDE mark

master
Dnomd343 2 years ago
parent
commit
dfd6b362ea
  1. BIN
      src/release/utils/mobi-meta.jar
  2. 33
      src/release/utils/release.py

BIN
src/release/utils/mobi-meta.jar

Binary file not shown.

33
src/release/utils/release.py

@ -228,29 +228,28 @@ def mobiRelease(metadata: dict, content: dict, mobiType: int = 1) -> None:
def setPdocMark(originFile: str, targetFile: str) -> None: def setPdocMark(originFile: str, targetFile: str) -> None:
jdkImage = 'openjdk:17-alpine'
tempDir = tempfile.TemporaryDirectory() # access temporary directory tempDir = tempfile.TemporaryDirectory() # access temporary directory
suffix = os.path.splitext(originFile)[-1]
shutil.copy(originFile, os.path.join(tempDir.name, 'xxrs.azw3')) shutil.copy(originFile, os.path.join(tempDir.name, 'xxrs%s' % suffix))
shutil.copy(
# TODO: copy originFile -> tempDir.name os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mobi-meta.jar'), # script folder
# remember changing the originFile suffix os.path.join(tempDir.name, 'mobi-meta.jar')
)
# TODO: fetch convert jar file (https://github.com/dnomd343/mobi-meta/releases/latest/download/mobi-meta.jar) dockerCommand = 'docker run --rm -v %(src)s:%(tmp)s --workdir %(tmp)s --entrypoint sh %(img)s -c "%(cmd)s"' % {
'src': tempDir.name,
# TODO: run openjdk container and generate new eBook (openjdk:17-alpine) 'tmp': '/xxrs/',
# java -jar mobi-meta.jar edit {xxrs.azw3} {xxrs_new.azw3} --pdoc 'img': jdkImage,
'cmd': 'java -jar mobi-meta.jar edit xxrs%s xxrs_mod%s --pdoc' % (suffix, suffix),
# TODO: copy output file as targetFile }
subprocess.Popen(dockerCommand, shell = True).wait() # blocking wait
pass shutil.copy(os.path.join(tempDir.name, 'xxrs_mod%s' % suffix), targetFile)
tempDir.cleanup()
def azw3Release(metadata: dict, content: dict) -> None: def azw3Release(metadata: dict, content: dict) -> None:
tempDir = tempfile.TemporaryDirectory() # access temporary directory tempDir = tempfile.TemporaryDirectory() # access temporary directory
print('Calibre AZW3 Build -> %s' % tempDir.name) print('Calibre AZW3 Build -> %s' % tempDir.name)
calibreBuild(tempDir.name, '.azw3', ['--mobi-toc-at-start'], metadata, content) calibreBuild(tempDir.name, '.azw3', ['--mobi-toc-at-start'], metadata, content)
# TODO: change `[EBOK]` as `[PDOC]`
setPdocMark(os.path.join(tempDir.name, './xxrs.azw3'), releaseInfo['azw3']) setPdocMark(os.path.join(tempDir.name, './xxrs.azw3'), releaseInfo['azw3'])
tempDir.cleanup() tempDir.cleanup()

Loading…
Cancel
Save