feat(downloader): wire rename_chapters into download pipeline

_download_mp3() returns (output_dir, tracks) tuple so manifest
track data flows to callers. download_book() accepts rename_chapters
kwarg; after MP3 extraction succeeds, calls rename_chapters() via
_rename_and_log() helper which also reports to user via reporter.

Both PlainTextReporter and RichProgressReporter show visible feedback:
'Renamed N chapter(s) for Book → example.mp3'. sync_run.py closure
threads resolved_rename_chapters flag through to download_book().

6 new integration tests covering all format strategies and edge cases.
~229 total tests. Closes #34.
This commit is contained in:
AlexKucera committed 2026-06-05 17:47:10 +02:00
1 parent af5ad4953c
commit a415fc37f5
7 files changed
+490 -17

No files matched your search

+2 -3
View File
@@ -197,7 +197,7 @@ def sync_run(
# --- Download loop (parallel via orchestrator — Issue #16) ---
def _make_download_fn():
"""Closure capturing session, config, history, reporter for each book."""
_rc = resolved_rename_chapters # capture resolved value
def _download_fn(
book: Book, *, progress: Callable[[int], None] | None = None
@@ -209,8 +209,7 @@ def sync_run(
config=config,
format_strategy=config.format,
)
result = download_book(book, client, plan, reporter, progress=progress)
result = download_book(book, client, plan, reporter, progress=progress, rename_chapters=_rc)
# Write history as caller (no longer inside download_book)
if result.status == "downloaded":