diff options
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, |
