Browse Source

feat: azw3 format support

master
Dnomd343 2 years ago
parent
commit
36f2787207
  1. 4
      src/release/release.py
  2. 1
      src/release/utils/__init__.py
  3. 1
      src/release/utils/common.py
  4. 9
      src/release/utils/release.py

4
src/release/release.py

@ -4,6 +4,7 @@
from utils import loadBook
from utils import txtRelease
from utils import jsonRelease
from utils import azw3Release
from utils import epubRelease
from utils import mobiRelease
from utils import staticRelease
@ -13,6 +14,7 @@ from utils import gitbookRelease
releaseEntry = {
'txt': txtRelease,
'json': jsonRelease,
'azw3': azw3Release,
'epub': epubRelease,
'mobi': mobiRelease,
'static': staticRelease,
@ -23,4 +25,4 @@ releaseEntry = {
releaseSrc = 'rc-5'
metadata, content = loadBook(releaseSrc)
releaseEntry['epub'](metadata, content)
releaseEntry['azw3'](metadata, content)

1
src/release/utils/__init__.py

@ -5,6 +5,7 @@ from .common import loadBook
from .release import txtRelease
from .release import jsonRelease
from .release import azw3Release
from .release import epubRelease
from .release import mobiRelease
from .release import staticRelease

1
src/release/utils/common.py

@ -17,6 +17,7 @@ metadataFile = os.path.join(rootPath, './assets/metadata.json')
releaseInfo = { # release file name
'json': 'XXRS.json',
'txt': '栩栩若生.txt',
'azw3': '栩栩若生.azw3',
'epub': '栩栩若生.epub',
'mobi': '栩栩若生.mobi',
'calibre': 'xxrs.zip',

9
src/release/utils/release.py

@ -225,3 +225,12 @@ def mobiRelease(metadata: dict, content: dict, mobiType: int = 1) -> None:
calibreBuild(tempDir.name, '.mobi', mobiOption, metadata, content)
shutil.copy(os.path.join(tempDir.name, './xxrs.mobi'), releaseInfo['mobi'])
tempDir.cleanup()
def azw3Release(metadata: dict, content: dict) -> None:
tempDir = tempfile.TemporaryDirectory() # access temporary directory
print('Calibre AZW3 Build -> %s' % tempDir.name)
calibreBuild(tempDir.name, '.azw3', [], metadata, content)
# TODO: change `[EBOK]` as `[PDOC]`
shutil.copy(os.path.join(tempDir.name, './xxrs.azw3'), releaseInfo['azw3'])
tempDir.cleanup()

Loading…
Cancel
Save