From 5f169a49216f7673d32e9e5a7f83a607ddc672bc Mon Sep 17 00:00:00 2001 From: Artem Akymenko Date: Wed, 22 Jul 2026 07:40:18 +0000 Subject: [PATCH] refactor: replace executor _slugify with domain sanitize_filename_for_chapter - Use existing domain function instead of duplicated local implementation - Domain version includes OS-specific sanitization --- abogen/application/conversion_executor.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/abogen/application/conversion_executor.py b/abogen/application/conversion_executor.py index 127511c..53cde40 100644 --- a/abogen/application/conversion_executor.py +++ b/abogen/application/conversion_executor.py @@ -33,6 +33,7 @@ from abogen.domain.conversion_engine import ( synthesize_text, ) from abogen.domain.normalization import TTSContext +from abogen.domain.output_paths import sanitize_filename_for_chapter from abogen.infrastructure.subtitle_writer import make_subtitle_writer @@ -183,7 +184,7 @@ def execute_conversion( chapter_sink: Optional[AudioSink] = None chapter_path = None if chapter_dir: - chapter_filename = _slugify(chapter.title, chapter_idx) + chapter_filename = sanitize_filename_for_chapter(chapter.title, chapter_idx) chapter_path = chapter_dir / f"{chapter_filename}.{request.separate_chapters_format}" chapter_sink = stack.enter_context( open_audio_sink( @@ -425,16 +426,6 @@ def _base_name(request: Any) -> str: return "output" -def _slugify(title: str, index: int) -> str: - """Create a safe filename slug from chapter title.""" - import re - slug = re.sub(r'[^\w\s-]', '', title.lower()) - slug = re.sub(r'[\s_]+', '_', slug).strip('_') - if not slug: - slug = f"chapter_{index}" - return f"{index:02d}_{slug}" - - def _format_heading(title: str, index: int, request: Any) -> str: """Format chapter heading for TTS.""" from abogen.domain.chapter_titles import format_spoken_chapter_title