Hi all,
A class of content doesn’t fit Mopidy’s flat-track model well: one audio
file with an internal tracklist Continuous live mixes, long classical works, podcasts or audiobooks with chapter
markers. The data for the internal positions usually already exists (CUE
sheets, container chapter atoms, yt-dlp chapters, Podcasting 2.0 chapters),
but Mopidy has nowhere to put it — so clients can’t show “what’s playing now
in this 2-hour mix” or let you jump between segments.
What’s interesting is the data is already reachable underneath Mopidy —
GStreamer emits a TOC (GstToc) for chaptered files, and mpv exposes
chapter-list — it’s just never surfaced through Mopidy’s model or API.
Before writing anything heavy, I wanted to gauge whether this is something
you’d consider in core. The shape I have in mind mirrors the existing
get_images() API:
core.library.get_chapters(uris) -> {uri: [Chapter, ...]}
backend.LibraryProvider.get_chapters(uris) -> {uri: [Chapter]} # defaults to {}
with a small Chapter model (start ms, optional length, name,
artists, image). Key choices:
- Not a field on
Track— chapters can be large or need a network fetch
to enumerate, so keep them lazy/opt-in, the same as images. - No tracklist auto-splitting — chapters are the non-destructive
representation; backends that want CUE->tracks can still do that separately. - No MPD-protocol changes — out of scope (MPD has no chapter concept). The
native JSON-RPC frontend exposesget_chaptersfor free, so web/native
clients (Iris etc.) can use it.
I put together a working PoC rather than just describe it:
- core branch —
Chaptermodel +get_chaptersmirroringget_images, with
tests: GitHub - davidj4tech/mopidy at poc/library-get-chapters · GitHub - a Mopidy-Mpv backend that populates it straight from mpv’s
chapter-list
(container + yt-dlp chapters). Verified end-to-end: a chaptered file →
get_chapters→[{start: 0, name: "Intro"}, {start: 318000, name: "Bonobo – Kerala"}].
Is a chapters / cue-points API something you’d be open to in core? Happy to
take feedback on the model (naming chapters vs cuepoints, whether
artists/image belong in v1), and to turn it into a proper PR or move this
wherever you’d prefer it discussed.
Thanks!