Issue #27: Libro.fm Session — Constructor Injection & Rename #27

Closed
opened 2026-06-04 13:50:33 +02:00 by AlexKucera · 1 comment
AlexKucera commented 2026-06-04 13:50:33 +02:00 (Migrated from github.com)

Parent

#25 — PRD 001: Deepen Architecture — Module Depth & Domain Alignment

What to build

Rename LibroFmClient → LibroFmSession, relocate to session.py. Inject transport at construction time so all endpoint methods share one httpx.Client. Assemble auth headers once on the instance.

End state:

  • librofm_downloader/session.py exports LibroFmSession, AuthError, M4BUnavailableError
  • Constructor: LibroFmSession(base_url, username, password, *, transport=None) — builds one httpx.Client(transport=transport) internally
  • All 4 endpoint methods (fetch_library, get_m4b_url, get_mp3_manifest, download_cover) drop their transport= parameter
  • Auth headers computed once in __init__, stored on instance
  • API semaphore stays on instance
  • librofm_downloader/client.py re-exports from session.py as deprecated aliases
  • All ~40 test constructions updated to use new constructor signature

Acceptance criteria

  • from librofm_downloader.session import LibroFmSession works; old client.py path still imports (deprecated)
  • Constructor accepts transport=; all 4 endpoints work through the single internal client
  • Endpoint methods have ≤3 parameters each (down from 5-6)
  • All existing client/session tests pass with updated signatures
  • session.py has ≤8 public symbols
  • AuthError and M4BUnavailableError importable from both session and (deprecated) client

Blocked by

None - can start immediately (parallel with #26)

## Parent #25 — PRD 001: Deepen Architecture — Module Depth & Domain Alignment ## What to build Rename `LibroFmClient` → `LibroFmSession`, relocate to `session.py`. Inject transport at construction time so all endpoint methods share one `httpx.Client`. Assemble auth headers once on the instance. **End state:** - `librofm_downloader/session.py` exports `LibroFmSession`, `AuthError`, `M4BUnavailableError` - Constructor: `LibroFmSession(base_url, username, password, *, transport=None)` — builds one `httpx.Client(transport=transport)` internally - All 4 endpoint methods (`fetch_library`, `get_m4b_url`, `get_mp3_manifest`, `download_cover`) drop their `transport=` parameter - Auth headers computed once in `__init__`, stored on instance - API semaphore stays on instance - `librofm_downloader/client.py` re-exports from `session.py` as deprecated aliases - All ~40 test constructions updated to use new constructor signature ## Acceptance criteria - [ ] `from librofm_downloader.session import LibroFmSession` works; old `client.py` path still imports (deprecated) - [ ] Constructor accepts `transport=`; all 4 endpoints work through the single internal client - [ ] Endpoint methods have ≤3 parameters each (down from 5-6) - [ ] All existing client/session tests pass with updated signatures - [ ] `session.py` has ≤8 public symbols - [ ] AuthError and M4BUnavailableError importable from both `session` and (deprecated) `client` ## Blocked by None - can start immediately (parallel with #26)
AlexKucera commented 2026-06-04 15:27:46 +02:00 (Migrated from github.com)

✅ Complete — committed as 006a756 on feature/improve-codebase. 227 tests pass, 6/6 AC met.

✅ Complete — committed as `006a756` on `feature/improve-codebase`. 227 tests pass, 6/6 AC met.
Sign in to join this conversation.