Improve EPUB restoration, book terminology and Calibre QA workflow

This commit is contained in:
Kai Tan
2026-10-08 07:25:27 +08:00
parent 40491e6386
commit caf9d8f4bb
35 changed files with 1439 additions and 959 deletions
+5
View File
@@ -1,4 +1,5 @@
import argparse
import hashlib
import sys
import os
from pathlib import Path
@@ -33,11 +34,15 @@ def run_preprocess(args):
if structure_path.exists() and not args.force:
logger.info(f"Reusing existing structure: {structure_path}")
structure = BookStructure.load(structure_path)
if structure.source_sha256 != hashlib.sha256(input_path.read_bytes()).hexdigest():
structure = BookStructure.load(EpubCleaner(input_path, work["root"]).clean())
else:
logger.info("Cleaning EPUB...")
cleaner = EpubCleaner(input_path, work["root"])
structure_path = cleaner.clean()
structure = BookStructure.load(structure_path)
if structure.source_sha256 != hashlib.sha256(input_path.read_bytes()).hexdigest():
structure = BookStructure.load(EpubCleaner(input_path, work["root"]).clean())
# 2. Extract Text
logger.info("Extracting text segments...")