All remaining endpoint docs frontmatter'd: media-item bulk ops + audio surface, collections book-listing/preview, koreader rating/review/stats plugin protocol, hash-conflicts JSON list. Scope call (Claude): resolve_hash_conflict.md DELETED — the resolve POST renders an htmx fragment (renderResolved), a web-admin flow under rule 3; only the GET list is a JSON API. update_media_review skipped by Beam (correct): ratings/upsert_media_review.md already covers the PUT. Registry: 16 entries. koreader rating/review/stats all bind koreaderBookRef (query or body) — odd=half-star rating scale; audio track endpoint serves raw bytes (ServeContent, Range) — response nil. Fixed drift: deleted_annotations doc's secondary restore/purge fences unlabeled (gate validates labeled blocks against the ONE frontmatter route); chapters example labeled. UNVERIFIED: 1 (koreader book-ref fields, push_stats). make test 9/9.
62 lines
1.8 KiB
Markdown
62 lines
1.8 KiB
Markdown
---
|
|
method: GET
|
|
path: /api/media-items/:id/chapters
|
|
auth: jwt
|
|
area: media-items
|
|
---
|
|
<!-- source: internal/handlers/media.go:2947 MediaHandler.GetAudioChapters -->
|
|
|
|
# Get Audio Chapters
|
|
|
|
The format-abstraction chapter list for audiobooks, sourced from
|
|
`media_items.audio_metadata`. Embedded m4b chapters, folder-of-tracks
|
|
books and zip-of-audio books all write the same chapter shape; the
|
|
locator `{chapter, audio_offset_seconds}` and this endpoint never learn
|
|
which file model produced them.
|
|
|
|
**Endpoint**: `GET /api/media-items/{id}/chapters`
|
|
**Auth**: Required (JWT)
|
|
|
|
## Response
|
|
|
|
```json example-response
|
|
{
|
|
"media_item_id": "…",
|
|
"chapters": [
|
|
{ "index": 0, "title": "Chapter One", "start": 0.0, "end": 168.0 }
|
|
],
|
|
"duration_seconds": 36000.0,
|
|
"codec_profile": "mp3",
|
|
"layout": "folder",
|
|
"tracks": [
|
|
{
|
|
"index": 0,
|
|
"url": "/api/media-items/{id}/audio/{trackIndex}",
|
|
"title": "01 First",
|
|
"path": "Author/Title/01 First.mp3",
|
|
"start": 0.0,
|
|
"end": 168.0,
|
|
"duration_seconds": 168.0,
|
|
"size_bytes": 2700000
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
- `layout` is `""` for single-file books (the Batch A model — the whole
|
|
file streams through the `/uploads` path), `"folder"` for a directory
|
|
of track files and `"zip"` for a zip-of-audio book.
|
|
- `tracks` is empty for single-file books and carries one entry per
|
|
playable file otherwise. `start`/`end` are cumulative GLOBAL seconds —
|
|
the same coordinate system chapters, bookmarks and
|
|
`audio_offset_seconds` use.
|
|
|
|
## Error Responses
|
|
|
|
| Code | Description |
|
|
| ---- | ------------------------------- |
|
|
| 400 | Invalid media item id |
|
|
| 401 | Missing/invalid token |
|
|
| 404 | Book not found |
|
|
| 500 | audio_metadata failed to parse |
|