diff --git a/src/release/release.py b/src/release/release.py index 2e5090a..75be847 100755 --- a/src/release/release.py +++ b/src/release/release.py @@ -4,6 +4,7 @@ from utils import loadBook from utils import txtRelease from utils import jsonRelease +from utils import epubRelease from utils import mobiRelease from utils import staticRelease from utils import calibreRelease @@ -12,6 +13,7 @@ from utils import gitbookRelease releaseEntry = { 'txt': txtRelease, 'json': jsonRelease, + 'epub': epubRelease, 'mobi': mobiRelease, 'static': staticRelease, 'calibre': calibreRelease, @@ -21,4 +23,4 @@ releaseEntry = { releaseSrc = 'rc-5' metadata, content = loadBook(releaseSrc) -releaseEntry['mobi'](metadata, content) +releaseEntry['epub'](metadata, content) diff --git a/src/release/utils/__init__.py b/src/release/utils/__init__.py index d6076e4..1ecaf43 100644 --- a/src/release/utils/__init__.py +++ b/src/release/utils/__init__.py @@ -5,6 +5,7 @@ from .common import loadBook from .release import txtRelease from .release import jsonRelease +from .release import epubRelease from .release import mobiRelease from .release import staticRelease from .release import calibreRelease diff --git a/src/release/utils/common.py b/src/release/utils/common.py index de801d9..497a9c3 100644 --- a/src/release/utils/common.py +++ b/src/release/utils/common.py @@ -32,6 +32,10 @@ resourceInfo = { # resource download links 'https://res.343.re/Share/XXRS/%E6%A0%A9%E6%A0%A9%E8%8B%A5%E7%94%9F.txt', 'https://cdn.dnomd343.top/xxrs/%E6%A0%A9%E6%A0%A9%E8%8B%A5%E7%94%9F.txt', ], + 'EPUB 下载': [ + 'https://res.343.re/Share/XXRS/%E6%A0%A9%E6%A0%A9%E8%8B%A5%E7%94%9F.epub', + 'https://cdn.dnomd343.top/xxrs/%E6%A0%A9%E6%A0%A9%E8%8B%A5%E7%94%9F.epub', + ], 'MOBI 下载': [ 'https://res.343.re/Share/XXRS/%E6%A0%A9%E6%A0%A9%E8%8B%A5%E7%94%9F.mobi', 'https://cdn.dnomd343.top/xxrs/%E6%A0%A9%E6%A0%A9%E8%8B%A5%E7%94%9F.mobi', diff --git a/src/release/utils/release.py b/src/release/utils/release.py index 9bde976..5615f8a 100644 --- a/src/release/utils/release.py +++ b/src/release/utils/release.py @@ -200,6 +200,14 @@ def calibreBuild(workDir: str, suffix: str, extOption: list, metadata: dict, con subprocess.Popen(buildCommand, shell = True).wait() # blocking wait +def epubRelease(metadata: dict, content: dict) -> None: + tempDir = tempfile.TemporaryDirectory() # access temporary directory + print('Calibre EPUB Build -> %s' % tempDir.name) + calibreBuild(tempDir.name, '.epub', [], metadata, content) + shutil.copy(os.path.join(tempDir.name, './xxrs.epub'), releaseInfo['epub']) + tempDir.cleanup() + + # MOBI Type: KF7 = 0 (old) / KF7 + KF8 = 1 (both) / KF8 = 2 (new) def mobiRelease(metadata: dict, content: dict, mobiType: int = 1) -> None: mobiOption = ['--mobi-toc-at-start'] @@ -213,7 +221,7 @@ def mobiRelease(metadata: dict, content: dict, mobiType: int = 1) -> None: print('Unknown MOBI type') return tempDir = tempfile.TemporaryDirectory() # access temporary directory - print('Calibre MOBI Build: %s' % tempDir.name) + print('Calibre MOBI Build -> %s' % tempDir.name) calibreBuild(tempDir.name, '.mobi', mobiOption, metadata, content) shutil.copy(os.path.join(tempDir.name, './xxrs.mobi'), releaseInfo['mobi']) tempDir.cleanup()