feat: Release v0.10 - Modular Architecture & External Config

- Refactor codebase into src/ (preprocessing, translation, assembly)
- Add pipeline/ scripts for individual stages
- Externalize configuration to config/config.yaml
- Fix Cover Image preservation
- Update documentation and manuals
This commit is contained in:
谭凯
2026-01-31 22:49:44 +08:00
parent 9ef82393be
commit 7a93c52b42
306 changed files with 30313 additions and 1071 deletions
+51
View File
@@ -0,0 +1,51 @@
import sys
from pathlib import Path
import traceback
# Add src to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from src.data_model import BookStructure, ManifestEntry
from src.manifest_manager import ManifestManager
from src.backfill_engine import BackfillEngine
from src.bilingual_builder import BilingualBuilder
from src.utils import setup_logger
logger = setup_logger("build_final")
def build_final():
BOOK_NAME = "Empire of AI Dreams and Nightmares in Sam Altmans OpenAI (Karen Hao)"
WORK_DIR = Path(f".work/{BOOK_NAME}")
MANIFEST_PATH = WORK_DIR / "manifest.json"
STRUCTURE_PATH = WORK_DIR / "book_structure.json"
OUTPUT_EPUB = Path("output/final_verification.epub")
INPUT_EPUB = Path(f"input/{BOOK_NAME}.epub")
if not MANIFEST_PATH.exists() or not STRUCTURE_PATH.exists():
logger.error("Missing manifest or structure. Run translation first.")
return
# 1. Load Data
logger.info("Loading structure and manifest...")
structure = BookStructure.load(STRUCTURE_PATH)
manager = ManifestManager(MANIFEST_PATH)
manager.load()
# 2. Backfill
logger.info("Backfilling translations...")
backfiller = BackfillEngine()
structure = backfiller.backfill(structure, manager.entries, mode="bilingual")
# 3. Build
logger.info(f"Building final EPUB to {OUTPUT_EPUB}...")
builder = BilingualBuilder(WORK_DIR, original_epub_path=INPUT_EPUB)
builder.build(structure, OUTPUT_EPUB)
logger.info("Build complete.")
if __name__ == "__main__":
try:
build_final()
except Exception as e:
traceback.print_exc()
print(f"CRITICAL ERROR: {e}")