6 Commits
Author SHA1 Message Date
AlexKucera 75a6eb61ea fix(progress): wire task_id through parallel progress callback
In parallel download mode, all progress updates went to the same
(most recently started) bar because task_id was never threaded from
start_download() to the update callback. Create per-book closure in
orchestrator that binds task_id, pass through cli._download_fn as
optional kwarg. 3 new regression tests. 259 total.
2026-06-04 13:26:38 +02:00
AlexKucera 3dcae24d34 fix(orchestrator): Ctrl+C hangs and threading shutdown traceback
Python ThreadPoolExecutor workers cannot be killed when blocked in HTTP
I/O. Previous approach of waiting for graceful cancellation via
shutdown(wait=True) caused infinite hangs, and re-raising KeyboardInterrupt
still triggered Python's _python_exit thread-join cleanup on exit.

Replace with hard-exit strategy: first Ctrl+C marks all unfinished books
(active + pending) as cancelled, prints summary, returns partial result
with interrupted=True. CLI then calls os._exit(130) to bypass thread
cleanup entirely. Second Ctrl+C hard-exits immediately.

Also fixes: books_with_index[idx][0] returning int index instead of
Book object (AttributeError on summary), empty CancelledError reason
strings, missing cancel_event wiring through download_book->download_m4b
call chain, and corrupted test body from earlier edit collision.

256 tests pass.
2026-06-04 13:10:10 +02:00
AlexKucera 35cd34b604 feat(progress): support concurrent multi-bar progress via per-book identity mapping
Replace singleton _current_task/_current_book state with bidirectional
_tasks (task_id→book) / _book_ids (id(book)→task_id) dicts, enabling N
simultaneous Rich progress bars for parallel downloads.

- start_download() now returns task_id (int)
- update() accepts optional task_id kwarg; falls back to most-recent
  task when omitted for backward compat with existing callers
- complete()/fail() look up task by id(book) and clean up both mappings
- Safe on unknown books (no-op)
- PlainTextReporter unchanged — already stateless per-call design

10 new tests across TestMultiBarProgress (9) and TestMultiBookPlainText (1).
All 194 tests pass, zero regressions. Closes #14
2026-06-03 17:30:16 +02:00
AlexKucera 7a0d8c1d18 feat(config): add workers field and --workers CLI flag
Add parallel download worker-count configuration through all three
config layers: Config dataclass (workers=3 default), YAML parsing
with InvalidWorkersError validation, and -w/--workers CLI flag with
three-layer resolution (CLI > config > hardcoded 3). 6 new tests.

Closes #12
2026-06-03 17:07:50 +02:00
AlexKucera 4aaae68a2e feat(cli): enhanced summary, graceful Ctrl+C, integration tests (closes #9)
Summary output now lists each failed book (ISBN + title + reason)
and each skipped book (ISBN + title) in both plain-text and rich/TTY
formats. Ctrl+C produces a clean shutdown message with exit code 130
instead of a Python traceback. Three integration tests exercise the
full run() pipeline: happy path, mixed results, and fatal auth failure.

12 new tests (168 total), 15/15 acceptance criteria met.
2026-06-03 15:00:27 +02:00
AlexKucera 6cefc79006 feat(progress): add TTY-aware download reporting (closes #8)
Rich progress bars with live %/ETA/speed/file size for interactive
terminals; plain log lines for pipes/cron. Reads Content-Length from
HTTP response so percentage works from first chunk onward. Per-book
failure isolation prevents one bad book from stopping the batch.
18 new tests, 156 total passing.
2026-06-03 14:44:37 +02:00