Slice 4: MP3 fallback + ZIP extraction #6

Closed
opened 2026-06-03 10:27:19 +02:00 by AlexKucera · 0 comments
AlexKucera commented 2026-06-03 10:27:19 +02:00 (Migrated from github.com)

Parent

#1

What to build

MP3 format fallback when M4B is unavailable, including ZIP part download and extraction.

client module (MP3 endpoints):

  • GET /api/v10/download-manifest?isbn={isbn} — returns parts list (ZIP URLs) and track metadata
  • Parse manifest: extract parts[] array with download URLs, tracks[] with chapter info

downloader module (MP3 path):

  • Download each ZIP part from manifest to {part_name}.zip.partial → rename on completion
  • Extract each ZIP part (contains one or more .mp3 track files) into the book output location
  • Handle corrupt/invalid ZIP gracefully (log error, treat as book-level failure)
  • Resume support for individual ZIP parts via .partial + Range header

Format strategy selector:

  • m4b_mp3_fallback: try M4B first, if 404 → fall back to MP3
  • mp3_only: skip M4B query entirely, go straight to MP3
  • m4b_only: if M4B not available, skip book (log, don't fail)
  • Config-driven via download.format setting

cli wiring:

  • For each undownloaded book: try M4B → fallback MP3 per format strategy → download → update history
  • Full download loop working for both formats

Acceptance criteria

  • MP3 download manifest fetched and parsed correctly
  • Parts list extracted from manifest with URLs
  • Each ZIP part downloaded with .partial tracking
  • ZIP parts extracted to output directory
  • Corrupt ZIP handled as book-level error (not crash)
  • Individual ZIP parts resume from .partial file
  • Format strategy m4b_mp3_fallback tries M4B then falls back to MP3 on 404
  • Format strategy mp3_only skips M4B query entirely
  • Format strategy m4b_only skips book if M4B unavailable
  • ~15 tests: manifest parsing, ZIP download+extraction, format strategy branches, fallback integration, corrupt ZIP handling
  • All tests pass

Blocked by

#5

## Parent #1 ## What to build MP3 format fallback when M4B is unavailable, including ZIP part download and extraction. **client module (MP3 endpoints):** - `GET /api/v10/download-manifest?isbn={isbn}` — returns parts list (ZIP URLs) and track metadata - Parse manifest: extract `parts[]` array with download URLs, `tracks[]` with chapter info **downloader module (MP3 path):** - Download each ZIP part from manifest to `{part_name}.zip.partial` → rename on completion - Extract each ZIP part (contains one or more `.mp3` track files) into the book output location - Handle corrupt/invalid ZIP gracefully (log error, treat as book-level failure) - Resume support for individual ZIP parts via `.partial` + Range header **Format strategy selector:** - `m4b_mp3_fallback`: try M4B first, if 404 → fall back to MP3 - `mp3_only`: skip M4B query entirely, go straight to MP3 - `m4b_only`: if M4B not available, skip book (log, don't fail) - Config-driven via `download.format` setting **cli wiring:** - For each undownloaded book: try M4B → fallback MP3 per format strategy → download → update history - Full download loop working for both formats ## Acceptance criteria - [ ] MP3 download manifest fetched and parsed correctly - [ ] Parts list extracted from manifest with URLs - [ ] Each ZIP part downloaded with .partial tracking - [ ] ZIP parts extracted to output directory - [ ] Corrupt ZIP handled as book-level error (not crash) - [ ] Individual ZIP parts resume from .partial file - [ ] Format strategy `m4b_mp3_fallback` tries M4B then falls back to MP3 on 404 - [ ] Format strategy `mp3_only` skips M4B query entirely - [ ] Format strategy `m4b_only` skips book if M4B unavailable - [ ] ~15 tests: manifest parsing, ZIP download+extraction, format strategy branches, fallback integration, corrupt ZIP handling - [ ] All tests pass ## Blocked by #5
Sign in to join this conversation.