## Parent
#1
## What to build
The core M4B download pipeline — first working end-to-end audiobook download.
**client module (M4B endpoint):**
- `GET /api/v10/audiobooks/{isbn}/packaged_m4b` — returns M4B download URL
- Handle 404 (M4B not available for this book) — return None/raise specific error for caller to decide fallback
**downloader module (I/O):**
- Streaming chunked download: 8MB chunks, write to `{filename}.m4b.partial`
- On completion: atomic rename from `.partial` to final `{filename}.m4b`
- Resume support: detect existing `.partial` file, read its size, send `Range: bytes={size}-` header
- Use path resolution and sanitization from Slice 3a to determine output location
- Apply subdirectory-vs-flat decision from Slice 3a
- File I/O uses binary mode, respects output directory config
**history integration:**
- After successful complete download (atomic rename done), write entry to `download_history.json`
**cli wiring:**
- For each undownloaded book: resolve path → query M4B metadata → if available, download → update history
- Books without M4B available are logged as "skipped (no M4B)" — fallback to MP3 is next slice
- First **working** download end-to-end (with mocked HTTP in tests)
## Acceptance criteria
- [ ] M4B metadata query returns download URL when available
- [ ] M4B metadata query returns None/specific error on 404 (book has no M4B)
- [ ] Download writes to `.partial` file during transfer
- [ ] On completion, file atomically renamed to final `.m4b`
- [ ] Existing `.partial` file detected and resume via Range header
- [ ] Resume starts from correct byte offset (partial file size)
- [ ] Output path follows pattern from Slice 3a with sanitization applied
- [ ] Subdirectory created when accompanying files present; flat otherwise
- [ ] History entry written only after successful complete download
- [ ] Book without M4B logged and skipped (not treated as error)
- [ ] ~25 tests: M4B query success/404, streaming to temp dir, resume from partial, atomic rename, path resolution integration, happy-path orchestration with mocks
- [ ] All tests pass
## Blocked by
#4
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent
#1
What to build
The core M4B download pipeline — first working end-to-end audiobook download.
client module (M4B endpoint):
GET /api/v10/audiobooks/{isbn}/packaged_m4b— returns M4B download URLdownloader module (I/O):
{filename}.m4b.partial.partialto final{filename}.m4b.partialfile, read its size, sendRange: bytes={size}-headerhistory integration:
download_history.jsoncli wiring:
Acceptance criteria
.partialfile during transfer.m4b.partialfile detected and resume via Range headerBlocked by
#4