refactor: simplify _build_request, restore epub3_export as config object

Simplify _build_request() in WebUI
- Remove profiles loading (load_profiles, normalize_profile_entry)
- Remove PronunciationConfig/Epub3ExportConfig building
- Pass raw fields directly to ConversionRequest
- Clean up unused imports

Bugfix: epub3_export as Optional[Epub3ExportConfig] (None = disabled)
- Reverted generate_epub3: bool + epub3_book_id: str back to object pattern
- Consistent with word_substitution, subtitle_input, chapter_chunk
- Updated conversion_service.py _finalize() to use request.epub3_export
This commit is contained in:
Artem Akymenko
2026-07-27 12:41:29 +03:00
parent 625b6610e2
commit 98ab2d925e
3 changed files with 233 additions and 948 deletions
+2 -4
View File
@@ -16,6 +16,7 @@ from typing import Any, Dict, List, Optional
from abogen.application.conversion_config import ( from abogen.application.conversion_config import (
ChapterChunkConfig, ChapterChunkConfig,
Epub3ExportConfig,
SubtitleInputConfig, SubtitleInputConfig,
WordSubstitutionConfig, WordSubstitutionConfig,
) )
@@ -106,11 +107,8 @@ class ConversionRequest:
cover_image_path: Optional[Path] = None cover_image_path: Optional[Path] = None
cover_image_mime: Optional[str] = None cover_image_mime: Optional[str] = None
# --- Feature toggles ---
generate_epub3: bool = False
epub3_book_id: str = ""
# --- Feature configs (None = disabled) --- # --- Feature configs (None = disabled) ---
epub3_export: Optional[Epub3ExportConfig] = None
word_substitution: Optional[WordSubstitutionConfig] = None word_substitution: Optional[WordSubstitutionConfig] = None
subtitle_input: Optional[SubtitleInputConfig] = None subtitle_input: Optional[SubtitleInputConfig] = None
chapter_chunk: Optional[ChapterChunkConfig] = None chapter_chunk: Optional[ChapterChunkConfig] = None
+3 -3
View File
@@ -136,7 +136,7 @@ def _finalize(
raise RuntimeError(f"Failed to embed m4b metadata: {exc}") from exc raise RuntimeError(f"Failed to embed m4b metadata: {exc}") from exc
# EPUB3 generation # EPUB3 generation
if request.generate_epub3 and plan.extraction: if request.epub3_export and plan.extraction:
audio_asset = result.audio_path audio_asset = result.audio_path
if not audio_asset and result.chapter_paths: if not audio_asset and result.chapter_paths:
audio_asset = result.chapter_paths[0] audio_asset = result.chapter_paths[0]
@@ -153,7 +153,7 @@ def _finalize(
events.log("Generating EPUB 3 package...") events.log("Generating EPUB 3 package...")
epub_path = build_epub3_package( epub_path = build_epub3_package(
output_path=epub_output_path, output_path=epub_output_path,
book_id=request.epub3_book_id, book_id=request.epub3_export.book_id,
extraction=plan.extraction, extraction=plan.extraction,
metadata_tags=result.metadata or {}, metadata_tags=result.metadata or {},
chapter_markers=result.chapter_markers or [], chapter_markers=result.chapter_markers or [],
@@ -183,7 +183,7 @@ def _finalize(
chunk_level=request.chapter_chunk.chunk_level if request.chapter_chunk else None, chunk_level=request.chapter_chunk.chunk_level if request.chapter_chunk else None,
speaker_mode=request.chapter_chunk.speaker_mode if request.chapter_chunk else None, speaker_mode=request.chapter_chunk.speaker_mode if request.chapter_chunk else None,
speakers=request.chapter_chunk.speakers if request.chapter_chunk else None, speakers=request.chapter_chunk.speakers if request.chapter_chunk else None,
generate_epub3=bool(request.generate_epub3), generate_epub3=bool(request.epub3_export),
) )
metadata_dir = plan.output_layout.metadata_dir metadata_dir = plan.output_layout.metadata_dir
File diff suppressed because it is too large Load Diff