refactor(downloader): shrink download_book to 4 domain params
Replace 9-parameter signature (book, client, output_base, history, format_strategy, config, transport, progress, cancel_event) with 4 domain-aligned parameters (book, session, plan, reporter) that return a frozen DownloadResult dataclass. Key changes: - Add DownloadResult(status, path, format, error) frozen dataclass - Add format_strategy field to OutputPlan - Move history writing from download_book() to caller (cli closure) - Remove config param from download_accompanying_files() - Wire cancel_event through reporter.cancel_event attribute - Extract transport from session._client._transport Closes #29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ee8186361
commit
9ac581e5b7
11 files changed
+492
-174
No files matched your search
@@ -144,6 +144,7 @@ class OutputPlan:
|
||||
partial_path: Path # .partial resume path for audio
|
||||
cover_path: Path | None # None when disabled or no cover_url
|
||||
pdf_path: Path | None # None when disabled or no pdf_extras
|
||||
format_strategy: str = "m4b_mp3_fallback" # Which format to attempt
|
||||
|
||||
|
||||
def _resolve_output_dir(
|
||||
@@ -179,6 +180,8 @@ def resolve_output_plan(
|
||||
book: Book,
|
||||
output_base: Path | str,
|
||||
config: "Config | None" = None,
|
||||
*,
|
||||
format_strategy: str = "m4b_mp3_fallback",
|
||||
) -> OutputPlan:
|
||||
"""Resolve all output paths for a book into a single immutable plan.
|
||||
|
||||
@@ -219,4 +222,5 @@ def resolve_output_plan(
|
||||
partial_path=partial_path,
|
||||
cover_path=cover_path,
|
||||
pdf_path=pdf_path,
|
||||
format_strategy=format_strategy,
|
||||
)
|
||||
Reference in new issue
Block a user