diff options
| author | historia <historiavg@proton.me> | 2026-08-19 05:25:14 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-19 05:25:14 -0400 |
| commit | c2afb9d01b854bb709345c1b33bdba741daceb25 (patch) | |
| tree | 7317daa34c0e2c4a6d37e88a2c6377cac9b799e5 /converter/audio.py | |
| parent | 94ddbb0634022a6e5209b5221c057228ec3d1418 (diff) | |
| download | tts-audiobook-generator-c2afb9d01b854bb709345c1b33bdba741daceb25.tar.gz | |
fix: skip tests if no ebooklib
Diffstat (limited to 'converter/audio.py')
| -rw-r--r-- | converter/audio.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/converter/audio.py b/converter/audio.py index 3e163be..01f78ab 100644 --- a/converter/audio.py +++ b/converter/audio.py @@ -337,35 +337,27 @@ def verify_output_duration(path: Path, expected_ms: int) -> bool: def _collect_chunk_files(total_chunks: int, - chunk_results: Optional[Dict[int, Optional[Path]]] = None + chunk_results: Dict[int, Optional[Path]] ) -> Tuple[List[Path], List[int]]: """Resolve chunk audio files in book order. - When ``chunk_results`` is provided (chunk number -> path written, or None - for a failed chunk), the recorded paths are used exactly as-is so stale - files from a previous chapter can never leak in. Without it, the chunks - folder is globbed per index (legacy discovery). + ``chunk_results`` maps chunk number -> path written (or None for a failed + chunk); recorded paths are used exactly as-is so stale files from a + previous chapter can never leak in. """ chunk_files: List[Path] = [] missing: List[int] = [] for i in range(1, total_chunks + 1): - if chunk_results is not None: - recorded = chunk_results.get(i) - if recorded is not None and Path(recorded).exists(): - chunk_files.append(Path(recorded)) - else: - missing.append(i) - continue - matches = sorted(CHUNKS_FOLDER.glob(f"chunk_{i:04d}.*")) - if matches: - chunk_files.append(matches[0]) + recorded = chunk_results.get(i) + if recorded is not None and Path(recorded).exists(): + chunk_files.append(Path(recorded)) else: missing.append(i) return chunk_files, missing def combine_chunks(total_chunks: int, output_path: Path, - chunk_results: Optional[Dict[int, Optional[Path]]] = None, + chunk_results: Dict[int, Optional[Path]], speed: float = 1.0, output_format: str = config.AUDIO_FORMAT, intermediate: bool = False, meta: Optional[TrackMeta] = None, |
