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:
7 files changed
+490
-17
No files matched your search
@@ -76,6 +76,10 @@ class PlainTextReporter:
|
||||
authors = ", ".join(book.authors) if book.authors else "Unknown"
|
||||
self._print(f" ⏭ {authors} - {book.title} [{book.isbn}]")
|
||||
|
||||
def chapter_renamed(self, count: int, book_title: str, example_name: str) -> None:
|
||||
"""Log chapter rename result with example filename."""
|
||||
self._print(f" Renamed {count} chapter(s) for '{book_title}' → '{example_name}'")
|
||||
|
||||
def _print(self, message: str) -> None:
|
||||
self._out.write(message + "\n")
|
||||
self._out.flush()
|
||||
@@ -216,6 +220,12 @@ class ProgressReporter:
|
||||
authors = ", ".join(book.authors) if book.authors else "Unknown"
|
||||
self._console.print(f" ⏭ {authors} - {book.title} [{book.isbn}]")
|
||||
|
||||
def chapter_renamed(self, count: int, book_title: str, example_name: str) -> None:
|
||||
"""Log chapter rename result with example filename."""
|
||||
self._console.print(
|
||||
f" [dim]Renamed[/dim] {count} chapter(s) for "
|
||||
f"'[italic]{book_title}[/italic]' → [cyan]{example_name}[/cyan]"
|
||||
)
|
||||
|
||||
def _fmt_size(bytes_val: int) -> str:
|
||||
"""Format byte count as human-readable size string."""
|
||||
|
||||
Reference in new issue
Block a user