mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Merge pull request #252 from BinaryAlley/refactor/add-tests-music-stack
Refactor/add tests music stack
This commit is contained in:
1946 files changed
+273285
-1805
No files matched your search
@@ -36,7 +36,10 @@ Lumina is growing, and this is what works right now:
|
||||
|
||||
- **Media libraries that scan themselves.** Point Lumina at a folder or a drive, tell it what kind of media lives there, and it gets to work discovering and indexing what it finds. Scans run in the background, report their progress as they go, and can be started, cancelled or resumed.
|
||||
- **Written content.** Add a written content library and Lumina scans it, cataloguing the books and e-books it contains and dressing them up with metadata for browsing in the client. Open one and it renders in the browser through a reader plugin; the EPUB and PDF readers are bundled and can be enabled per library.
|
||||
- **Music.** Add a music library and Lumina indexes the artists, albums and tracks it contains, reading metadata from the tags inside the audio files. If you want more, enable a metadata provider and Lumina fills in the gaps from online sources, and artwork can come from your folders or from remote sources.
|
||||
- **Music.** Add a music library and Lumina indexes the artists, albums and tracks it contains, reading metadata from the tags inside the audio files. If you want more, enable a metadata provider and Lumina fills in the gaps from online sources, and artwork can come from your folders or from remote sources. You can also build your own playlists, order them the way you want and play them in the browser.
|
||||
- **Favorites.** Mark the artists, albums, tracks and books you love as favorites, from their lists or from the player, and come back to them from one page, filtered by kind. Favorites are private to your account.
|
||||
- **Statistics across your media.** See how much you consumed, how many sessions counted and completed, and which books and music you consumed recently and most, all in one place. Tags and genres are grouped across media kinds and shown lowercase, and administrators can look at any user or at the whole server.
|
||||
- **Resume where you left off.** A book library can remember the section you reached when its progress tracking is on, which is the default for books. A short reading may not be tracked. A music library can remember the position of a track when you turn progress tracking on for it.
|
||||
- **Metadata and artwork from plugins.** Plugins do the knowing. They supply the metadata and the artwork of a library, and you decide, library by library, which ones are switched on and which one wins when several of them recognize the same item.
|
||||
- **A file system browser.** Reach the drives, folders and files of the server machine from anywhere you can open the client, as if you were sitting right in front of it. Poke around, walk a path to its root or to its parent, and let Lumina generate thumbnails for what it finds.
|
||||
- **Accounts, roles, permissions and policies.** Create accounts, sign in with a password and optional two factor authentication, and hand out access through roles, fine grained permissions and policies that decide who may reach which library or content. Administrators manage all of it from the administration area.
|
||||
|
||||
@@ -21,16 +21,17 @@ Lumina ships as two applications that talk to each other over the network: the *
|
||||
|
||||
> **Not production ready yet.** Lumina is pre-alpha software. Updates are one way and can lose Lumina's data, so read [Updating](#updating) before you install or upgrade.
|
||||
|
||||
There are **two ways to install Lumina**. Pick one:
|
||||
There are **two ways to run Lumina**. Pick one:
|
||||
|
||||
- **[Option A: run with Docker Compose](#option-a-run-with-docker-compose)**, the recommended route, where a single command brings up the whole system.
|
||||
- **[Option B: build and run manually](#option-b-build-and-run-manually)**, if you would rather run the applications directly, without containers.
|
||||
- **[Option B: run the applications directly](#option-b-run-the-applications-directly)**, whether you install a release package or build from source, if you would rather run them without containers.
|
||||
|
||||
Everything from Configuration onward applies to whichever route you chose.
|
||||
|
||||
## Before you start
|
||||
|
||||
- **Docker**, if you want the container route, or the **.NET 10 SDK** if you want to build and run from source.
|
||||
- **Docker**, if you want the container route. For a non-container install, you need the Lumina application files, from a release package or installer, or from your own build, plus the **.NET 10 runtime** unless that package is self-contained. The **.NET 10 SDK** is only needed if you build from source.
|
||||
- **ffmpeg**, for any non-container install, however you obtained the application files. The API server uses it to remux or transcode audio that the browser cannot play as stored. The Docker API container image already includes it.
|
||||
- By default the **web client listens on port `5012`** and the **API on port `5214`**. You can change either, as long as the two agree on where the API is (see [Configuration](#configuration)).
|
||||
- For anything reachable beyond your own machine, put a **reverse proxy** in front to terminate TLS and forward to the web client.
|
||||
- Lumina needs **no external database server**. It keeps its data in a local SQLite file that is created automatically.
|
||||
@@ -77,15 +78,15 @@ The development configuration embeds throwaway keys so the container route works
|
||||
|
||||
Set them as environment variables on the `lumina-api` and `lumina-web` services in your own compose file or orchestration.
|
||||
|
||||
## Option B: build and run manually
|
||||
## Option B: run the applications directly
|
||||
|
||||
With the .NET 10 SDK installed, build the solution from the `src` directory:
|
||||
Use a release package or installer when one is available, or, with the .NET 10 SDK installed, build the solution from the `src` directory:
|
||||
|
||||
```bash
|
||||
dotnet build Lumina.sln
|
||||
```
|
||||
|
||||
Run the API and the web client. In development, their addresses come from each project's `launchSettings.json` (`http://localhost:5214` and `http://localhost:5012`). When you run a published build directly on a host, set the addresses yourself, either with `ASPNETCORE_URLS` or with `ASPNETCORE_HTTP_PORTS`:
|
||||
Run the API and the web client from the installed release package or from the published build. In development, their addresses come from each project's `launchSettings.json` (`http://localhost:5214` and `http://localhost:5012`). When you run a published build directly on a host, set the addresses yourself, either with `ASPNETCORE_URLS` or with `ASPNETCORE_HTTP_PORTS`:
|
||||
|
||||
```bash
|
||||
ASPNETCORE_HTTP_PORTS=5012 dotnet Lumina.Presentation.Web.dll
|
||||
@@ -93,6 +94,8 @@ ASPNETCORE_HTTP_PORTS=5012 dotnet Lumina.Presentation.Web.dll
|
||||
|
||||
The API creates its SQLite database (`Lumina.db`) next to its own binary and applies any pending migrations at startup, so the first launch sets up the schema on its own.
|
||||
|
||||
The API server needs **ffmpeg** on its `PATH` to normalize audio that a player cannot play as stored. Install it with your platform's package manager, or point `TranscodingSettings:FfmpegPath` at the binary if it is somewhere else.
|
||||
|
||||
## Configuration
|
||||
|
||||
Each application reads its own `appsettings.json` and an optional environment specific `appsettings.development.json`, and environment variables override both. The API also loads the `appsettings.shared.json` file (and its development variant), which holds the server side settings that are not specific to a single layer, such as the media, plugins and theme options.
|
||||
@@ -112,10 +115,15 @@ The settings that matter most when installing:
|
||||
| `PluginsSettings:Directory` | API server | Folder holding installed plugin assemblies, `plugins` by default. |
|
||||
| `ThemeEngine:StoragePath`, `ThemeEngine:BundledThemesPath`, `ThemeEngine:DefaultThemeId` | API server | Where installed and bundled themes live, and which theme is activated by default. |
|
||||
| `ThemeEngine:MaxArchiveBytes`, `MaxExpandedBytes`, `MaxSingleFileBytes`, `MaxEntries` | API server | Limits enforced on uploaded theme packs. |
|
||||
| `TranscodingSettings:FfmpegPath`, `MaxConcurrentJobs`, `MaxConcurrentJobsPerUser`, `MaxCacheBytes`, `JobTimeoutSeconds`, `EvictionGraceSeconds`, `CacheDirectory` | API server | Where the ffmpeg binary is, how many audio normalization jobs may run at once in total and per user, the maximum size of the normalized audio cache in bytes, how long a single job may take in seconds, how long a freshly produced or served cache entry is protected from eviction, and where the cache is stored. When `CacheDirectory` is absent, a private directory under the API account's temporary directory is used. |
|
||||
| `Telemetry:Enabled`, `Telemetry:Otlp:Endpoint`, `Telemetry:TraceSampleRatio`, `Telemetry:ConsoleExporterEnabled` | API server and web client | Telemetry behavior. The OTLP endpoint also falls back to the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable. Again, while telemetry is enabled as a feature, nothing is sent anywhere. |
|
||||
|
||||
The `LOG_PATH` environment variable selects where the rolling log files are written.
|
||||
|
||||
The normalized audio cache must not be placed inside `MediaSettings:RootDirectory`, because that directory is served at the `/media` route, and it must not contain that directory either, because cleaning the cache would remove the media. The startup configuration also rejects a cache directory that is a filesystem root, the application directory or one of its parents, or that overlaps the logs or plugins directories. The default uses a private directory under the API account's temporary directory and avoids all of these. The cache holds transcoded or remuxed audio only while it is useful: at API startup only the entries the cache itself owns are removed, and a directory is cleaned only when it carries Lumina's cache marker file (`.lumina-transcoding-cache`) or is empty, so a directory that belongs to something else is left untouched. Its total footprint is capped by `TranscodingSettings:MaxCacheBytes`, but an entry that is still being read, or that was just produced when the cache was already at the limit, is kept until it can be removed, so the cache can exceed the cap temporarily. The cache is not part of the media library.
|
||||
|
||||
The default cache directory is scoped to the API account, but the coordinator, the running jobs and the startup cleanup are per process. Run a single API process per account and host, or configure a distinct `CacheDirectory` for each instance. Playback delivery handles are also process local: in a load balanced multi-instance deployment, a track's manifest and its subsequent segment requests must reach the same API instance, so configure sticky routing for them as described for SignalR below. On a multi-user Unix host the directory is created with private permissions, and a pre-existing directory owned by another account is treated as unavailable rather than reused or deleted.
|
||||
|
||||
### Keeping the two applications in step
|
||||
|
||||
The web client and the API must agree on two addresses, and getting them wrong is the usual cause of a client that loads but never updates live:
|
||||
|
||||
@@ -51,6 +51,8 @@ Open the Libraries management page, choose to add a library, and fill in the for
|
||||
| Download metadata from the web | on | Whether Lumina may look up the metadata of the items online. This only has an effect when a metadata provider is enabled for the library (see [Plugins](../plugins/index.md)). |
|
||||
| Save metadata in media directories | off | Whether the metadata Lumina fetches is also written next to your media files, so other tools can read it. This is the one option that writes into your media folders. |
|
||||
| Skip unchanged directories during scan | off | An opt-in speedup that skips folders whose own last-modified time has not changed since the last scan. Editing the contents of an existing file in place, without adding, removing or renaming anything in that folder, leaves the folder's time untouched, so that edit can be missed while it is on. |
|
||||
| Track consumption progress | the type default | Whether the latest playback or reading position of the library's items is remembered, so a user can resume where they left off. |
|
||||
| Completion threshold | the type default | The percentage of an item that must be consumed for a stopped session to be recorded as completed. Empty means completion is recorded only when it is reported explicitly. |
|
||||
| Path template | the type's ideal structure | Tells Lumina how your folders are arranged on disk. Unless you customize it, it holds the default template of the library type, which is exactly the structure Lumina expects. Optional, and explained in full below. |
|
||||
|
||||
A library that is disabled or locked is never scanned, so those two settings double as a pause switch, and `Locked` also freezes edits.
|
||||
@@ -130,6 +132,36 @@ Editing a library reopens the same form, and changes take effect on the next sca
|
||||
- Changing the **type** of an existing library also reconciles the metadata, artwork and reader provider settings of that library, so they match the plugins that support the new type.
|
||||
- Changing the **content locations** takes effect on the next scan. Items found under a location you removed are dropped from the catalogue, along with the metadata and artwork Lumina had stored for them, and items under a location you added are picked up.
|
||||
|
||||
## Progress tracking and completion thresholds
|
||||
|
||||
Two settings on a library decide whether Lumina remembers where you stopped and when a session is complete. They apply to every user of that library.
|
||||
|
||||
- **Track consumption progress** decides whether the latest playback or reading position of an item is remembered and offered as the resume position. When it is off, Lumina stores no resume point for the library's items.
|
||||
- **Completion threshold** is the percentage of an item at which a stopped session is recorded as completed instead of stopped. It is set only while tracking is on, and it can be left empty.
|
||||
|
||||
When a session ends, the settings decide its status:
|
||||
|
||||
- **Tracking off**: the session is recorded as stopped, its position is not saved, and the completion threshold is not checked.
|
||||
- **Tracking on, no threshold**: the session is recorded as stopped and its position is saved, so it can be resumed. It is completed only when completion is reported explicitly.
|
||||
- **Tracking on with a threshold**: a stop at or above the threshold is recorded as completed and removes the resume point. A stop below the threshold is recorded as stopped and keeps the resume point.
|
||||
|
||||
The defaults by library type are:
|
||||
|
||||
| Library category | Track progress | Completion threshold |
|
||||
| --- | --- | --- |
|
||||
| Music audio (Music, Remix, SoundEffect, CoverSongAudio, LiveRecordingAudio, InterviewAudio) | no | none |
|
||||
| Photo | no | none |
|
||||
| Written content (Book, EBook, ComicBook, Magazine, Newspaper, Manga, GraphicNovel, AcademicPaper, SheetMusic) | yes | 100 |
|
||||
| Video (TvShow, Movie, Documentary, Anime, ConcertVideo, TutorialVideo, HomeVideo, YouTubeVideo, MusicVideo, LiveRecordingVideo, InterviewVideo, CoverSongVideo) | yes | 90 |
|
||||
| Audiobook and podcast (Audiobook, PodcastAudio, PodcastVideo) | yes | 95 |
|
||||
| Other, non-media or unknown | no | none |
|
||||
|
||||
For now, only Book and Music libraries produce a working catalogue, so the written content and music defaults are the ones you will meet. Other library types can still be created, and their rows are the defaults they will use when their catalogues arrive. A value you set on a library always wins after the library is created.
|
||||
|
||||
When you add a library without changing these fields, Lumina applies the default of its type. When you turn tracking on for a library whose type has no default threshold, the threshold stays empty and completion is recorded only when it is reported explicitly. An empty threshold is not zero: zero would complete every stopped session as soon as it stops.
|
||||
|
||||
The threshold must be a whole number from 0 to 100, and the form refuses any other value. Changing it affects sessions that stop afterwards; a session that was already recorded keeps the status it was recorded with. Turning tracking off clears the threshold. The setting does not change what a library can play or read, only whether a resume point is kept and how a stopped session is recorded.
|
||||
|
||||
## Deleting a library
|
||||
|
||||
Deleting a library removes it from Lumina: its configuration, its scan history, the items in its catalogue, their metadata and the artwork Lumina stored for them, and its provider settings. The cover image Lumina copied into its own storage is removed as well. Your original files are left untouched.
|
||||
@@ -160,8 +192,11 @@ These are per user settings, each user changes their own from the settings page
|
||||
- **`Skip unchanged directories during scan` can miss in-place edits.** It trusts each folder's own last-modified time, so editing the contents of an existing file without adding, removing or renaming anything in its folder leaves the folder unchanged and it gets skipped. Adding, removing or renaming a file does change the folder, and is still seen.
|
||||
- **`Locked` blocks everything.** A locked library is not scanned and not updated, including by the scheduler.
|
||||
- **`Disabled` hides the library.** A disabled library is neither shown on the dashboard nor touched.
|
||||
- **Deleting a library removes Lumina's catalogue for it.** The files remain, but the metadata, artwork and history Lumina held for that library do not.
|
||||
- **Deleting a library removes Lumina's catalogue for it.** The files remain, but the metadata and artwork Lumina held for that library do not. Consumption history and resume points are kept as records of what was consumed. The history shows the items as unavailable until you delete it. **Remove from continue watching** removes every resume point of the selected user, not only the ones from the deleted library.
|
||||
- **Removing a folder from a library, or deleting a file, removes its catalogued items on the next scan.** The catalogue tracks what is on disk, so what disappears from disk also disappears from Lumina, along with the metadata and artwork Lumina stored for it.
|
||||
- **Changing the path template can change how items are read.** Re-scan and check the results after a change.
|
||||
- **Only Book and Music libraries scan today.** Other types cannot be created into a working library yet.
|
||||
- **Tracking off means no resume points.** A library that does not track consumption progress never offers a saved position, even if a client reports one.
|
||||
- **An empty completion threshold is not zero.** Empty means completion is recorded only when it is reported explicitly, while zero completes a stopped session immediately.
|
||||
- **Deleting history and removing resume points are separate.** Clearing a user's history removes all of that user's recorded sessions and keeps their resume points, while **Remove from continue watching** removes all of that user's resume points and keeps their history. Neither action is limited by the library, media kind or date filters of the statistics page.
|
||||
- **For now, only Book and Music libraries produce a working catalogue.** Other types can be created, but they do not scan into a usable catalogue yet.
|
||||
- **Not every book format is readable.** Recognized formats are indexed, but only those with an enabled reader plugin can be opened in the browser.
|
||||
@@ -60,6 +60,8 @@ The reader opens the book in the browser and gives you a small toolbar and the b
|
||||
|
||||
A book opens only through an enabled reader for its format. The EPUB and PDF readers are bundled and can be enabled for a library. A scanned PDF has no text to extract, so it can only be shown as page images, which is what the `Render PDFs as images` setting turns on.
|
||||
|
||||
Book libraries track consumption progress by default. Reopening a book continues from the last section of a tracked reading session. A short reading, such as opening a book, turning a few pages and closing it, may not reach the minimum needed to be tracked, so it can leave no saved position and the book opens at the beginning. Reaching the library's completion threshold, 100 percent for a book library by default, completes the reading session and removes the saved position. The threshold is a per-library setting, described in [Managing Libraries](../managing-libraries/index.md).
|
||||
|
||||
## Browsing your music
|
||||
|
||||
Opening a music library shows a page with the library title, a search box, a sort toggle, a count of items, a grid of artist cards, an alphabetical picker down the side, and pagination at the bottom.
|
||||
@@ -69,15 +71,67 @@ Opening a music library shows a page with the library title, a search box, a sor
|
||||
- **The alpha picker** jumps to names starting with a chosen character. It offers All, then the number and symbol keys, then A to Z. You can also press a letter key to filter, and press Escape to clear the filter.
|
||||
- **Pagination** splits the list into pages when you have it enabled, with previous and next buttons and a page indicator. When it is off, the whole list is shown and the count is the total.
|
||||
|
||||
Each artist is a card; selecting it opens the artist's page, and the card's actions menu offers **View details** and **Delete**.
|
||||
Each artist is a card; selecting it opens the artist's page, and the card's actions menu offers **View details**, **Play**, **Shuffle**, **Add to playlist** and **Delete**. The heart on the card marks the artist as a favorite.
|
||||
|
||||
The artist page is also where you edit the artist. It lists the artist's albums as cards, each leading to its own album page, followed by the artist's general information, contributors, ratings, genres, tags, aliases, areas and identifiers. The album page holds the album's information and its tracks, and the track page holds the track's details. The album page also shows the artwork Lumina stored for the album as a strip of thumbnails beside the main image, and selecting a thumbnail displays that image in place of the cover. Deleting an artist, album or track removes it from Lumina's catalogue; your files are not touched.
|
||||
|
||||
The music pages also play what they show. The artist page has a **Play all** control that plays the artist's releases in the order the page presents them, one release after another. The actions menu of a music library card on the home page, of an artist card, and of an album card offers **Play** and **Shuffle**. Play starts the library at its first artist and continues through the remaining artists in artist page order, starts the artist's discography in the order the artist page presents it, or starts the release in disc and track order. Shuffle starts the library, the artist's discography or the release with a list of up to 100 tracks sampled uniformly at random from every track of that scope, and continues in random order without repeating a track that is already queued. The album page has a **Play album** control that plays the release in disc and track order, and every track row has its own play control that plays just that track. The track page has a **Play track** control for the track it shows. Every track row on the album page also has an actions menu: **Add to playlist** opens the playlist picker for that track, **Add to play queue** appends it to the end of the player queue or starts it when the queue is empty, and **Play all from here** replaces the queue with that track and the rest of the album and starts playing. Starting playback opens the player bar at the bottom of the window. It keeps playing while you move between pages, and the bar shows the track name, with the album name underneath when the track belongs to a named album, the progress of the current track, a segmented VU meter that follows the level of the track, and the volume, together with previous, play or pause, stop, next and repeat controls. When you expand it, it also shows the cover art, the current track name, the release type, the release name and year, the artist name, and a carousel of the album's stored artwork, next to the queue, where every entry carries its album cover, including when only one track is queued. Selecting an artwork in the carousel shows it as the main cover. The expanded queue moves the current track to the top whenever playback advances, so it stays visible even in a long list. The current track's favorite is the heart on the bar between the repeat and mute controls, and every entry of the expanded queue carries its own heart. The queue's own playlist picker appends the whole queue, in order, to one of your playlists. The double chevron at the right points up to expand the bar and down to collapse it. Stop is the square control next to play or pause; in the condensed bar it stops playback and slides the bar out of view.
|
||||
|
||||
Music libraries do not remember positions by default. When progress tracking is turned on for a music library, starting a track resumes it from the last reported position, and stopping it at or above the library's completion threshold, when one is set, completes the session instead of saving a position.
|
||||
|
||||
## Playlists
|
||||
|
||||
The **Playlists** entry under Audio opens your playlists. A playlist survives signing out and back in, but the player queue itself does not. A full page reload still starts with an empty queue and a hidden player.
|
||||
|
||||
From the playlists page you can open a playlist or select **Create** to open the dedicated page that creates a new playlist with a name and an optional description. Selecting an existing playlist opens its own page, which shows its tracks in order and lets you:
|
||||
|
||||
- **Add a track** by choosing a music library, then an artist, an album and a track, and selecting **Add**. A track can appear more than once in the same playlist.
|
||||
- **Reorder the tracks** by dragging a row by its handle, or with the up and down controls on each row. The order is saved immediately.
|
||||
- **Remove a track** from the playlist. The track itself, and the file behind it, are not touched.
|
||||
- **Play a single track** with its play control, or **Play playlist** to hand the whole ordered list to the player in one go. Each row also has a heart that marks the track as a favorite and a plus control that adds it to another playlist. While something is playing, the expanded player's **Add to playlist** button appends its current queue to one of your playlists.
|
||||
- **Add a whole library, artist or album** from the card menu of its page: choose **Add to playlist**, pick a playlist, and the tracks of that scope are appended in catalogue order. The same dialog lets you create a playlist when you have none yet.
|
||||
- **Edit the name and description**, and **delete the playlist** when you no longer need it. Deleting a playlist never deletes any track.
|
||||
|
||||
The playlist reflects the catalogue at the moment you open it. If a track is deleted from a library after it was added to a playlist, its row stays in the playlist as an unavailable track so you can remove it deliberately. Long playlists are shown in pages; select **Load more** to show the next page.
|
||||
|
||||
## Favorites
|
||||
|
||||
A favorite is a mark you place on an artist, album, track or book so you can find it again quickly. Favorites belong to your account and are not shared with other users. Marking an item never changes the item or its files. Videos and photos are not available as favorites yet.
|
||||
|
||||
Select the heart on an item's card, on its row on an album page or in a playlist, on the player bar for the current track, or on any queue entry of the player, to add or remove the mark. A blue heart means the item is not a favorite; a red heart means it is.
|
||||
|
||||
The **Favorites** page in the library section lists everything you marked, most recent first, with a count that follows the filter.
|
||||
|
||||
- **Filter by kind** with the **Show** picker.
|
||||
- **Open an item** from its card.
|
||||
- **Remove a favorite** with the heart on its card.
|
||||
- **Load more** when the list is long, or **Retry** if it does not load.
|
||||
|
||||
A favorite whose item was deleted, or whose library you can no longer access, stays in the list as an unavailable card so you can still remove it.
|
||||
|
||||
## Statistics
|
||||
|
||||
The **Statistics** entry under Library opens your consumption statistics. It covers every media kind the server can consume, with music and book sessions appearing side by side and more kinds joining as their catalogues arrive. The statistics are built from the sessions your player and reader report, belong to your account, and are not shared with other regular users; administrators can view any user's statistics.
|
||||
|
||||
A session counts towards the statistics when it completes, or when it reaches the counting rule of its kind. A music track counts after 30 seconds, and a book counts after more than 5 consecutive pages in the reader. A stopped session below the rule is stored but not counted, while the total consumed time still includes the time you spent. Completion is separate from counting: a session can count without the library considering the item complete.
|
||||
|
||||
The page shows:
|
||||
|
||||
- **Total consumed time**, **counted sessions**, **completed sessions** and the **completion rate** of the selected user.
|
||||
- **By media kind**, the same totals broken down per kind.
|
||||
- **Genres** and **tags** as bars, grouped across media kinds and shown lowercase. A genre or tag shared by a book and a track appears once.
|
||||
- **Recently consumed** and **most consumed**, with the kind of each item, its title, creator, collection, cover, last consumption time, counted sessions, completed sessions and consumed time.
|
||||
- **Filters** for the library, the media kind and a date range, applied to every section.
|
||||
|
||||
Each history row has **Delete from history**, which removes every recorded session of that item. The page also has **Clear history**, which removes every recorded session of the selected user, and **Remove from continue watching**, which removes every saved resume point of the selected user. Each action asks for confirmation, and the page reloads after it. Deleting history does not remove resume points, and removing resume points does not delete history. The resume points themselves are the saved positions described under reading and listening; the statistics page does not list them, it only clears them.
|
||||
|
||||
An administrator sees a user picker with **Me**, every user, and **All users**. Selecting another user shows that user's statistics. Selecting **All users** shows the combined totals and a per-user table, because the history lists and the genre and tag breakdown are only meaningful per user. A regular user sees no picker and only their own statistics. Administrators can read and delete the history of any user; regular users can only read and delete their own.
|
||||
|
||||
An item that was deleted, or whose library you can no longer access, keeps its place in the counts but is shown as unavailable, without display details. Select **Retry** when a section does not load.
|
||||
|
||||
## Editing what is catalogued
|
||||
|
||||
Both book and music pages double as editors for the items that were scanned in. A book's details page groups its fields into general and release information, language and original language, genres, tags, identifiers, ISBNs, contributors and ratings, and lets you replace its cover. An artist's page lists the artist's albums first, then groups its fields into general information, contributors, ratings, genres, tags, aliases, areas and identifiers, and lets you replace the artist's cover. An album page groups its fields into general information, contributors, ratings, genres, tags, release types, release information, language and original language, and identifiers, and lets you replace the album's cover. A track page groups its fields into general information, contributors, ratings, genres, tags, moods, release information, language and original language, work, ISRCs, identifiers and audio properties. Saving sends the changes back to the server, and a confirmation or an error is shown in the corner of the screen.
|
||||
|
||||
Changes you make here live in Lumina's catalogue.
|
||||
Both book and music pages double as editors for the items that were scanned in. A book's details page groups its fields into general and release information, language and original language, genres, tags, identifiers, ISBNs, contributors and ratings, and lets you replace its cover. An artist's page lists the artist's albums first, then groups its fields into general information, contributors, ratings, genres, tags, aliases, areas and identifiers, and lets you replace the artist's cover. An album page groups its fields into general information, contributors, ratings, genres, tags, release types, release information, language and original language, and identifiers, and lets you replace the album's cover. A track page groups its fields into general information, contributors, ratings, genres, tags, moods, release information, language and original language, work, ISRCs, identifiers and audio properties. Saving applies the changes to Lumina's catalogue.
|
||||
|
||||
## The file system browser
|
||||
|
||||
@@ -87,6 +141,8 @@ Wherever Lumina needs a folder or a file from the server, it opens the file syst
|
||||
|
||||
The tools section holds your settings and the language picker.
|
||||
|
||||
Your **settings** decide how lists and books behave for you. Enable pagination and the number of items per page control how browsing is split. The alpha picker option decides whether titles beginning with "The" are filed under the next word. Theme caching decides whether the theme is fetched fresh each time. Rendering PDFs as images and preserving book styles shape how books are shown, and the metadata and artwork aggregation options decide whether missing fields are completed from your other providers. The ones that touch libraries are described in more detail in [Managing Libraries](../managing-libraries/index.md).
|
||||
Your **settings** decide how lists and books behave for you. Enable pagination and the number of items per page control how browsing is split. The alpha picker option decides whether titles beginning with "The" are filed under the next word. Theme caching decides whether the theme is fetched fresh each time. Rendering PDFs as images and preserving book styles shape how books are shown, and the metadata and artwork aggregation options decide whether missing fields are completed from your other providers. A final group of options shapes playback: whether the player keeps downloading while it is paused (for a track the server has to normalize, this keeps its bounded one-segment lookahead filled rather than downloading the whole file), whether it continues automatically at the end of an album or artist, whether consecutive tracks play without a gap, how ReplayGain normalizes loudness, and the quality cap used when the server has to normalize a track. That cap applies only when the server re-encodes a track into a lossy format; a remux only repackages the stored audio, and a lossless delivery is not reduced. The ones that touch libraries are described in more detail in [Managing Libraries](../managing-libraries/index.md).
|
||||
|
||||
The **VU meter** group shapes the meter of the player bar. Orientation lays its channels out as columns that grow upwards or rows that grow to the right. Segments per channel sets how finely each channel is divided, and Segment gap sets the space between segments and channels. The medium and high thresholds decide the level at which a segment changes color; the high threshold cannot be lower than the medium one. Show peak keeps a mark at the loudest recent level of each channel. Peak hold is how long that mark stays in place before it falls, in milliseconds, and Level falloff and Peak falloff are how quickly the bars and the peak marks drop once the sound gets quieter, in level units per second. Larger falloff values drop faster. The meter follows the level of the track itself, so muting the player or moving the volume slider does not change the height of the bars, and saving these settings applies them to the player without reloading the page.
|
||||
|
||||
The **language** picker switches the interface between the languages Lumina ships with, and remembers your choice.
|
||||
@@ -0,0 +1,335 @@
|
||||
# Lumina API
|
||||
|
||||
- [Lumina API](#lumina-api)
|
||||
- [Favorites](#favorites)
|
||||
- [Add Favorite](#add-favorite)
|
||||
- [Add Favorite Request](#add-favorite-request)
|
||||
- [Add Favorite Response](#add-favorite-response)
|
||||
- [Remove Favorite](#remove-favorite)
|
||||
- [Remove Favorite Request](#remove-favorite-request)
|
||||
- [Remove Favorite Response](#remove-favorite-response)
|
||||
- [Get Favorites](#get-favorites)
|
||||
- [Get Favorites Request](#get-favorites-request)
|
||||
- [Get Favorites Response](#get-favorites-response)
|
||||
- [Get Favorite Status](#get-favorite-status)
|
||||
- [Get Favorite Status Request](#get-favorite-status-request)
|
||||
- [Get Favorite Status Response](#get-favorite-status-response)
|
||||
- [Media Kinds](#media-kinds)
|
||||
- [Scoping and Library Access](#scoping-and-library-access)
|
||||
- [Errors](#errors)
|
||||
- [Pagination Limits](#pagination-limits)
|
||||
|
||||
## Favorites
|
||||
|
||||
A favorite is the marker the current user places on a media item of any media kind. It references the item only by its kind and its Id, so the same four operations serve music artists, albums and tracks, books, and the kinds that are planned. A favorite belongs to the user that created it, and only that user can list it, check it or remove it. Every route is under `users/me`, because it always acts on the currently authenticated user, and every operation requires authentication.
|
||||
|
||||
Favorites are independent of the catalogue they point to. A favorite stores the kind and the Id of the item without a foreign key to it, so deleting the item from its library does not delete the favorite. A favorite is deleted together with the user that owns it. A favorite whose item was deleted, or whose library the user can no longer access, is still listed, as an unavailable item with empty display fields, so that its owner can see it and remove it.
|
||||
|
||||
All the responses of the four operations are private to the authenticated user: they carry `Cache-Control: private, no-store` and `Vary: Authorization`.
|
||||
|
||||
### Add Favorite
|
||||
|
||||
#### Add Favorite Request
|
||||
|
||||
```js
|
||||
POST api/v1/users/me/favorites
|
||||
Authorization: Bearer <token>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `mediaKind` | string | yes | The kind of the media item: `MusicArtist`, `MusicAlbum`, `MusicTrack` or `Book`. `Video` and `Photo` are planned kinds and are rejected, see [Media Kinds](#media-kinds). |
|
||||
| `mediaItemId` | Guid | yes | The Id of the media item. It cannot be the empty Guid. |
|
||||
|
||||
Marks the media item as a favorite of the current user. The request is validated first, and then the media item is looked up in the catalogue of its kind. The item must exist, and the library that contains it must be accessible to the current user, see [Scoping and Library Access](#scoping-and-library-access). The user is always the authenticated user, so no user Id is accepted in the body.
|
||||
|
||||
#### Add Favorite Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"mediaKind": "MusicTrack",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"favoritedOnUtc": "2026-10-21T12:00:00.0000000Z"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `id` | The Id of the favorite. |
|
||||
| `mediaKind` | The kind of the favorited media item. |
|
||||
| `mediaItemId` | The Id of the favorited media item. |
|
||||
| `favoritedOnUtc` | The date and time when the item was favorited. |
|
||||
|
||||
The response is `200 Ok` both when the favorite was created and when it already existed, so a client does not need to tell the two apart. The favorite is read back from storage after it is saved, so `favoritedOnUtc` is the stored value. A favorite that was created raises a `FavoriteAdded` domain event; an existing favorite raises none.
|
||||
|
||||
### Remove Favorite
|
||||
|
||||
#### Remove Favorite Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/me/favorites/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `mediaKind` | The name of the media kind, matched case insensitively. Only the member names are accepted: a number that would parse as a kind is rejected. |
|
||||
| `mediaItemId` | The Id of the media item. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
Removes the favorite of the current user on the media item identified by the route. Removal is scoped to the authenticated user and never touches another user's favorite. It does not look the media item up and does not evaluate the library access rule, so a user can always remove their own favorite even when the item was deleted or its library is no longer accessible. Another user's favorite is never visible to them, so it cannot be removed through this route. Removing a media kind that is planned but not supported is not an error by itself: it finds no favorite and the request succeeds without changing anything.
|
||||
|
||||
#### Remove Favorite Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
The response body is an empty JSON object.
|
||||
|
||||
Removing an item that the current user did not favorite succeeds without changing anything, and the same is true for a favorite of another user, which is never visible to the current user. Removing is therefore idempotent: the second removal of the same favorite also returns `200 Ok` and raises no event. A favorite that was actually removed raises a `FavoriteRemoved` domain event.
|
||||
|
||||
### Get Favorites
|
||||
|
||||
#### Get Favorites Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/favorites?mediaKind=MusicTrack¤tPage=1&perPage=200
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Query parameter | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `mediaKind` | string | no | Restricts the list to one kind: `MusicArtist`, `MusicAlbum`, `MusicTrack` or `Book`. Every kind is returned when it is omitted. |
|
||||
| `currentPage` | integer | no | The one based page of favorites to return. Defaults to `1` when `perPage` is provided. Values below `1` are raised to `1`. |
|
||||
| `perPage` | integer | no | The number of favorites per page. Defaults to `200` when `currentPage` is provided. Values below `1` are raised to `1`, and there is no maximum. |
|
||||
|
||||
Returns the favorites of the current user, from the most recently favorited. The page bounds one response, not the number of favorites a user can have: a client reads the next page until `currentPage` reaches `numberOfPages`, and `count` reports the total. When neither `currentPage` nor `perPage` is provided, every matching favorite is returned in a single page, the same way the other paginated collections of the API behave when pagination is omitted.
|
||||
|
||||
#### Get Favorites Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"isAvailable": true,
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"title": "Bohemian Rhapsody",
|
||||
"collectionId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"collectionTitle": "A Night at the Opera",
|
||||
"creatorId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"creatorName": "Queen",
|
||||
"coverPath": "/media/music/Queen-3b3a19f3/A Night at the Opera-e8d52f7b/cover.jpg"
|
||||
},
|
||||
{
|
||||
"mediaKind": "Book",
|
||||
"mediaItemId": "4a5b6c7d-8e9f-4a0b-9c1d-2e3f4a5b6c7d",
|
||||
"isAvailable": true,
|
||||
"libraryId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
|
||||
"title": "The Hobbit",
|
||||
"collectionId": "00000000-0000-0000-0000-000000000000",
|
||||
"collectionTitle": "",
|
||||
"creatorId": "00000000-0000-0000-0000-000000000000",
|
||||
"creatorName": "J. R. R. Tolkien",
|
||||
"coverPath": null
|
||||
},
|
||||
{
|
||||
"mediaKind": "MusicAlbum",
|
||||
"mediaItemId": "0f1e2d3c-4b5a-4968-8776-5a4b3c2d1e0f",
|
||||
"isAvailable": false,
|
||||
"libraryId": "00000000-0000-0000-0000-000000000000",
|
||||
"title": "",
|
||||
"collectionId": "00000000-0000-0000-0000-000000000000",
|
||||
"collectionTitle": "",
|
||||
"creatorId": "00000000-0000-0000-0000-000000000000",
|
||||
"creatorName": "",
|
||||
"coverPath": null
|
||||
}
|
||||
],
|
||||
"currentPage": 1,
|
||||
"perPage": 200,
|
||||
"count": 3,
|
||||
"numberOfPages": 1
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `data` | The favorites of the page, from the most recently favorited. |
|
||||
| `currentPage` | The one based page number. |
|
||||
| `perPage` | The number of favorites per page. |
|
||||
| `count` | The number of favorites that match the `mediaKind` filter, even when only a page of them is returned. |
|
||||
| `numberOfPages` | The total number of pages. |
|
||||
|
||||
Each item carries the kind and Id of the favorited media item together with its display details. The display fields are generic across media kinds, and "no value" is the empty Guid or the empty string:
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `mediaKind` | The kind of the favorited media item. |
|
||||
| `mediaItemId` | The Id of the favorited media item. |
|
||||
| `isAvailable` | Whether the item still exists and its library is accessible to the user. When it is `false`, every display field below is empty. |
|
||||
| `libraryId` | The Id of the library that contains the item. |
|
||||
| `title` | The title of the item. |
|
||||
| `collectionId`, `collectionTitle` | The Id and the title of the collection the item belongs to. |
|
||||
| `creatorId`, `creatorName` | The Id and the name of the creator of the item. |
|
||||
| `coverPath` | The stored path of the cover art of the item, the same kind of value the artist, album and book resources expose as `coverPath`, or `null` when it has none. The cover of a track is the cover of its album. |
|
||||
|
||||
How the generic fields map to each kind:
|
||||
|
||||
| Kind | `title` | `collection` | `creator` |
|
||||
| --- | --- | --- | --- |
|
||||
| `MusicArtist` | The artist name. | None. | None. |
|
||||
| `MusicAlbum` | The album title. | None. | The artist. |
|
||||
| `MusicTrack` | The track title. | The album. | The artist. |
|
||||
| `Book` | The book title. | None today: the series of a book is not catalogued yet, so the collection is always empty. | The first author, by display name. |
|
||||
|
||||
An item whose display details no longer exist, because the item was deleted, or whose library the current user cannot access, is returned with `isAvailable` set to `false` and every display field empty. It stays in `data` and in `count`, so its owner can see it and remove it with [Remove Favorite](#remove-favorite), and the response never exposes display data from a library the user cannot reach. The Id of the media item is the one the user favorited, and carries no information beyond that.
|
||||
|
||||
### Get Favorite Status
|
||||
|
||||
#### Get Favorite Status Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/favorites/status?mediaKind=MusicTrack&mediaItemIds=9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f&mediaItemIds=8e9f0a1b-2c3d-4e5f-9a6b-7c8d9e0f1a2b
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Query parameter | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `mediaKind` | string | yes | The kind of every media item checked: `MusicArtist`, `MusicAlbum`, `MusicTrack` or `Book`. |
|
||||
| `mediaItemIds` | Guid, repeated | yes | The Ids of the media items to check, one `mediaItemIds` parameter per Id, from 1 to 100. None can be the empty Guid. Repeated Ids are checked once. |
|
||||
|
||||
Tells which of the given media items are favorites of the current user. It reads only the favorites of the current user and evaluates no library access, so the answer reveals nothing about any other user, and an Id that is not a favorite, does not exist or belongs to an inaccessible library is simply absent from the answer. A page that renders many favorite toggles uses it to hydrate all of them with one request per kind.
|
||||
|
||||
#### Get Favorite Status Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"favoritedMediaItemIds": [
|
||||
"9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `favoritedMediaItemIds` | The Ids, among the checked ones, that the current user favorited. Empty when none is. |
|
||||
|
||||
### Media Kinds
|
||||
|
||||
The media kind is stored by its name, together with the Id of the item.
|
||||
|
||||
| Kind | Status | Item |
|
||||
| --- | --- | --- |
|
||||
| `MusicArtist` | Supported | An artist of a music library. |
|
||||
| `MusicAlbum` | Supported | An album of a music library. |
|
||||
| `MusicTrack` | Supported | A track of a music library. |
|
||||
| `Book` | Supported | A book of a book library. |
|
||||
| `Video` | Planned | A video file. Video libraries are not catalogued yet. |
|
||||
| `Photo` | Planned | A photo. Photo libraries are not catalogued yet. |
|
||||
|
||||
### Scoping and Library Access
|
||||
|
||||
Every operation is scoped to the current user by the server: the user is read from the authenticated principal, never from the route, the query or the body, so a user cannot read or change the favorites of another user.
|
||||
|
||||
Adding a favorite also applies the library access rule. The server resolves the library that contains the item, through the catalogue of its kind, and then evaluates the library ownership policy of the current user for that library, exactly as the library routes do. An item that does not exist, and an item whose library is not accessible to the current user, are both reported with the same kind specific not found error, so the response cannot be used to find out whether an item exists in a library of another user. The not found error depends on the kind:
|
||||
|
||||
| Kind | Not found error |
|
||||
| --- | --- |
|
||||
| `MusicArtist` | `ArtistNotFound` |
|
||||
| `MusicAlbum` | `AlbumNotFound` |
|
||||
| `MusicTrack` | `TrackNotFound` |
|
||||
| `Book` | `BookNotFound` |
|
||||
|
||||
Removing, and checking the status of, favorites do not evaluate the rule, because they only touch the favorites of the current user. Listing evaluates the rule once for each distinct library among the items of the page, and an item of an inaccessible library is returned as unavailable, as described in [Get Favorites Response](#get-favorites-response).
|
||||
|
||||
### Errors
|
||||
|
||||
Errors are returned as problem details. A request without a valid token is rejected with `401 Unauthorized` before it reaches the operation.
|
||||
|
||||
| Status | Error | When |
|
||||
| --- | --- | --- |
|
||||
| `401` | | The request carries no token, or an invalid or expired one. The body is a problem whose `title` is `Unauthorized` and whose `detail` says why, for example `The token has expired`. |
|
||||
| `403` | `NotAuthorized` | The authenticated principal carries no user identity. |
|
||||
| `404` | `ArtistNotFound` | [Add Favorite](#add-favorite) of a `MusicArtist` that does not exist or whose library the user cannot access. |
|
||||
| `404` | `AlbumNotFound` | [Add Favorite](#add-favorite) of a `MusicAlbum` that does not exist or whose library the user cannot access. |
|
||||
| `404` | `TrackNotFound` | [Add Favorite](#add-favorite) of a `MusicTrack` that does not exist or whose library the user cannot access. |
|
||||
| `404` | `BookNotFound` | [Add Favorite](#add-favorite) of a `Book` that does not exist or whose library the user cannot access. |
|
||||
| `409` | `ConcurrencyConflict` | The storage reported a busy or locked database while the change was saved. Repeating the request is safe. |
|
||||
| `422` | see below | The request failed validation. |
|
||||
|
||||
The `404` and `409` problems carry the generic error code in `title` and the specific name in `detail`:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "General.NotFound",
|
||||
"status": 404,
|
||||
"detail": "TrackNotFound",
|
||||
"instance": "/api/v1/users/me/favorites",
|
||||
"traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
|
||||
}
|
||||
```
|
||||
|
||||
A request that fails validation is rejected with `422 Unprocessable Entity` and a validation problem whose `errors` object lists the names of the validation errors under the generic `General.Validation` code:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "General.Validation",
|
||||
"status": 422,
|
||||
"detail": "OneOrMoreValidationErrorsOccurred",
|
||||
"instance": "/api/v1/users/me/favorites",
|
||||
"errors": {
|
||||
"General.Validation": [
|
||||
"FavoriteMediaKindIsNotSupported"
|
||||
]
|
||||
},
|
||||
"traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
|
||||
}
|
||||
```
|
||||
|
||||
The validation errors of each operation are:
|
||||
|
||||
| Error | Operation | When |
|
||||
| --- | --- | --- |
|
||||
| `FavoriteMediaKindIsInvalid` | Add, Remove, Get Favorites, Get Favorite Status | The kind is missing where it is required, the kind is `None`, or it is a number that is not a member of the media kind enumeration. In the Remove route, the segment is not a member name of the enumeration, and numbers are not accepted. |
|
||||
| `FavoriteMediaKindIsNotSupported` | Add | The kind is `Video` or `Photo`, which are planned and cannot be favorited yet. |
|
||||
| `FavoriteMediaItemIdCannotBeEmpty` | Add, Remove, Get Favorite Status | The item Id is missing or is the empty Guid. In the Remove route it is also reported when the segment is not a Guid. For the status request, any of the Ids is the empty Guid. |
|
||||
| `FavoriteMediaItemIdsCannotBeEmpty` | Get Favorite Status | No `mediaItemIds` were given. |
|
||||
| `FavoriteMediaItemIdsExceedMaximumCount` | Get Favorite Status | More than 100 Ids were given. |
|
||||
|
||||
A value that cannot be bound is not reported by the validators. This covers a `mediaKind` that is not a member of `FavoriteMediaKind` (for example `"Song"`, or a number outside the enumeration), an item Id that is not a Guid in the Add body or the status query, and a `currentPage` or `perPage` that is not an integer. The endpoints do not catch binding failures, so the request is answered by the exception handling middleware as a generic `500 Internal Server Error` problem, exactly like every other endpoint of the API that binds an enumeration or a number, and not with the `422` problem above. The web client never sends such values, because its proxy endpoints rebuild the query from typed values.
|
||||
|
||||
`FavoriteAlreadyExists` is defined among the favorites errors, but adding is idempotent, so no operation returns it. `FavoriteNotFound` remains defined for the storage read that follows an add, but removing is idempotent, so a remove request no longer returns it.
|
||||
|
||||
### Pagination Limits
|
||||
|
||||
| Limit | Value |
|
||||
| --- | --- |
|
||||
| Default per page of Get Favorites | 200 favorites, when a page is requested. |
|
||||
| Minimum per page of Get Favorites | 1 favorite. |
|
||||
| Maximum per page of Get Favorites | None. The server has no separate maximum page size, matching the other paginated collections of the API. |
|
||||
| Ids of one Get Favorite Status request | From 1 to 100, one kind per request. The Ids travel in the query string, so the limit keeps the request line under the 8 KB default of Kestrel. |
|
||||
|
||||
The limits bound a response or a request, not the number of favorites a user can have. A client that needs more than 100 Ids checked splits them into several requests, as the bundled web client does.
|
||||
@@ -296,6 +296,7 @@ POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"artistName": "Queen",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
@@ -376,6 +377,7 @@ POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -454,6 +456,7 @@ POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -559,6 +562,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"artistName": "Queen",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
@@ -639,6 +643,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -717,6 +722,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -861,6 +867,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"artistName": "Queen",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
@@ -941,6 +948,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -1019,6 +1027,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -1203,6 +1212,7 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"artistName": "Queen",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
@@ -1283,6 +1293,7 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -1361,6 +1372,7 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -1511,6 +1523,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
|
||||
@@ -518,6 +518,7 @@ POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -596,6 +597,7 @@ POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -865,6 +867,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists?currentPage=1&
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -943,6 +946,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists?currentPage=1&
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -1252,6 +1256,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -1330,6 +1335,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
@@ -1916,6 +1922,7 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -1994,6 +2001,7 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
|
||||
@@ -8,6 +8,18 @@
|
||||
- [Get Track](#get-track)
|
||||
- [Get Track Request](#get-track-request)
|
||||
- [Get Track Response](#get-track-response)
|
||||
- [Shuffle Tracks](#shuffle-tracks)
|
||||
- [Shuffle Tracks Request](#shuffle-tracks-request)
|
||||
- [Shuffle Tracks Response](#shuffle-tracks-response)
|
||||
- [Stream Track](#stream-track)
|
||||
- [Stream Track Request](#stream-track-request)
|
||||
- [Stream Track Response](#stream-track-response)
|
||||
- [Stream Track Segment](#stream-track-segment)
|
||||
- [Stream Track Segment Request](#stream-track-segment-request)
|
||||
- [Stream Track Segment Response](#stream-track-segment-response)
|
||||
- [Get Playback Manifest](#get-playback-manifest)
|
||||
- [Get Playback Manifest Request](#get-playback-manifest-request)
|
||||
- [Get Playback Manifest Response](#get-playback-manifest-response)
|
||||
- [Update Track](#update-track)
|
||||
- [Update Track Request](#update-track-request)
|
||||
- [Update Track Response](#update-track-response)
|
||||
@@ -126,6 +138,7 @@ POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -228,6 +241,7 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -310,6 +324,167 @@ GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
```
|
||||
|
||||
|
||||
### Shuffle Tracks
|
||||
|
||||
#### Shuffle Tracks Request
|
||||
|
||||
```js
|
||||
POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/tracks/shuffle
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"count": 100,
|
||||
"artistId": null,
|
||||
"albumId": null,
|
||||
"excludedTrackIds": [
|
||||
"9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Returns a uniformly random selection of tracks from every track of the library, optionally scoped to one artist or one album, and excludes the tracks in `excludedTrackIds`. The database picks the rows at random, so the result is not limited to the albums or artists that happen to be stored or loaded first. `count` must be between 1 and 500. When `artistId` is present, only tracks whose album belongs to that artist are sampled; when `albumId` is present, only tracks of that album are sampled. The tracks are returned to an Admin, who can shuffle all libraries, or to the owner of the library.
|
||||
|
||||
#### Shuffle Tracks Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"trackId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"title": "Bohemian Rhapsody",
|
||||
"durationInSeconds": 354,
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"albumTitle": "A Night at the Opera",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"coverPath": "\\media\\music\\music-3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a\\QUEEN\\Album\\A night at the opera-e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f\\cover.jpg"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
The response holds at most `count` tracks, and fewer when the scope has fewer tracks that are not excluded. A repeated request returns a different random selection and a different order.
|
||||
|
||||
|
||||
### Stream Track
|
||||
|
||||
#### Stream Track Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/stream
|
||||
Authorization: Bearer <token>
|
||||
Range: bytes=0-1048575
|
||||
```
|
||||
|
||||
Streams the audio file of the track identified by the route, with HTTP range support. The `Range` header is optional: without it the whole file is streamed, and with it only the requested range is streamed, so that a player can start playback before the whole file is downloaded and can seek within the file. The audio file is streamed to an Admin, who can stream the tracks of all libraries, or to the owner of the library of the track.
|
||||
|
||||
#### Stream Track Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
or, when a range is requested:
|
||||
|
||||
```js
|
||||
206 Partial Content
|
||||
Content-Range: bytes 0-1048575/3542771
|
||||
Accept-Ranges: bytes
|
||||
```
|
||||
|
||||
The response is the raw bytes of the audio file, served with the media type of the file when it is an audio type, or `application/octet-stream` otherwise. Every response carries `X-Content-Type-Options: nosniff`, `Cache-Control: private` and `Vary: Authorization`, together with a `Last-Modified` and an `ETag` derived from the size and the modification time of the file.
|
||||
|
||||
|
||||
### Stream Track Segment
|
||||
|
||||
#### Stream Track Segment Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/stream/deliveries/8f14e45fceea167a5a36dedd4bea2543/segments/0
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
Streams one segment of the normalized audio of the track identified by the route. A track the player cannot play as it is stored is delivered as time addressed segments instead of bytes: the server produces the whole track into a temporary cache with a target segment duration of `segmentDurationSeconds` seconds, cutting at the first packet at or after each target boundary, and serves each produced segment as an independent container file. A real segment start can therefore differ from an exact multiple of the target duration, and a consumer must use the start the response reports rather than assume the grid. The segment index is zero based.
|
||||
|
||||
The `deliveryId` is the opaque handle the playback manifest reported in `deliveryId`. It is bound to the user the manifest was issued to and to the track it describes, and it captures the delivery decision, the quality cap, the source file version and the library content locations the manifest declared. The segment route resolves that handle instead of recomputing the delivery from a capability list, so the segments always belong to exactly the delivery the manifest declared. Library ownership is re-evaluated on every segment request, so revoked access stops playback immediately; the track membership and the content locations are the ones captured at manifest time, so a deleted track row whose file remains, or a removed content location, stays streamable until the handle expires, within 12 hours. A handle that is unknown, expired, or was issued to another user or track is reported as not found. A track the manifest declared as a direct play has no delivery handle at all, so a segment request for it is also reported as not found with `PlaybackDeliveryNotFound`, never as the end of the audio. A source file that changed since the manifest declared the delivery is reported as a conflict instead of starting a second production. The handle is exactly 32 lowercase hexadecimal characters, and a value that does not match that format is rejected rather than normalized into another handle.
|
||||
|
||||
A byte range cannot be mapped to a time in this delivery, so a player seeks by choosing the segment that covers the target time. A segment is a small independent container file that is already fetched as a whole, so the player reads it from its first packet and discards the packets that end before the target; it never seeks inside the container itself, because a container that numbers its frames across the whole track would then add that number to the segment offset twice. The playback manifest reports the root relative path of this route in `segmentStreamPathTemplate`, with `{deliveryId}` and `{segmentIndex}` placeholders, and the player expands both from the manifest. A segment is served to an Admin, who can stream the tracks of all libraries, or to the owner of the library of the track.
|
||||
|
||||
#### Stream Track Segment Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
Content-Type: audio/aac
|
||||
Content-Length: 240128
|
||||
```
|
||||
|
||||
The response is the raw bytes of one produced segment, served with the media type of the delivered container when the server can name it, or `application/octet-stream` otherwise. Every response carries `X-Content-Type-Options: nosniff`, `Cache-Control: private, no-store`, `Vary: Authorization`, `X-Lumina-Segment-Count`, the number of segments the production holds, and `X-Segment-Start-Seconds`, the exact start of the segment on the track timeline, in seconds. The count tells a player where the audio ends without probing for the end with a request that returns not found, and the start lets it offset the packets of a container that numbers its frames from the start of the track, instead of assuming that a segment starts at an exact multiple of its duration. Range requests are not used: the segment is the addressing unit, and the next segment is a separate request. The first request for a track can take longer than the following ones, because the whole normalized audio is produced and cached before its first segment is published. A segment index that the production does not hold is reported as not found with the `NormalizedTrackSegmentNotFound` detail, which is the only not-found answer that means the end of the audio. A track, library or audio file that disappeared, a delivery handle that is unknown, expired, or was issued to another user or track, and a cache entry that was evicted, are reported with their own not-found details instead, and a request that arrives while every normalization job slot is in use is reported as unavailable (`503`), because it is a transient condition that a player retries. A delivery handle whose captured shape is not time addressed segments is a conflict (`409`), because the segment route cannot index it.
|
||||
|
||||
|
||||
### Get Playback Manifest
|
||||
|
||||
#### Get Playback Manifest Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/playback-manifest?capabilities=mp3/mp3,flac/flac,ogg/opus,ogg/vorbis,wav/pcm,mp4/aac
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
Returns the playback manifest of the track identified by the route: the format of its stored audio, the delivery the server decided on for the requesting player, and the path of its stream, so that a player is told what to fetch and how before it fetches any audio. The `capabilities` query parameter is optional, and its value is a comma separated list of the `container/codec` pairs the player advertises it can demux and decode directly, matched case insensitively, with at most 32 pairs read from one request. When the parameter is absent, empty, or lists no valid pair, the default capabilities of the bundled player apply. The manifest is returned to an Admin, who can build the manifest of the tracks of all libraries, or to the owner of the library of the track.
|
||||
|
||||
#### Get Playback Manifest Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"trackId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"durationInSeconds": 354,
|
||||
"sourceContainer": "FLAC",
|
||||
"sourceCodec": "FLAC",
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"replayGainTrackGain": -7.5,
|
||||
"replayGainTrackPeak": 0.9877,
|
||||
"replayGainAlbumGain": -6.8,
|
||||
"replayGainAlbumPeak": 0.9999,
|
||||
"isDirectPlay": true,
|
||||
"deliveryContainer": null,
|
||||
"deliveryCodec": null,
|
||||
"deliveryShape": null,
|
||||
"segmentDurationSeconds": null,
|
||||
"isSeekable": true,
|
||||
"streamPath": "/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/stream",
|
||||
"deliveryId": null,
|
||||
"segmentStreamPathTemplate": null
|
||||
}
|
||||
```
|
||||
|
||||
When the player can play the stored audio as it is, `isDirectPlay` is `true`, and `deliveryContainer`, `deliveryCodec`, `deliveryShape`, `segmentDurationSeconds`, `deliveryId` and `segmentStreamPathTemplate` are `null`, because the delivery is the stored file itself, addressed and seeked by byte range. When it cannot, `isDirectPlay` is `false`, and those fields name the container, the codec, the addressing the server produces instead, the length in seconds of each of its time addressed segments, the opaque handle of the delivery, and the root relative path template of the segment route, with `{deliveryId}` and `{segmentIndex}` placeholders. `durationInSeconds` is the probed duration; a normalized production can be slightly longer or shorter, and its exact produced duration is reported by the `X-Lumina-Track-Duration-Seconds` header of its segments. A normalized delivery is always addressed as `TimeAddressedSegments`, and `segmentDurationSeconds` is the nominal length of each of its segments, so that the server that produces the segments and the player that consumes them agree on the target without duplicating the value on both sides. The `deliveryId` binds the delivery to the user and the track, and it captures the quality cap and the source file version that were in effect when the manifest was read, so a segment request addresses exactly that delivery instead of recomputing it. A player that cannot play a track directly fetches each segment from that template in index order and seeks by segment index, never by byte range. `isSeekable` reports whether the delivered audio can be seeked by the player. `streamPath` is relative to the API, without a host or a scheme, so that a client reaches the stream through its own application rather than the API server directly.
|
||||
|
||||
For example, a delivery of a track the player cannot decode is declared as follows:
|
||||
|
||||
```json
|
||||
{
|
||||
"trackId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"isDirectPlay": false,
|
||||
"deliveryContainer": "AAC",
|
||||
"deliveryCodec": "AAC",
|
||||
"deliveryShape": "TimeAddressedSegments",
|
||||
"segmentDurationSeconds": 6,
|
||||
"isSeekable": true,
|
||||
"streamPath": "/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/stream",
|
||||
"deliveryId": "8f14e45fceea167a5a36dedd4bea2543",
|
||||
"segmentStreamPathTemplate": "/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/stream/deliveries/{deliveryId}/segments/{segmentIndex}"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Update Track
|
||||
|
||||
#### Update Track Request
|
||||
@@ -320,7 +495,6 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
|
||||
```json
|
||||
{
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
@@ -421,6 +595,7 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"container": "FLAC",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
|
||||
@@ -65,6 +65,8 @@ POST api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": []
|
||||
}
|
||||
```
|
||||
@@ -90,6 +92,8 @@ POST api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -126,6 +130,8 @@ GET api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -163,6 +169,8 @@ GET api/v1/libraries/enabled
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -199,6 +207,8 @@ GET api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
@@ -228,6 +238,8 @@ PUT api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": []
|
||||
}
|
||||
```
|
||||
@@ -253,6 +265,8 @@ PUT api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
|
||||
@@ -0,0 +1,594 @@
|
||||
# Lumina API
|
||||
|
||||
- [Lumina API](#lumina-api)
|
||||
- [Library Statistics](#library-statistics)
|
||||
- [When a Session Counts](#when-a-session-counts)
|
||||
- [Get Recently Consumed](#get-recently-consumed)
|
||||
- [Get Recently Consumed Request](#get-recently-consumed-request)
|
||||
- [Get Recently Consumed Response](#get-recently-consumed-response)
|
||||
- [Get Most Consumed](#get-most-consumed)
|
||||
- [Get Most Consumed Request](#get-most-consumed-request)
|
||||
- [Get Most Consumed Response](#get-most-consumed-response)
|
||||
- [Get Consumption Statistics](#get-consumption-statistics)
|
||||
- [Get Consumption Statistics Request](#get-consumption-statistics-request)
|
||||
- [Get Consumption Statistics Response](#get-consumption-statistics-response)
|
||||
- [Get All Users Consumption Statistics](#get-all-users-consumption-statistics)
|
||||
- [Get All Users Consumption Statistics Request](#get-all-users-consumption-statistics-request)
|
||||
- [Get All Users Consumption Statistics Response](#get-all-users-consumption-statistics-response)
|
||||
- [Get Tag Consumption](#get-tag-consumption)
|
||||
- [Get Tag Consumption Request](#get-tag-consumption-request)
|
||||
- [Get Tag Consumption Response](#get-tag-consumption-response)
|
||||
- [Get Genre Consumption](#get-genre-consumption)
|
||||
- [Get Genre Consumption Request](#get-genre-consumption-request)
|
||||
- [Get Genre Consumption Response](#get-genre-consumption-response)
|
||||
- [Delete Consumption Record](#delete-consumption-record)
|
||||
- [Delete Consumption Record Request](#delete-consumption-record-request)
|
||||
- [Delete Consumption Record Response](#delete-consumption-record-response)
|
||||
- [Delete Consumption Item History](#delete-consumption-item-history)
|
||||
- [Delete Consumption Item History Request](#delete-consumption-item-history-request)
|
||||
- [Delete Consumption Item History Response](#delete-consumption-item-history-response)
|
||||
- [Clear Consumption History](#clear-consumption-history)
|
||||
- [Clear Consumption History Request](#clear-consumption-history-request)
|
||||
- [Clear Consumption History Response](#clear-consumption-history-response)
|
||||
- [Clear Resume Points](#clear-resume-points)
|
||||
- [Clear Resume Points Request](#clear-resume-points-request)
|
||||
- [Clear Resume Points Response](#clear-resume-points-response)
|
||||
- [Pagination](#pagination)
|
||||
- [Scoping and Authorization](#scoping-and-authorization)
|
||||
- [Private Responses](#private-responses)
|
||||
- [Errors](#errors)
|
||||
- [Concurrency](#concurrency)
|
||||
|
||||
## Library Statistics
|
||||
|
||||
The library statistics read the media consumption history and aggregate it in the application layer. They are media neutral: music and book sessions appear in the same lists and the same summary, and the planned kinds use the same routes when their catalogues exist. The statistics never read a stored counter. Every response is computed from the consumption records on the request, so deleting history changes the statistics immediately, and a changed counting rule applies to the whole history at once. The lifecycle that creates the records, and the read of one resume point, are documented in [Media Consumption](../../media-consumption/Api.MediaConsumption.md).
|
||||
|
||||
The consumed duration is the active listening, watching or reading time reported by the session. It is totalled over every recorded session, including the sessions that do not count towards the statistics, because the time was consumed regardless. The counted sessions, completed sessions, stopped sessions and completion rate use the counting rules below.
|
||||
|
||||
### When a Session Counts
|
||||
|
||||
A session counts towards the statistics when its media kind's rule says so:
|
||||
|
||||
| Media kind | A session counts when |
|
||||
| --- | --- |
|
||||
| `MusicTrack` | The session completed, or the consumed duration is at least 30 seconds |
|
||||
| `PodcastEpisode` | The session completed, or the consumed duration is at least 30 seconds |
|
||||
| `Audiobook` | The session completed, or the consumed duration is at least 60 seconds |
|
||||
| `Movie` | The session completed, or the consumed duration is at least 3 minutes |
|
||||
| `TvEpisode` | The session completed, or the consumed duration is at least 3 minutes |
|
||||
| `Book` | The session completed, or more than 5 consecutive pages were read |
|
||||
| `Photo` | Every session counts |
|
||||
| `Video` | The session completed, or the consumed duration is at least 3 minutes |
|
||||
|
||||
A completed session always counts. A stopped session counts only when it reaches the rule of its kind. A book with 5 consecutive pages does not count, while one with 6 does. The counting rule is separate from the library completion threshold: a session can count as consumed without the library considering the item complete.
|
||||
|
||||
### Get Recently Consumed
|
||||
|
||||
#### Get Recently Consumed Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/consumption-history/recently-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can read the history of another user by targeting the per-user route:
|
||||
|
||||
```js
|
||||
GET api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/recently-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Query parameter | Meaning |
|
||||
| --- | --- |
|
||||
| `libraryId` | Optional. The Id of a library to restrict the history to. It must be a non-empty Guid. |
|
||||
| `mediaKind` | Optional. The name of a media kind to restrict the history to, matched case insensitively. Only member names are accepted, so a numeric value is rejected even when it is a defined enumeration value. `None` is rejected. |
|
||||
| `currentPage` | Optional. The one based page of distinct media items to return. |
|
||||
| `perPage` | Optional. The number of distinct media items per page. |
|
||||
| `fromUtc` | Optional. The inclusive start of the history date range, in UTC. A trailing zone designator is honored and converted to UTC, while a value without one is interpreted as UTC. |
|
||||
| `toUtc` | Optional. The inclusive end of the history date range, in UTC. A trailing zone designator is honored and converted to UTC, while a value without one is interpreted as UTC. It must not be before `fromUtc`. |
|
||||
|
||||
The same query parameters apply to the per-user route. The route user is the target, and the access policy decides whether the caller may read it.
|
||||
|
||||
The records are grouped to one row per media kind, media item and library before ordering, so an item consumed many times appears once. The rows are ordered by the time of the latest activity, from the most recent, and ties are broken by media kind, media item Id and library Id.
|
||||
|
||||
#### Get Recently Consumed Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"isAvailable": true,
|
||||
"title": "The Show Must Go On",
|
||||
"collectionTitle": "Innuendo",
|
||||
"creatorName": "Queen",
|
||||
"coverPath": "/artwork/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/cover.jpg",
|
||||
"lastConsumedOnUtc": "2026-10-24T12:12:00.0000000Z",
|
||||
"countedSessionCount": 4,
|
||||
"completedSessionCount": 3,
|
||||
"consumedDurationInSeconds": 1424.5
|
||||
},
|
||||
{
|
||||
"mediaKind": "Book",
|
||||
"mediaItemId": "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d",
|
||||
"libraryId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
|
||||
"isAvailable": true,
|
||||
"title": "The Fellowship of the Ring",
|
||||
"collectionTitle": "",
|
||||
"creatorName": "J. R. R. Tolkien",
|
||||
"coverPath": "/artwork/books/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d/cover.jpg",
|
||||
"lastConsumedOnUtc": "2026-10-23T20:40:00.0000000Z",
|
||||
"countedSessionCount": 2,
|
||||
"completedSessionCount": 1,
|
||||
"consumedDurationInSeconds": 7320
|
||||
}
|
||||
],
|
||||
"currentPage": 1,
|
||||
"perPage": 50,
|
||||
"count": 2,
|
||||
"numberOfPages": 1
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `mediaKind` | string | The kind of the consumed media item. |
|
||||
| `mediaItemId` | Guid | The Id of the consumed media item. |
|
||||
| `libraryId` | Guid | The Id of the library recorded with the sessions. |
|
||||
| `isAvailable` | boolean | Whether the item still exists and its library is accessible to the current user. |
|
||||
| `title` | string | The title of the item, or an empty string when it is not available. |
|
||||
| `collectionTitle` | string | The album title of a track, or an empty string when there is none. Books have no collection title. |
|
||||
| `creatorName` | string | The artist of a track, or the name of one of a book's authors chosen alphabetically, or an empty string when there is none. |
|
||||
| `coverPath` | string? | The path of the cover art, or `null` when there is none. |
|
||||
| `lastConsumedOnUtc` | DateTime | The time of the latest recorded activity of the item. |
|
||||
| `countedSessionCount` | integer | The sessions of the item that count towards the statistics. |
|
||||
| `completedSessionCount` | integer | The sessions of the item that completed. |
|
||||
| `consumedDurationInSeconds` | number | The active duration consumed in the item over all of its sessions, in seconds. |
|
||||
|
||||
A deleted item, an item whose library was deleted, and an item in a library the current user can no longer access keep their identity, counts and duration, but are returned with `isAvailable` set to `false`, blank display fields and no cover. This lets the user see the history row and delete it. An item that moved to another library after it was consumed is also reported as unavailable for the recorded library, because the display data of the recorded library cannot be shown for it.
|
||||
|
||||
### Get Most Consumed
|
||||
|
||||
#### Get Most Consumed Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/consumption-history/most-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can read the most consumed items of another user:
|
||||
|
||||
```js
|
||||
GET api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/most-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
The query parameters are those of [Get Recently Consumed](#get-recently-consumed-request). The records are grouped to one row per media kind, media item and library, then ordered by counted sessions, then by consumed duration, then by the latest activity, all descending, with the media item Id, media kind and library Id as the tiebreakers.
|
||||
|
||||
#### Get Most Consumed Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
The response has the same shape as [Get Recently Consumed Response](#get-recently-consumed-response), ordered from the most consumed.
|
||||
|
||||
### Get Consumption Statistics
|
||||
|
||||
#### Get Consumption Statistics Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/consumption-statistics?fromUtc=2026-10-01T00:00:00Z&toUtc=2026-10-31T23:59:59Z
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can read the statistics of another user:
|
||||
|
||||
```js
|
||||
GET api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-statistics?fromUtc=2026-10-01T00:00:00Z&toUtc=2026-10-31T23:59:59Z
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Query parameter | Meaning |
|
||||
| --- | --- |
|
||||
| `libraryId` | Optional. The Id of a library to restrict the statistics to. It must be a non-empty Guid. |
|
||||
| `mediaKind` | Optional. The name of a media kind to restrict the statistics to, matched case insensitively. Only member names are accepted, so a numeric value is rejected even when it is a defined enumeration value. `None` is rejected. |
|
||||
| `fromUtc` | Optional. The inclusive start of the date range, in UTC. A trailing zone designator is honored and converted to UTC, while a value without one is interpreted as UTC. |
|
||||
| `toUtc` | Optional. The inclusive end of the date range, in UTC. A trailing zone designator is honored and converted to UTC, while a value without one is interpreted as UTC. It must not be before `fromUtc`. |
|
||||
|
||||
#### Get Consumption Statistics Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"userId": "2cff0c0f-3a67-4e30-b94f-f4e948a3b64f",
|
||||
"totalConsumedDurationInSeconds": 12840.5,
|
||||
"countedSessionCount": 62,
|
||||
"completedSessionCount": 41,
|
||||
"stoppedSessionCount": 21,
|
||||
"completionRate": 0.6612903,
|
||||
"mediaKindSummaries": [
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"totalConsumedDurationInSeconds": 5520.5,
|
||||
"countedSessionCount": 60,
|
||||
"completedSessionCount": 40,
|
||||
"stoppedSessionCount": 20,
|
||||
"completionRate": 0.6666667
|
||||
},
|
||||
{
|
||||
"mediaKind": "Book",
|
||||
"totalConsumedDurationInSeconds": 7320,
|
||||
"countedSessionCount": 2,
|
||||
"completedSessionCount": 1,
|
||||
"stoppedSessionCount": 1,
|
||||
"completionRate": 0.5
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `userId` | Guid | The user the statistics belong to. |
|
||||
| `totalConsumedDurationInSeconds` | number | The consumed duration over every recorded session, in seconds. Sessions below the counting threshold are included. |
|
||||
| `countedSessionCount` | integer | The sessions that count towards the statistics. |
|
||||
| `completedSessionCount` | integer | The recorded sessions that completed. |
|
||||
| `stoppedSessionCount` | integer | The counted sessions that stopped before completing. |
|
||||
| `completionRate` | number | The completed sessions divided by the counted sessions, between 0 and 1, or 0 when no session counts. |
|
||||
| `mediaKindSummaries` | array | The same fields, without `userId`, broken down by media kind, ordered by media kind. |
|
||||
|
||||
The overall totals are the sums of the per-kind summaries, so the completion rate never disagrees with the breakdown. When no record matches, every total is 0 and the breakdown is an empty array.
|
||||
|
||||
### Get All Users Consumption Statistics
|
||||
|
||||
#### Get All Users Consumption Statistics Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/consumption-statistics?fromUtc=2026-10-01T00:00:00Z&toUtc=2026-10-31T23:59:59Z
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
The same optional `libraryId`, `mediaKind`, `fromUtc` and `toUtc` filters apply. Only an administrator can call this route. It is the only statistics route that loads the records of every user.
|
||||
|
||||
#### Get All Users Consumption Statistics Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"total": {
|
||||
"totalConsumedDurationInSeconds": 12840.5,
|
||||
"countedSessionCount": 62,
|
||||
"completedSessionCount": 41,
|
||||
"stoppedSessionCount": 21,
|
||||
"completionRate": 0.6612903,
|
||||
"mediaKindSummaries": [
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"totalConsumedDurationInSeconds": 5520.5,
|
||||
"countedSessionCount": 60,
|
||||
"completedSessionCount": 40,
|
||||
"stoppedSessionCount": 20,
|
||||
"completionRate": 0.6666667
|
||||
},
|
||||
{
|
||||
"mediaKind": "Book",
|
||||
"totalConsumedDurationInSeconds": 7320,
|
||||
"countedSessionCount": 2,
|
||||
"completedSessionCount": 1,
|
||||
"stoppedSessionCount": 1,
|
||||
"completionRate": 0.5
|
||||
}
|
||||
]
|
||||
},
|
||||
"users": [
|
||||
{
|
||||
"userId": "2cff0c0f-3a67-4e30-b94f-f4e948a3b64f",
|
||||
"totalConsumedDurationInSeconds": 12840.5,
|
||||
"countedSessionCount": 62,
|
||||
"completedSessionCount": 41,
|
||||
"stoppedSessionCount": 21,
|
||||
"completionRate": 0.6612903,
|
||||
"mediaKindSummaries": [
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"totalConsumedDurationInSeconds": 5520.5,
|
||||
"countedSessionCount": 60,
|
||||
"completedSessionCount": 40,
|
||||
"stoppedSessionCount": 20,
|
||||
"completionRate": 0.6666667
|
||||
},
|
||||
{
|
||||
"mediaKind": "Book",
|
||||
"totalConsumedDurationInSeconds": 7320,
|
||||
"countedSessionCount": 2,
|
||||
"completedSessionCount": 1,
|
||||
"stoppedSessionCount": 1,
|
||||
"completionRate": 0.5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`total` carries the same fields as a user summary without `userId`, including its own `mediaKindSummaries` array, which combines the per-kind summaries of every user. `users` holds one summary per user that has a matching record, ordered by user Id. The all-users route returns no history lists and no tag or genre breakdown, because those are only meaningful per user.
|
||||
|
||||
### Get Tag Consumption
|
||||
|
||||
#### Get Tag Consumption Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/consumption-statistics/tags?mediaKind=MusicTrack
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can read the tag breakdown of another user:
|
||||
|
||||
```js
|
||||
GET api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-statistics/tags?mediaKind=MusicTrack
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
The optional `libraryId`, `mediaKind`, `fromUtc` and `toUtc` filters are the same as for [Get Consumption Statistics](#get-consumption-statistics-request).
|
||||
|
||||
#### Get Tag Consumption Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "fantasy",
|
||||
"consumedItemCount": 2,
|
||||
"consumedDurationInSeconds": 7320
|
||||
},
|
||||
{
|
||||
"name": "horror",
|
||||
"consumedItemCount": 1,
|
||||
"consumedDurationInSeconds": 1424.5
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
The records are grouped to one row per media kind, media item and library first, so an item with several sessions contributes its tags once, not once per session. A music track with no tags of its own contributes the tags of its album, and then the tags of its artist when the album has none. Only items in an accessible library with at least one counted session contribute. A name that appears twice on the same item contributes once. Names are normalized to lowercase, so `Horror` and `horror` share one bucket across media kinds. The rows are ordered by consumed item count, then consumed duration, both descending, with the name ascending as the tiebreaker. An item that no longer exists, or that moved to another library after it was consumed, does not contribute to the breakdown, because its terms cannot be resolved for the recorded library.
|
||||
|
||||
`consumedItemCount` is the number of distinct items that carry the tag, not the number of sessions. `consumedDurationInSeconds` is the consumed duration of those items, over all of their sessions.
|
||||
|
||||
### Get Genre Consumption
|
||||
|
||||
#### Get Genre Consumption Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/consumption-statistics/genres?mediaKind=Book
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can read the genre breakdown of another user:
|
||||
|
||||
```js
|
||||
GET api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-statistics/genres?mediaKind=Book
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
The optional `libraryId`, `mediaKind`, `fromUtc` and `toUtc` filters are the same as for [Get Consumption Statistics](#get-consumption-statistics-request).
|
||||
|
||||
#### Get Genre Consumption Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "fantasy",
|
||||
"consumedItemCount": 2,
|
||||
"consumedDurationInSeconds": 7320
|
||||
},
|
||||
{
|
||||
"name": "science fiction",
|
||||
"consumedItemCount": 1,
|
||||
"consumedDurationInSeconds": 1424.5
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
The genre breakdown follows the same item level aggregation, lowercase normalization, ordering and availability rules as the tag breakdown. A music track with no genres of its own contributes the genres of its album, and then the genres of its artist when the album has none.
|
||||
|
||||
### Delete Consumption Record
|
||||
|
||||
#### Delete Consumption Record Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/me/consumption-history/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can delete a record of another user:
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `recordId` | The Id of the consumption record to delete. It must be a non-empty Guid. |
|
||||
| `userId` | The owner of the record on the per-user route. An administrator can name any user; a regular user can only name themselves. |
|
||||
|
||||
The record is deleted hard. Deleting a record that does not exist, or that belongs to another user, succeeds without changing anything. The resume point of the item is not deleted, because the history and the resume point are separate actions.
|
||||
|
||||
#### Delete Consumption Record Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
The response body is an empty JSON object.
|
||||
|
||||
### Delete Consumption Item History
|
||||
|
||||
#### Delete Consumption Item History Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/me/consumption-history/media-items/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can delete every record of an item of another user:
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/media-items/Book/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `mediaKind` | The kind of the item. `None` is rejected. |
|
||||
| `mediaItemId` | The Id of the item. It must be a non-empty Guid. |
|
||||
| `libraryId` | The Id of the library recorded with the item. It must be a non-empty Guid. |
|
||||
| `userId` | The owner of the history on the per-user route. An administrator can name any user; a regular user can only name themselves. |
|
||||
|
||||
Every recorded session of the item in that library is deleted, not only the sessions inside a date range. The deletion is idempotent and leaves the resume point untouched.
|
||||
|
||||
#### Delete Consumption Item History Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
The response body is an empty JSON object.
|
||||
|
||||
### Clear Consumption History
|
||||
|
||||
#### Clear Consumption History Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/me/consumption-history
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can clear the whole history of another user:
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
Every consumption record of the target user is deleted. The deletion is idempotent and does not delete any resume point, so the continue watching list survives until the user removes it separately.
|
||||
|
||||
#### Clear Consumption History Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
The response body is an empty JSON object.
|
||||
|
||||
### Clear Resume Points
|
||||
|
||||
#### Clear Resume Points Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/me/media-resume-points?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
An administrator can clear the resume points of another user:
|
||||
|
||||
```js
|
||||
DELETE api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/media-resume-points
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Query parameter | Meaning |
|
||||
| --- | --- |
|
||||
| `libraryId` | Optional. The Id of a library to restrict the deletion to. It must be a non-empty Guid. When it is omitted, every resume point of the user is deleted. |
|
||||
|
||||
Clearing resume points deletes no history. The operation is idempotent.
|
||||
|
||||
#### Clear Resume Points Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
The response body is an empty JSON object.
|
||||
|
||||
### Pagination
|
||||
|
||||
The recently consumed and most consumed routes accept `currentPage` and `perPage`:
|
||||
|
||||
- When both are omitted, every matching item is returned in one page. `currentPage` is 1, `perPage` is the number of items, which is 0 when none match, and `numberOfPages` is 1.
|
||||
- When either is supplied, the other defaults to 1 for `currentPage` and 50 for `perPage`.
|
||||
- A page below 1 is treated as 1. A page size below 1 is treated as 1.
|
||||
- When at least one item matches, a page beyond the last one is clamped to the last page.
|
||||
- When a requested page matches no item, `count` is 0, `currentPage` is 1 and `numberOfPages` is 0.
|
||||
- `count` is the number of distinct items that match the filters, before pagination.
|
||||
|
||||
The statistics, tag and genre routes are not paginated, because their result is already an aggregate bounded by the number of media kinds, tags or genres.
|
||||
|
||||
### Scoping and Authorization
|
||||
|
||||
Every route in this document requires authentication.
|
||||
|
||||
- The `/users/me/...` routes always act on the current user. The identity comes from the authenticated principal, never from the route, query or body.
|
||||
- The `/users/{userId}/...` routes act on the named user. A regular user may name only themselves. Naming another user returns `403 NotAuthorized`, exactly like a route that names no accessible user, so the response cannot be used to find out whether a user or their history exists.
|
||||
- The `/users/consumption-statistics` route is only for administrators. A regular user receives `403 NotAuthorized`.
|
||||
- Administrator access is role based. The per-user routes evaluate the consumption activity access policy, which allows the owner or an administrator. The all-users route checks the administrator role directly. There is no separate permission toggle for consumption activity.
|
||||
|
||||
The statistics and lists never expose the history of another user to a regular user. Display data is resolved per distinct library through the library ownership policy. An item in a library the current user can no longer access keeps its counts but has blank display data, so the history lists reveal no inaccessible title, collection, creator or cover. The service wide totals never include the records of a user that the caller cannot target.
|
||||
|
||||
Deleting a record, every record of an item, the whole history, or the resume points belongs to the same access rule. An administrator can delete any user's consumption activity through the per-user routes, and a regular user can delete only their own. Reading a resume point is not part of this surface; it stays owner only, as documented in [Media Consumption](../../media-consumption/Api.MediaConsumption.md).
|
||||
|
||||
### Private Responses
|
||||
|
||||
Every response produced by these endpoints is private to the authenticated user, and each endpoint sets:
|
||||
|
||||
- `Cache-Control: private, no-store`
|
||||
- `Vary: Authorization`
|
||||
|
||||
The headers are set before the operation runs, so they are present on the endpoint's problem responses too. A request rejected by the authentication middleware with `401` before the endpoint runs is produced by the framework rather than by the endpoint.
|
||||
|
||||
### Errors
|
||||
|
||||
Errors are returned as problem details. A request without a valid token is rejected with `401 Unauthorized` before it reaches the operation.
|
||||
|
||||
| Status | Error | When |
|
||||
| --- | --- | --- |
|
||||
| `401` | | The request carries no token, or an invalid or expired one. |
|
||||
| `403` | `NotAuthorized` | The authenticated principal carries no user identity, a regular user targets another user, or a regular user calls the all-users route. |
|
||||
| `409` | `ConcurrencyConflict` | A deletion could not be stored because the database is busy or locked, or because another request changed the same row after this request read it. Repeating the request is safe. |
|
||||
| `422` | see below | The request failed validation. |
|
||||
|
||||
A request that fails validation is rejected with `422 Unprocessable Entity` and a validation problem whose `errors` object lists the validation error names under the generic `General.Validation` code.
|
||||
|
||||
| Error | Operation | When |
|
||||
| --- | --- | --- |
|
||||
| `TargetUserIdIsInvalid` | Per-user routes | The `userId` route value is not a non-empty Guid. |
|
||||
| `ConsumptionRecordIdCannotBeEmpty` | Delete record | The `recordId` route value is not a non-empty Guid. |
|
||||
| `MediaItemIdCannotBeEmpty` | Delete item history | The `mediaItemId` route value is the empty Guid. |
|
||||
| `LibraryIdCannotBeEmpty` | Statistics filters, delete item history, clear resume points | A supplied library Id is not a non-empty Guid. |
|
||||
| `UnsupportedMediaKind` | Statistics filters, delete item history | The supplied kind is `None` or is not a defined media kind. Omitting `mediaKind` is valid on the statistics filters. |
|
||||
| `ConsumptionDateRangeIsInvalid` | Statistics filters | A date bound is not a valid date, or `fromUtc` is after `toUtc`. |
|
||||
|
||||
A value that cannot be bound to the request type, such as a malformed route Id on delete item history, is rejected by the framework before these validators run. Media kind query filters are carried as text, so an unknown name reaches the validator and is reported as `UnsupportedMediaKind`.
|
||||
|
||||
### Concurrency
|
||||
|
||||
Deletions use the optimistic concurrency version stored on the consumption record and resume point entities. A deletion that races with another change is reported as `409 ConcurrencyConflict`, and a busy or locked SQLite write is reported the same way. Deleting an already absent record, item history or set of resume points succeeds, so a retried deletion is safe.
|
||||
@@ -0,0 +1,681 @@
|
||||
# Lumina API
|
||||
|
||||
- [Lumina API](#lumina-api)
|
||||
- [Media Consumption](#media-consumption)
|
||||
- [Start Consumption](#start-consumption)
|
||||
- [Start Consumption Request](#start-consumption-request)
|
||||
- [Start Consumption Response](#start-consumption-response)
|
||||
- [Get Consumption Record](#get-consumption-record)
|
||||
- [Get Consumption Record Request](#get-consumption-record-request)
|
||||
- [Get Consumption Record Response](#get-consumption-record-response)
|
||||
- [Report Consumption Progress](#report-consumption-progress)
|
||||
- [Report Consumption Progress Request](#report-consumption-progress-request)
|
||||
- [Report Consumption Progress Response](#report-consumption-progress-response)
|
||||
- [Complete Consumption](#complete-consumption)
|
||||
- [Complete Consumption Request](#complete-consumption-request)
|
||||
- [Complete Consumption Response](#complete-consumption-response)
|
||||
- [Stop Consumption](#stop-consumption)
|
||||
- [Stop Consumption Request](#stop-consumption-request)
|
||||
- [Stop Consumption Response](#stop-consumption-response)
|
||||
- [Get Resume Point](#get-resume-point)
|
||||
- [Get Resume Point Request](#get-resume-point-request)
|
||||
- [Get Resume Point Response](#get-resume-point-response)
|
||||
- [Media Kinds](#media-kinds)
|
||||
- [Session Statuses](#session-statuses)
|
||||
- [Position Kinds](#position-kinds)
|
||||
- [Reportable Ranges](#reportable-ranges)
|
||||
- [Session Lifecycle and Resume Points](#session-lifecycle-and-resume-points)
|
||||
- [Completion Threshold](#completion-threshold)
|
||||
- [Scoping and Authorization](#scoping-and-authorization)
|
||||
- [Private Responses](#private-responses)
|
||||
- [Errors](#errors)
|
||||
- [Concurrency](#concurrency)
|
||||
|
||||
## Media Consumption
|
||||
|
||||
The media consumption API records what the current user consumed, how far they reached, how long they consumed it, and where they can resume it. It is media neutral: the same routes serve a music track and a book, and every future catalogue uses the same routes without a per-kind endpoint. The statistics read these records; see [Library Statistics](../library/statistics/Api.LibraryStatistics.md) for the counting rules and the aggregated reads.
|
||||
|
||||
A consumption session is stored as a `MediaConsumptionRecord`. It carries the kind of media, the library and the item, the start and end times, the latest position and progress fraction, the active consumed duration, and the number of consecutive pages read for page based media. It is not a playback session: it stores no queue, no current index, no repeat or shuffle state, and it never restores playback.
|
||||
|
||||
A resume point is stored separately as a `MediaResumePoint`, with at most one row per user, media kind and media item. It carries the last known position, the last progress fraction, and when the item was last consumed. Completion deletes it. A session that stops without completing can keep it, depending on the library settings.
|
||||
|
||||
All the routes in this document require authentication and act on the current user. No route or body accepts a user Id. The lifecycle writes are owner only: an admin cannot progress, complete or stop another user's session.
|
||||
|
||||
The supported media kinds are `MusicTrack` and `Book`. The other kinds are planned and are rejected until their catalogues exist, see [Media Kinds](#media-kinds).
|
||||
|
||||
All responses are private to the authenticated user, including the endpoint problem responses, see [Private Responses](#private-responses).
|
||||
|
||||
### Start Consumption
|
||||
|
||||
#### Start Consumption Request
|
||||
|
||||
```js
|
||||
POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/media-items/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/consumption-records
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
The same operation starts a book session:
|
||||
|
||||
```js
|
||||
POST api/v1/libraries/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f/media-items/Book/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d/consumption-records
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `libraryId` | The Id of the media library that contains the item. It must be a Guid and cannot be the empty Guid. |
|
||||
| `mediaKind` | The kind of media, matched case insensitively. Only the member names are accepted: `MusicTrack` and `Book` for now. Numeric values such as `1`, `6` or `0` are rejected, even when they are defined enumeration values. |
|
||||
| `mediaItemId` | The Id of the consumed item. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
Starts a consumption session for the item named by the route. The request has no body: every identifier is taken from the route, so a client cannot substitute the library, kind or item with a body value.
|
||||
|
||||
The operation validates the request, requires the current user, and evaluates the library ownership policy for the route library. The library is then loaded, and the item is resolved through the catalogue repository of its kind. The item must exist and must belong to the route library. A missing item, an item that belongs to another library, and an item of another kind are reported with the same kind specific not found error, so the route cannot be used to probe another library or another kind.
|
||||
|
||||
When the library tracks progress and the kind can resume, the new session starts from the stored resume point: the record's `lastPosition` and `lastProgressFraction` are initialized from it, and `consecutivePagesRead` starts at zero. The consumed duration always starts at zero, because it measures this session only. When tracking is off, or when there is no stored resume point, the session starts with a null position and a zero progress fraction.
|
||||
|
||||
The start operation records the session immediately and returns its identifier. A new session of a one-shot kind such as a photo would be created completed in the same call, but one-shot kinds are not supported by the current catalogues, so they are rejected before that branch is reached.
|
||||
|
||||
#### Start Consumption Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
A music track with no stored resume point:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"mediaKind": "MusicTrack",
|
||||
"status": "InProgress",
|
||||
"startedOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"lastActivityOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"endedOnUtc": null,
|
||||
"consumedDurationInSeconds": 0,
|
||||
"lastPosition": null,
|
||||
"lastProgressFraction": 0,
|
||||
"consecutivePagesRead": 0
|
||||
}
|
||||
```
|
||||
|
||||
A book with a stored resume point:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"libraryId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
|
||||
"mediaItemId": "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d",
|
||||
"mediaKind": "Book",
|
||||
"status": "InProgress",
|
||||
"startedOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"lastActivityOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"endedOnUtc": null,
|
||||
"consumedDurationInSeconds": 0,
|
||||
"lastPosition": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/4[chapter-3]!/4/2/2)"
|
||||
},
|
||||
"lastProgressFraction": 0.42,
|
||||
"consecutivePagesRead": 0
|
||||
}
|
||||
```
|
||||
|
||||
The returned `id` identifies the session in the get, progress, complete and stop routes.
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `id` | Guid | The Id of the consumption record. |
|
||||
| `libraryId` | Guid | The Id of the library that contains the consumed item. |
|
||||
| `mediaItemId` | Guid | The Id of the consumed item. |
|
||||
| `mediaKind` | string | The kind of media: `MusicTrack` or `Book` today. |
|
||||
| `status` | string | The state of the session: `InProgress`, `Completed` or `Stopped`. |
|
||||
| `startedOnUtc` | DateTime | When the session started. |
|
||||
| `lastActivityOnUtc` | DateTime | When the session last received a progress, complete or stop request. |
|
||||
| `endedOnUtc` | DateTime? | When the session completed or stopped, or `null` while it is in progress. |
|
||||
| `consumedDurationInSeconds` | number | The active duration consumed by the session, in seconds. It starts at zero and never decreases. |
|
||||
| `lastPosition` | object? | The latest known position, or `null` when there is none. See [Position Kinds](#position-kinds). |
|
||||
| `lastProgressFraction` | number | The latest reported progress fraction, from 0 to 1. It may move backwards. |
|
||||
| `consecutivePagesRead` | integer | The number of consecutive pages read in this session. It is zero for every kind except page based media such as books. |
|
||||
|
||||
The start response is `200 Ok`. A wrong-library item and a missing item return the same `TrackNotFound` or `BookNotFound` error. A missing library returns `LibraryNotFound`. Starting in a library the current user cannot access returns `NotAuthorized`.
|
||||
|
||||
### Get Consumption Record
|
||||
|
||||
#### Get Consumption Record Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `recordId` | The Id of the consumption record. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
Returns the consumption record identified by the route, when it belongs to the current user. A record of another user is reported as not found, exactly like a record that does not exist, so a guessed identifier never reveals the existence of another user's session.
|
||||
|
||||
#### Get Consumption Record Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"libraryId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
|
||||
"mediaItemId": "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d",
|
||||
"mediaKind": "Book",
|
||||
"status": "Stopped",
|
||||
"startedOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"lastActivityOnUtc": "2026-10-24T12:12:00.0000000Z",
|
||||
"endedOnUtc": "2026-10-24T12:12:00.0000000Z",
|
||||
"consumedDurationInSeconds": 720,
|
||||
"lastPosition": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/4[chapter-3]!/4/2/2)"
|
||||
},
|
||||
"lastProgressFraction": 0.42,
|
||||
"consecutivePagesRead": 6
|
||||
}
|
||||
```
|
||||
|
||||
The response is a `ConsumptionRecordResponse` with the fields listed in [Start Consumption Response](#start-consumption-response). A record of another user, and a record that does not exist, are both reported with `ConsumptionRecordNotFound`.
|
||||
|
||||
### Report Consumption Progress
|
||||
|
||||
#### Report Consumption Progress Request
|
||||
|
||||
```js
|
||||
PUT api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/progress
|
||||
Authorization: Bearer <token>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
A music track reports a time offset:
|
||||
|
||||
```json
|
||||
{
|
||||
"position": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 92.5,
|
||||
"location": null
|
||||
},
|
||||
"progressFraction": 0.31,
|
||||
"consumedDurationInSeconds": 92.5,
|
||||
"consecutivePagesRead": 0
|
||||
}
|
||||
```
|
||||
|
||||
A book reports an opaque location and the number of consecutive pages read:
|
||||
|
||||
```json
|
||||
{
|
||||
"position": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/6[chapter-2]!/4/2/2)"
|
||||
},
|
||||
"progressFraction": 0.18,
|
||||
"consumedDurationInSeconds": 300,
|
||||
"consecutivePagesRead": 2
|
||||
}
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `recordId` | The Id of the consumption record, taken from the route. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
| Body field | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `position` | object | no | The latest position reported by the client. Send a complete position object to update it; omit it, or send an empty object, to keep the stored position. |
|
||||
| `progressFraction` | number | yes | The fraction of the item the client reached, from 0 to 1, finite. It may move backwards. |
|
||||
| `consumedDurationInSeconds` | number | yes | The active duration consumed by this session, in seconds. It must be finite, non-negative, within the maximum reportable range, and never lower than the value already stored for the session. |
|
||||
| `consecutivePagesRead` | integer | no | The number of consecutive pages read in this session. It must be non-negative and is only accepted for page based media. Defaults to 0. |
|
||||
|
||||
Reports the latest measurements of an in-progress session of the current user. The position and the progress fraction are the latest reported values, not the maximum values reached: a seek backwards is accepted and is stored as the new position. The consumed duration is the only monotonic measurement of the session and can never decrease. The operation never completes a session, even when the reported fraction reaches 1, because completion is explicit or threshold based.
|
||||
|
||||
A session of a non-page-based kind cannot report consecutive pages above zero. A music client that sends `consecutivePagesRead` above zero is rejected with `ConsecutivePagesReadIsOnlySupportedForPageBasedMedia`, even though the request contract has the field for every kind.
|
||||
|
||||
A book page count of 5 does not count as a session for statistics, while 6 does, but that counting rule belongs to the statistics read model and does not change the stored progress.
|
||||
|
||||
The book reader counts a page as one visible reader viewport. A PDF page is a section of its own, while a reflowable section can hold several viewport pages, so the reported page count follows the pages the reader actually scrolled through rather than the printed pages of the source book.
|
||||
|
||||
#### Report Consumption Progress Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"libraryId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
|
||||
"mediaItemId": "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d",
|
||||
"mediaKind": "Book",
|
||||
"status": "InProgress",
|
||||
"startedOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"lastActivityOnUtc": "2026-10-24T12:05:00.0000000Z",
|
||||
"endedOnUtc": null,
|
||||
"consumedDurationInSeconds": 300,
|
||||
"lastPosition": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/6[chapter-2]!/4/2/2)"
|
||||
},
|
||||
"lastProgressFraction": 0.18,
|
||||
"consecutivePagesRead": 2
|
||||
}
|
||||
```
|
||||
|
||||
The response is a `ConsumptionRecordResponse` with the fields listed in [Start Consumption Response](#start-consumption-response). A record of another user, and a record that does not exist, are both reported with `ConsumptionRecordNotFound`. A terminal session returns `ConsumptionIsNotInProgress`.
|
||||
|
||||
### Complete Consumption
|
||||
|
||||
#### Complete Consumption Request
|
||||
|
||||
```js
|
||||
POST api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/complete
|
||||
Authorization: Bearer <token>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
A music track reports its final time offset:
|
||||
|
||||
```json
|
||||
{
|
||||
"position": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 300,
|
||||
"location": null
|
||||
},
|
||||
"progressFraction": 1,
|
||||
"consumedDurationInSeconds": 300
|
||||
}
|
||||
```
|
||||
|
||||
A book reports its final opaque location:
|
||||
|
||||
```json
|
||||
{
|
||||
"position": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/8[chapter-4]!/4/2/2)"
|
||||
},
|
||||
"progressFraction": 1,
|
||||
"consumedDurationInSeconds": 900
|
||||
}
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `recordId` | The Id of the consumption record, taken from the route. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
| Body field | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `position` | object | no | The final position. It is stored when provided; otherwise the stored position is kept. |
|
||||
| `progressFraction` | number | yes | The final fraction of the item the client reached, from 0 to 1, finite. |
|
||||
| `consumedDurationInSeconds` | number | yes | The final active duration consumed by the session, in seconds. It must be finite, non-negative, within the maximum reportable range, and never lower than the value already stored. |
|
||||
|
||||
Completes an in-progress session of the current user. Completion is explicit, so it is recorded even when the media was not played to its final second. Completing a session deletes the resume point of the current user for the same media item. The final position, progress fraction, consumed duration and consecutive pages remain on the record.
|
||||
|
||||
#### Complete Consumption Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"mediaKind": "MusicTrack",
|
||||
"status": "Completed",
|
||||
"startedOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"lastActivityOnUtc": "2026-10-24T12:05:00.0000000Z",
|
||||
"endedOnUtc": "2026-10-24T12:05:00.0000000Z",
|
||||
"consumedDurationInSeconds": 300,
|
||||
"lastPosition": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 300,
|
||||
"location": null
|
||||
},
|
||||
"lastProgressFraction": 1,
|
||||
"consecutivePagesRead": 0
|
||||
}
|
||||
```
|
||||
|
||||
The response is a `ConsumptionRecordResponse` with the fields listed in [Start Consumption Response](#start-consumption-response). A record of another user, and a record that does not exist, are both reported with `ConsumptionRecordNotFound`. A terminal session returns `ConsumptionIsAlreadyTerminal`.
|
||||
|
||||
### Stop Consumption
|
||||
|
||||
#### Stop Consumption Request
|
||||
|
||||
```js
|
||||
POST api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/stop
|
||||
Authorization: Bearer <token>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
A music track reports where it was stopped:
|
||||
|
||||
```json
|
||||
{
|
||||
"position": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 60,
|
||||
"location": null
|
||||
},
|
||||
"progressFraction": 0.6,
|
||||
"consumedDurationInSeconds": 60
|
||||
}
|
||||
```
|
||||
|
||||
A book reports where it was stopped:
|
||||
|
||||
```json
|
||||
{
|
||||
"position": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/6[chapter-2]!/4/2/2)"
|
||||
},
|
||||
"progressFraction": 0.18,
|
||||
"consumedDurationInSeconds": 300
|
||||
}
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `recordId` | The Id of the consumption record, taken from the route. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
| Body field | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `position` | object | no | The final position. It is stored when provided; otherwise the stored position is kept. |
|
||||
| `progressFraction` | number | yes | The final fraction of the item the client reached, from 0 to 1, finite. |
|
||||
| `consumedDurationInSeconds` | number | yes | The final active duration consumed by the session, in seconds. It must be finite, non-negative, within the maximum reportable range, and never lower than the value already stored. |
|
||||
|
||||
Stops an in-progress session of the current user before it completes. The library settings decide the terminal status:
|
||||
|
||||
- When the library tracks progress, has a completion threshold, and the final progress fraction is at or above that threshold, the session is recorded as `Completed` instead of `Stopped`, and its resume point is deleted. Completion does not require the media to reach its final second.
|
||||
- When the library tracks progress without a completion threshold, the session is recorded as `Stopped`.
|
||||
- When the library does not track progress, the session is recorded as `Stopped`, without a completion threshold check.
|
||||
|
||||
A stopped session keeps a resume point only when the library tracks progress, the kind can resume, and a final position is known. Without a known position there is nothing to resume from, so no resume point is written. Music libraries default to tracking off, so a normal music stop records history but does not create a resume point. A music library that explicitly enables tracking can create one.
|
||||
|
||||
#### Stop Consumption Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"mediaKind": "MusicTrack",
|
||||
"status": "Stopped",
|
||||
"startedOnUtc": "2026-10-24T12:00:00.0000000Z",
|
||||
"lastActivityOnUtc": "2026-10-24T12:01:00.0000000Z",
|
||||
"endedOnUtc": "2026-10-24T12:01:00.0000000Z",
|
||||
"consumedDurationInSeconds": 60,
|
||||
"lastPosition": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 60,
|
||||
"location": null
|
||||
},
|
||||
"lastProgressFraction": 0.6,
|
||||
"consecutivePagesRead": 0
|
||||
}
|
||||
```
|
||||
|
||||
The response is a `ConsumptionRecordResponse` with the fields listed in [Start Consumption Response](#start-consumption-response). The `status` is `Completed` when the stop reached the library completion threshold, and `Stopped` otherwise. A record of another user, and a record that does not exist, are both reported with `ConsumptionRecordNotFound`. A terminal session returns `ConsumptionIsAlreadyTerminal`.
|
||||
|
||||
### Get Resume Point
|
||||
|
||||
#### Get Resume Point Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/media-resume-points/Book/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
The same operation reads a music track resume point, when the music library tracks progress:
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/media-resume-points/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
| Route value | Meaning |
|
||||
| --- | --- |
|
||||
| `mediaKind` | The kind of media to resume, matched case insensitively. `MusicTrack` and `Book` can resume today. `Photo` cannot resume. |
|
||||
| `mediaItemId` | The Id of the media item to resume. It must be a Guid and cannot be the empty Guid. |
|
||||
|
||||
Returns the resume point of the current user for the item named by the route. A book resume point carries an opaque location, while a music track resume point carries a time offset. A resume point of another user is reported as not found, exactly like a missing resume point, so a guessed identifier never reveals another user's position.
|
||||
|
||||
When the media item no longer exists, or no longer belongs to the library recorded in the resume point, the resume point is an orphan. It is deleted before the item is reported as not found. A client that reopens the item must therefore fall back to the beginning instead of assuming the stored point still exists.
|
||||
|
||||
When the library that recorded the resume point no longer tracks consumption progress, the stored resume point is deleted and reported as `MediaResumePointNotFound`, so turning tracking off takes effect for an existing position as well.
|
||||
|
||||
A kind whose catalogue does not exist yet is rejected with `UnsupportedMediaKind`, so a planned kind cannot return a resume point that start would never create. A photo is the exception among the planned kinds: it has no position representation, so it is rejected with `MediaKindCannotResume`. The invalid `None` kind is rejected with `UnsupportedMediaKind`.
|
||||
|
||||
#### Get Resume Point Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "4d5e6f70-8192-4a3b-9c4d-5e6f708192a3",
|
||||
"libraryId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f",
|
||||
"mediaItemId": "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d",
|
||||
"mediaKind": "Book",
|
||||
"lastPosition": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/4[chapter-3]!/4/2/2)"
|
||||
},
|
||||
"lastProgressFraction": 0.42,
|
||||
"lastConsumedOnUtc": "2026-10-24T12:12:00.0000000Z"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `id` | Guid | The Id of the resume point. |
|
||||
| `libraryId` | Guid | The Id of the library that contains the item. |
|
||||
| `mediaItemId` | Guid | The Id of the item to resume. |
|
||||
| `mediaKind` | string | The kind of media that is resumed. |
|
||||
| `lastPosition` | object | The position at which the item can be resumed. See [Position Kinds](#position-kinds). |
|
||||
| `lastProgressFraction` | number | The progress fraction at which the item can be resumed, from 0 to 1. |
|
||||
| `lastConsumedOnUtc` | DateTime | When the item was last consumed. |
|
||||
|
||||
A missing resume point returns `MediaResumePointNotFound`. A deleted item, or an item that no longer belongs to the recorded library, returns `TrackNotFound` or `BookNotFound` after the orphan resume point is removed. A kind that cannot resume returns `MediaKindCannotResume`.
|
||||
|
||||
### Media Kinds
|
||||
|
||||
`MediaKind` is shared across media contexts and is stored by its name.
|
||||
|
||||
| Kind | Status | Item |
|
||||
| --- | --- | --- |
|
||||
| `None` | Invalid | It is not a media kind and is rejected wherever a kind is required. |
|
||||
| `MusicTrack` | Supported | A track of a music library. Resumes with a time offset. |
|
||||
| `PodcastEpisode` | Planned | A podcast episode. Its catalogue does not exist yet. |
|
||||
| `Audiobook` | Planned | An audiobook. Its catalogue does not exist yet. |
|
||||
| `Movie` | Planned | A movie. Its catalogue does not exist yet. |
|
||||
| `TvEpisode` | Planned | A TV episode. Its catalogue does not exist yet. |
|
||||
| `Book` | Supported | A book of a book library. Resumes with an opaque location. |
|
||||
| `Photo` | Planned | A photo. Its catalogue does not exist yet, and it has no position, so it cannot resume. |
|
||||
| `Video` | Planned | A video. Its catalogue does not exist yet. |
|
||||
|
||||
Only the supported kinds can start a consumption session for now. A planned kind is rejected with `UnsupportedMediaKind`, and a `None` kind is rejected by validation. The planned kinds are listed so that clients can map the shared enumeration, not because their routes are available.
|
||||
|
||||
### Session Statuses
|
||||
|
||||
| Status | Meaning |
|
||||
| --- | --- |
|
||||
| `InProgress` | The session is running. Progress reports are accepted, and the record has no end time. |
|
||||
| `Completed` | The session ended because completion was reported, or because a stop reached the library completion threshold. The record has an end time and the status is terminal. |
|
||||
| `Stopped` | The session ended without completing. The record has an end time and the status is terminal. |
|
||||
|
||||
`Completed` and `Stopped` are terminal. A terminal record rejects further progress with `ConsumptionIsNotInProgress`, and further complete or stop operations with `ConsumptionIsAlreadyTerminal`. No update can move it back to `InProgress`.
|
||||
|
||||
### Position Kinds
|
||||
|
||||
A position is exactly one of two representations. The `kind` names the representation, and the fields of the other representation must be absent or null.
|
||||
|
||||
| Kind | Fields | Used by |
|
||||
| --- | --- | --- |
|
||||
| `TimeOffset` | `timeOffsetSeconds`: a non-negative finite number of seconds, within the maximum reportable range. `location` must be null or omitted. | Music tracks and the other time based kinds. |
|
||||
| `Location` | `location`: a non-empty opaque string of at most 4096 characters. `timeOffsetSeconds` must be null or omitted. | Books and other page or section based kinds. |
|
||||
|
||||
An empty position object means no position and keeps the stored position. When a `kind` is present, exactly one representation must be present: `TimeOffset` requires `timeOffsetSeconds` and no `location`, while `Location` requires `location` and no `timeOffsetSeconds`. A position with a time offset or a location but no `kind`, a position with both representations, a position with a kind but no matching representation, an unknown or numeric kind, a negative or non-finite time offset, or an empty or too long location is rejected with `InvalidMediaPosition`. The position kind must also match the media kind: a time offset on a book, or a location on a music track, is rejected with `InvalidMediaPosition`.
|
||||
|
||||
A photo has no position kind, so it cannot resume. The server does not parse a book location: it stores and returns the opaque locator exactly as reported.
|
||||
|
||||
### Reportable Ranges
|
||||
|
||||
| Value | Rule |
|
||||
| --- | --- |
|
||||
| `progressFraction` | Finite and between 0 and 1, inclusive. |
|
||||
| `consumedDurationInSeconds` | Finite, non-negative, and at most 31 days. It must also be at least the value already stored for the session. |
|
||||
| `timeOffsetSeconds` | Finite, non-negative, and at most 31 days. |
|
||||
| `location` | Non-empty and at most 4096 characters. |
|
||||
| `consecutivePagesRead` | Non-negative. Only page based media may report a value above zero. |
|
||||
|
||||
The 31 day limit keeps accumulated totals representable and rejects durations that cannot describe real media. The consumed duration is the only value that must not decrease; the position and the progress fraction are latest reported values and may move backwards.
|
||||
|
||||
### Session Lifecycle and Resume Points
|
||||
|
||||
A session moves through one lifecycle:
|
||||
|
||||
1. [Start Consumption](#start-consumption) creates an `InProgress` record and returns its identifier.
|
||||
2. [Report Consumption Progress](#report-consumption-progress) updates the latest position, progress fraction, consumed duration and consecutive page count. It never completes the session.
|
||||
3. [Complete Consumption](#complete-consumption) or [Stop Consumption](#stop-consumption) ends the session, sets its end time, and makes it terminal.
|
||||
|
||||
A resume point is separate from the history. It is created or updated by progress and stop when the library tracks progress, the kind can resume, and a position is known. It is read by start to initialize a new session. It is deleted by completion and by a stop that reaches the completion threshold. A stopped session that did not reach the threshold keeps it for the next start. Deleting a history record does not delete the resume point, because the two are separate actions in the product.
|
||||
|
||||
The business key of a resume point is the user, the media kind and the media item. There is at most one resume point per key, so a progress report updates the existing row instead of inserting a second one.
|
||||
|
||||
Ending a session is best effort on the client side. A client can disappear between its start request and its first terminal request, for example when a full page unload happens while the start is still in flight. The record created by such a start remains `InProgress`: the API does not expire it, and start is not idempotent, so the next session creates a new record instead of closing or reusing the lost one. A lost session therefore remains in the stored history as a record that was never ended.
|
||||
|
||||
### Completion Threshold
|
||||
|
||||
Completion is explicit or threshold based, and the threshold is a per-library setting. The relevant settings are `shouldTrackConsumptionProgress` and `completionThresholdPercentage` on the library, documented in [Libraries](../library/management/Api.Libraries.md). The per-library value always wins. When a library is created without explicit values, the defaults by library type are:
|
||||
|
||||
| Library category | Track progress | Completion threshold |
|
||||
| --- | --- | --- |
|
||||
| Music audio (`Music`, `Remix`, `SoundEffect`, `CoverSongAudio`, `LiveRecordingAudio`, `InterviewAudio`) | no | none |
|
||||
| Photo | no | none |
|
||||
| Written content (`Book`, `EBook`, `ComicBook`, `Magazine`, `Newspaper`, `Manga`, `GraphicNovel`, `AcademicPaper`, `SheetMusic`) | yes | 100 |
|
||||
| Video (`TvShow`, `Movie`, `Documentary`, `Anime`, `ConcertVideo`, `TutorialVideo`, `HomeVideo`, `YouTubeVideo`, `MusicVideo`, `LiveRecordingVideo`, `InterviewVideo`, `CoverSongVideo`) | yes | 90 |
|
||||
| Audiobook and podcast (`Audiobook`, `PodcastAudio`, `PodcastVideo`) | yes | 95 |
|
||||
| Other, non-media or unknown (`Playlist`, `Collection`, `Subtitles`, `Lyrics`, `Other`, any type added later) | no | none |
|
||||
|
||||
A stop reaches the threshold when the library tracks progress, a threshold is set, and the final progress fraction is at or above the threshold divided by 100. The comparison is done on the fraction, so a fraction exactly at the threshold completes the session. A library with tracking on and no threshold completes only when completion is reported explicitly. Tracking off never completes a session implicitly.
|
||||
|
||||
### Scoping and Authorization
|
||||
|
||||
Every route acts on the current user, read from the authenticated principal, never from the route, the query or the body. A client cannot read, progress, complete or stop another user's session through these routes.
|
||||
|
||||
Starting a session also applies the library ownership policy for the route library. When the current user cannot access the route library, the operation returns `NotAuthorized` before it looks up the item. When the route library is accessible, an item that does not exist and an item that belongs to another library are reported with the same kind specific not found error, so the response cannot be used to find out whether an item exists in another library. The kind specific errors are:
|
||||
|
||||
| Kind | Not found error |
|
||||
| --- | --- |
|
||||
| `MusicTrack` | `TrackNotFound` |
|
||||
| `Book` | `BookNotFound` |
|
||||
|
||||
A missing library returns `LibraryNotFound`. The current user must have access to the library; otherwise the start returns `NotAuthorized`.
|
||||
|
||||
Reading a single record or a single resume point is owner only. A record or resume point of another user is reported as not found, not as forbidden, so the response shapes are indistinguishable. Admins do not write another user's session.
|
||||
|
||||
### Private Responses
|
||||
|
||||
Every response produced by these endpoints is private to the authenticated user. Each endpoint sets:
|
||||
|
||||
- `Cache-Control: private, no-store`
|
||||
- `Vary: Authorization`
|
||||
|
||||
The headers are set before the operation runs, so they are present on the endpoint's problem responses too, including `403`, `404`, `409` and `422`. A request rejected by the authentication middleware with `401` before the endpoint runs is produced by the framework rather than by the endpoint. The CORS middleware may also add `Vary: Origin`; the endpoints append `Authorization` instead of replacing the header, so both values are preserved.
|
||||
|
||||
### Errors
|
||||
|
||||
Errors are returned as problem details. A request without a valid token is rejected with `401 Unauthorized` before it reaches the operation.
|
||||
|
||||
| Status | Error | When |
|
||||
| --- | --- | --- |
|
||||
| `401` | | The request carries no token, or an invalid or expired one. The body is a problem whose `title` is `Unauthorized` and whose `detail` says why. |
|
||||
| `403` | `NotAuthorized` | The authenticated principal carries no user identity, or the current user cannot access the route library on start. |
|
||||
| `403` | `ConsumedDurationCannotDecrease` | A progress, complete or stop request reports a consumed duration lower than the duration already stored for the session. |
|
||||
| `403` | `ConsecutivePagesReadIsOnlySupportedForPageBasedMedia` | A progress report sends consecutive pages above zero for a kind that is not page based, such as a music track. |
|
||||
| `403` | `MediaKindCannotResume` | A resume point is requested for a kind that cannot resume, such as a photo. |
|
||||
| `404` | `LibraryNotFound` | The start route names a library that does not exist. |
|
||||
| `404` | `TrackNotFound` | The start route names a music track that does not exist, or that does not belong to the route library, or a resume point names a track that no longer exists or no longer belongs to its recorded library. |
|
||||
| `404` | `BookNotFound` | The start route names a book that does not exist, or that does not belong to the route library, or a resume point names a book that no longer exists or no longer belongs to its recorded library. |
|
||||
| `404` | `ConsumptionRecordNotFound` | The record does not exist, or it belongs to another user. |
|
||||
| `404` | `MediaResumePointNotFound` | The resume point does not exist, belongs to another user, or belongs to a library that no longer tracks consumption progress. |
|
||||
| `409` | `ConsumptionIsNotInProgress` | A progress report targets a session that is already completed or stopped. |
|
||||
| `409` | `ConsumptionIsAlreadyTerminal` | A complete or stop request targets a session that is already completed or stopped. |
|
||||
| `409` | `ConcurrencyConflict` | Another request changed the same row after this request read it, or the storage reported a busy or locked database. Repeating the request is safe when it reports the current values. |
|
||||
| `422` | see below | The request failed validation. |
|
||||
|
||||
The `404` and `409` problems carry the generic error code in `title` and the specific name in `detail`:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "General.NotFound",
|
||||
"status": 404,
|
||||
"detail": "ConsumptionRecordNotFound",
|
||||
"instance": "/api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f",
|
||||
"traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
|
||||
}
|
||||
```
|
||||
|
||||
A request that fails validation is rejected with `422 Unprocessable Entity` and a validation problem whose `errors` object lists the names of the validation errors under the generic `General.Validation` code:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "General.Validation",
|
||||
"status": 422,
|
||||
"detail": "OneOrMoreValidationErrorsOccurred",
|
||||
"instance": "/api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/progress",
|
||||
"errors": {
|
||||
"General.Validation": [
|
||||
"InvalidProgressFraction",
|
||||
"InvalidMediaPosition"
|
||||
]
|
||||
},
|
||||
"traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
|
||||
}
|
||||
```
|
||||
|
||||
The validation errors of each operation are:
|
||||
|
||||
| Error | Operation | When |
|
||||
| --- | --- | --- |
|
||||
| `LibraryIdCannotBeEmpty` | Start | The library Id is missing or is not a non-empty Guid. |
|
||||
| `MediaItemIdCannotBeEmpty` | Start, Get Resume Point | The item Id is missing or is not a non-empty Guid. |
|
||||
| `UnsupportedMediaKind` | Start, Get Resume Point | The kind is missing, is not a member name of the media kind enumeration, or is a planned kind whose catalogue does not exist yet. A numeric value is rejected even when it is a defined enumeration value. On Get Resume Point, a photo is rejected with the 403 `MediaKindCannotResume` instead. |
|
||||
| `ConsumptionRecordIdCannotBeEmpty` | Get Record, Progress, Complete, Stop | The record Id is missing or is not a non-empty Guid. |
|
||||
| `InvalidMediaPosition` | Progress, Complete, Stop | The position is partially specified, uses both or neither representation for its kind, has an unknown or numeric kind, a negative or non-finite time offset, an empty or too long location, or a position kind that does not match the media kind. |
|
||||
| `InvalidProgressFraction` | Progress, Complete, Stop | The progress fraction is missing, is not finite, or is outside 0 to 1. |
|
||||
| `ConsumedDurationMustBeNonNegative` | Progress, Complete, Stop | The consumed duration is missing, is not finite, or is negative. |
|
||||
| `ConsumedDurationIsOutOfRange` | Progress, Complete, Stop | The consumed duration is above 31 days. |
|
||||
| `ConsecutivePagesReadMustBeNonNegative` | Progress | The consecutive page count is negative. |
|
||||
|
||||
A value that cannot be bound, such as a non-numeric progress fraction or a non-integer page count, is not reported by these validators. The endpoint does not catch binding failures, so the framework answers the request with its usual binding problem, and the web client never sends such values because its proxy endpoints rebuild the body from typed values.
|
||||
|
||||
### Concurrency
|
||||
|
||||
Every consumption record and resume point carries an optimistic concurrency version. A progress, complete or stop request reads the stored version, and the update is applied only when the stored version still matches. If another request ended or changed the session between the read and the write, the update affects no row and the request is reported as `409 ConcurrencyConflict`. A late progress report therefore never reverts a completed or stopped session, never clears its end time, and never lowers its consumed duration. A busy or locked SQLite write is reported the same way.
|
||||
|
||||
Repeating a progress, complete or stop request after a concurrency conflict is safe only when the client re-reads the record and reports values that are still valid for it. A complete or stop of a terminal session returns `ConsumptionIsAlreadyTerminal`, and a progress report of a terminal session returns `ConsumptionIsNotInProgress`.
|
||||
@@ -8,6 +8,12 @@
|
||||
- [Update User Settings](#update-user-settings)
|
||||
- [Update User Settings Request](#update-user-settings-request)
|
||||
- [Update User Settings Response](#update-user-settings-response)
|
||||
- [Get Playback State](#get-playback-state)
|
||||
- [Get Playback State Request](#get-playback-state-request)
|
||||
- [Get Playback State Response](#get-playback-state-response)
|
||||
- [Update Playback State](#update-playback-state)
|
||||
- [Update Playback State Request](#update-playback-state-request)
|
||||
- [Update Playback State Response](#update-playback-state-response)
|
||||
|
||||
## Settings
|
||||
|
||||
@@ -32,11 +38,25 @@ Returns the settings of the currently authenticated user.
|
||||
"userId": "2cff0c0f-3a67-4e30-b94f-f4e948a3b64f",
|
||||
"isPaginationEnabled": true,
|
||||
"itemsPerPage": 50,
|
||||
"ignoreThePrefixForAlphaPicker": true,
|
||||
"shouldIgnoreThePrefixForAlphaPicker": true,
|
||||
"isThemeCachingEnabled": true,
|
||||
"shouldAggregateMetadataWhenMissing": true,
|
||||
"shouldRenderPdfAsImages": false,
|
||||
"shouldPreserveBookStyles": true
|
||||
"shouldPreserveBookStyles": true,
|
||||
"shouldKeepDownloadingWhilePaused": true,
|
||||
"shouldAutoplay": true,
|
||||
"isGaplessPlaybackEnabled": true,
|
||||
"replayGainMode": "Off",
|
||||
"streamingQuality": "Auto",
|
||||
"vuMeterOrientation": "Vertical",
|
||||
"vuMeterSegmentCount": 12,
|
||||
"vuMeterSegmentGap": 1,
|
||||
"vuMeterMediumThreshold": 0.6,
|
||||
"vuMeterHighThreshold": 0.8,
|
||||
"vuMeterShowPeak": true,
|
||||
"vuMeterPeakHoldDurationInMilliseconds": 650,
|
||||
"vuMeterReleasePerSecond": 3,
|
||||
"vuMeterPeakReleasePerSecond": 0.65
|
||||
}
|
||||
```
|
||||
|
||||
@@ -50,15 +70,31 @@ PUT api/v1/users/me/settings
|
||||
|
||||
Updates the settings of the currently authenticated user.
|
||||
|
||||
The VU meter settings configure the segmented meter of the player bar: `vuMeterOrientation` is `Vertical` or `Horizontal`, `vuMeterSegmentCount` is between 1 and 128, `vuMeterSegmentGap` is between 0 and 32 pixels, `vuMeterMediumThreshold` and `vuMeterHighThreshold` are between 0 and 1 and the high threshold must not be lower than the medium one, `vuMeterPeakHoldDurationInMilliseconds` is between 0 and 10000, and `vuMeterReleasePerSecond` and `vuMeterPeakReleasePerSecond` are between 0 and 100 level units per second. All of them are required.
|
||||
|
||||
```json
|
||||
{
|
||||
"isPaginationEnabled": true,
|
||||
"itemsPerPage": 50,
|
||||
"ignoreThePrefixForAlphaPicker": true,
|
||||
"shouldIgnoreThePrefixForAlphaPicker": true,
|
||||
"isThemeCachingEnabled": true,
|
||||
"shouldAggregateMetadataWhenMissing": true,
|
||||
"shouldRenderPdfAsImages": false,
|
||||
"shouldPreserveBookStyles": true
|
||||
"shouldPreserveBookStyles": true,
|
||||
"shouldKeepDownloadingWhilePaused": true,
|
||||
"shouldAutoplay": true,
|
||||
"isGaplessPlaybackEnabled": true,
|
||||
"replayGainMode": "Off",
|
||||
"streamingQuality": "Auto",
|
||||
"vuMeterOrientation": "Vertical",
|
||||
"vuMeterSegmentCount": 12,
|
||||
"vuMeterSegmentGap": 1,
|
||||
"vuMeterMediumThreshold": 0.6,
|
||||
"vuMeterHighThreshold": 0.8,
|
||||
"vuMeterShowPeak": true,
|
||||
"vuMeterPeakHoldDurationInMilliseconds": 650,
|
||||
"vuMeterReleasePerSecond": 3,
|
||||
"vuMeterPeakReleasePerSecond": 0.65
|
||||
}
|
||||
```
|
||||
|
||||
@@ -67,3 +103,49 @@ Updates the settings of the currently authenticated user.
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
### Get Playback State
|
||||
|
||||
#### Get Playback State Request
|
||||
|
||||
```js
|
||||
GET api/v1/users/me/settings/playback-state
|
||||
```
|
||||
|
||||
Returns the playback state (the last volume and mute state) the player reported for the currently authenticated user. The values are written automatically by the player and are never surfaced as settings fields.
|
||||
|
||||
#### Get Playback State Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"volume": 0.75,
|
||||
"isMuted": false
|
||||
}
|
||||
```
|
||||
|
||||
### Update Playback State
|
||||
|
||||
#### Update Playback State Request
|
||||
|
||||
```js
|
||||
PUT api/v1/users/me/settings/playback-state
|
||||
```
|
||||
|
||||
Updates the playback state the player reported for the currently authenticated user. Both fields are required: the volume is a value between 0 and 1, and the mute state is a boolean. A request that omits either field, or sends a volume outside that range, is rejected with a `422 Unprocessable Entity`.
|
||||
|
||||
```json
|
||||
{
|
||||
"volume": 0.75,
|
||||
"isMuted": false
|
||||
}
|
||||
```
|
||||
|
||||
#### Update Playback State Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
+24
-2
@@ -33,7 +33,7 @@ SQLite Write-Ahead Logging (`PRAGMA journal_mode=WAL`) and a busy timeout are en
|
||||
### Risks and Tradeoffs
|
||||
| Risk | Mitigation Strategy |
|
||||
|-------------------------------|-------------------------------------------------------------------|
|
||||
| Raw SQL duplication | All raw SQL is confined to the two bulk repositories, behind the repository and unit of work abstractions |
|
||||
| Raw SQL duplication | All raw SQL is confined to the bulk repositories (the scan jobs and the documented playlist append), behind the repository and unit of work abstractions |
|
||||
| Concurrency errors | WAL and a busy timeout are enabled at startup, and the bulk operations run on dedicated connections |
|
||||
| Layer integrity | Dapper is referenced only by the DataAccess layer |
|
||||
|
||||
@@ -47,4 +47,26 @@ Bulk statements would run on the same connection as the tracked queries of the j
|
||||
### 2. Third party bulk library (for example EF Core bulk extensions)
|
||||
A dedicated bulk extension library would abstract the raw SQL.
|
||||
|
||||
**Rejected**: Dapper is a small, widely adopted and dependency free mapper, and the amount of raw SQL is small and confined to two repositories. See the ADRs of the scan subsystem for the exact statements.
|
||||
**Rejected**: Dapper is a small, widely adopted and dependency free mapper, and the amount of raw SQL is small and confined to the bulk repositories. See the ADRs of the scan subsystem for the exact statements, and the amendment below for the playlist append.
|
||||
|
||||
## Amendment: Playlist Whole-Library Appends (2026-10-20)
|
||||
|
||||
The playlist feature needs to append a whole library, which can contain hundreds of thousands of tracks, to a playlist in one request. The Entity Framework change tracker cannot materialize that graph, so `PlaylistRepository.AddEntriesAsync` performs the append with parameterized multi-row `INSERT` statements in bounded batches.
|
||||
|
||||
Unlike the scan jobs, this bulk operation deliberately uses the connection and the transaction of the request's unit of work, not a dedicated connection. The request middleware already holds the SQLite write transaction, and a dedicated connection would wait on that lock while the request waits on the append. Sharing the request transaction keeps the append atomic with the ownership check and the activity update, and the busy timeout plus the unique `(PlaylistId, Position)` index turn a concurrent append into a mapped conflict instead of a duplicate position.
|
||||
|
||||
The exception is confined to the append and the rare sparse-key rebalance in `PlaylistRepository` and is documented in the class remarks. Moves and removals use Entity Framework `ExecuteUpdateAsync` and `ExecuteDeleteAsync` on their normal path, so they keep the model, the transaction and the error mapping. The rebalance uses raw SQL only when repeated midpoint moves exhaust the numeric gap between two neighbors; it respaces the order keys through a temporary table inside the request transaction.
|
||||
|
||||
## Amendment: Playlist Scope Ordering and Rollback (2026-10-21)
|
||||
|
||||
A whole library, artist or album scope is now appended with one `INSERT ... SELECT` statement in `PlaylistRepository.AddScopeEntriesAsync`. The statement joins the catalogue tables, orders the tracks with `ROW_NUMBER()` in SQLite and computes the sparse positions as part of the insert, so the scope is never materialized, sorted in memory or sent to the data access layer as a list of Ids. Explicit track lists still use the batched `AddEntriesAsync` path, because that list is already in memory.
|
||||
|
||||
An append that fails or is cancelled rolls the request transaction back explicitly. The context records that rollback, and the eventual consistency middleware skips the commit and logs it when the response still reports success, instead of committing a partially written operation.
|
||||
|
||||
## Amendment: Request Transaction Ownership and Aborted Requests (2026-10-21)
|
||||
|
||||
The eventual consistency middleware now begins, commits and rolls back the request transaction through `IUnitOfWork`, so the transaction boundary follows the unit of work instead of the `DbContext` being used directly. The commit-before-publish sequence of ADR-0002 is unchanged.
|
||||
|
||||
An aborted request is no longer left at its default success status: the exception handling middleware reports it as `499 Client Closed Request` and rethrows. The eventual consistency middleware therefore decides from the response status alone. It commits a 2xx response and rolls back every other response, including an abort, and it deliberately does not consult the request abort token, because that token can already be cancelled after a successful operation whose response was already sent.
|
||||
|
||||
This replaces the in-context rollback marker and the repository's rollback of the ambient request transaction described in the previous amendment. A repository now only commits or rolls back a transaction it opened itself, which happens when it runs without an ambient request transaction. A partially written append is therefore discarded by the middleware's rollback, not by a signal from the repository.
|
||||
+14
@@ -82,3 +82,17 @@ Introduce a generic persistence engine driven by a per-aggregate profile describ
|
||||
Stop modeling shared references as a shared table keyed by name, and store them per aggregate, removing the duplicate-key-in-graph class of bug at the source.
|
||||
|
||||
**Rejected**: it requires a database schema change and changes query behavior for shared references, which is out of scope. The shared tables are kept, and the concern is handled where it belongs, in the persistence toolkit.
|
||||
|
||||
## Amendment: Set-Based Playlist Entry Operations (2026-10-20)
|
||||
|
||||
The playlist entries are mutated by set-based storage operations because a playlist can hold a whole library. The batched raw append and the `ExecuteUpdateAsync` and `ExecuteDeleteAsync` move and removal statements bypass the change tracker and therefore also bypass the auditing interceptor.
|
||||
|
||||
Those operations stamp `UpdatedOnUtc` and `UpdatedBy` on the playlist row themselves, stamp the creation or update audit columns of the entry rows they write, and increment the playlist concurrency token, in the same transaction. This is the only exception to the rule that the auditing interceptor is the only writer of the audit columns. Details edits still go through `EditableValuesCopier` and leave the audit columns to the interceptor. The exception is confined to `PlaylistRepository` and is documented in the class remarks.
|
||||
|
||||
Ordering is storage owned as well. The unique index on `(PlaylistId, Position)` is the enforced invariant, and the positions are sparse order keys rather than dense indices. A move normally changes one key to the midpoint between its new neighbors, and a removal deletes one row, so neither rewrites the following range. If repeated midpoint moves exhaust the numeric gap between two neighbors, a rare rebalance respaces the keys with a temporary table and two passes so the unique index is never violated. The domain only rejects duplicate positions on reconstitution, so a storage gap is readable instead of making the playlist impossible to load.
|
||||
|
||||
## Amendment: Playlist Entry Count and Change Detection (2026-10-21)
|
||||
|
||||
The playlist row now carries a denormalized `EntryCount`, maintained by the set-based append and removal operations in the same statement that updates the playlist activity time and concurrency token. Window reads, moves and the single-add read-back use that column instead of counting the entries of the playlist, so none of them scan an index proportional to the playlist size.
|
||||
|
||||
Details edits still go through `EditableValuesCopier`, but the copier now compares the incoming value with the tracked value before assigning it and marks only an actual change as modified. `PlaylistRepository.UpdateAsync` also compares the tracked original values explicitly before it decides to increment the concurrency token, so a no-op save neither restamps the row nor bumps its version.
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
# Architecture Decision Record (ADR): 0016 - Playback Delivery Decision and Player Capability Negotiation
|
||||
|
||||
## Status
|
||||
|
||||
**Accepted** (2026-10-14)
|
||||
|
||||
## Context
|
||||
|
||||
Lumina's music player is implemented from scratch, on WebCodecs for decoding and the Web Audio API for output, with no `HTMLMediaElement` and no Media Source Extensions. That player can only demux a curated set of containers and decode a curated set of codecs, so the server has to tell it, before it fetches any audio, whether a track can be played as stored or whether the server has to change the container or the codec first.
|
||||
|
||||
The server already has each track's stored probe result (the container and the codec, plus the sample rate, the channels, the bit depth, the duration and the ReplayGain values) and a stream endpoint with HTTP range support that serves the original file. What is missing is the decision itself and a way for the player to state what it can play.
|
||||
|
||||
## Decision
|
||||
|
||||
Introduce a playback format service (`IPlaybackFormatService`, `PlaybackFormatService`) that, given the container and the codec of a track as read from its stored probe result and the capabilities a player advertises, decides one of three delivery modes: direct play, remux, or transcode. It stays in the Application layer (interface) and the Infrastructure layer (implementation), as a service: the byte and codec pipeline is not part of the playback domain aggregate.
|
||||
|
||||
### Delivery modes
|
||||
|
||||
| Mode | Condition | Delivery format | Delivery shape |
|
||||
|---|---|---|---|
|
||||
| Direct play | The player can demux the stored container and decode the stored codec | The stored container and codec, unchanged | Byte range seekable |
|
||||
| Remux | The player can decode the stored codec but has no demuxer for the stored container | The stored codec, repackaged into a server container the player can demux | Time addressed segments |
|
||||
| Transcode | The player cannot decode the stored codec | The most preferred codec the server can produce that the player advertises | Time addressed segments |
|
||||
|
||||
- The stored codec is the free form description reported by the probe (for example `MPEG-1 Layer 3`), so it is canonicalized to the codec name players advertise (for example `MP3`) before it is compared. The MPEG layer is matched by its layer number only (`LAYER 3`/`LAYER III`), so `MPEG-1 Layer 1` and `MPEG-1 Layer 2` are not mistaken for `MP3`, and a description that names no recognizable codec is left as it is, which keeps it from matching any advertised codec and forces a transcode. Containers are canonicalized by casing.
|
||||
- The container a normalized delivery is produced in is always chosen from the containers the server can produce for the codec, never from the container the player names: the player only selects among the server's known containers, so a container supplied by a client never reaches the transcoder or a cache name. The containers the server produces each codec in are, in order of preference: `PCM` in `WAV`, `MP3` in `MP3`, `FLAC` in `FLAC`, `Opus` and `Vorbis` in `OGG`, `AAC` in `MP4` then `AAC`.
|
||||
- The server can produce, in order of preference, `AAC`, `OPUS`, `MP3`, `VORBIS`, `FLAC` and `PCM` (the efficient lossy codecs before the lossless ones, and uncompressed last), so a transcode re-encodes to the first of these the player advertises in one of its containers. When the player advertises no producible codec, the decision fails with `NoSupportedPlaybackFormat`, which is a forbidden outcome (HTTP 403) rather than a malformed request, and no delivery is attempted.
|
||||
|
||||
### Capability input convention
|
||||
|
||||
The capabilities a player can demux and decode directly are carried on the playback manifest request as a query parameter named `capabilities`, whose value is a comma separated list of `container/codec` pairs:
|
||||
|
||||
```
|
||||
GET /api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/playback-manifest?capabilities=mp3/mp3,flac/flac,ogg/opus,ogg/vorbis,wav/pcm,mp4/aac
|
||||
```
|
||||
|
||||
- The container and the codec of a pair are matched case insensitively, and surrounding whitespace is ignored.
|
||||
- A pair must name both a container and a codec, with neither empty (for example `flac`, `a/b/c` and `a//b` are ignored).
|
||||
- At most 32 pairs are read from one request, so the parsing work stays bounded regardless of the input length.
|
||||
- When the parameter is absent, empty, or lists no valid pair, the server applies the default capabilities of the bundled player, so a request that advertises nothing still gets a playable decision:
|
||||
`mp3/mp3`, `flac/flac`, `ogg/opus`, `ogg/vorbis`, `wav/pcm`, `aac/aac`. The default set is the bundled player's demuxer set (MP3, AAC/ADTS, FLAC, OGG and WAV), so it deliberately contains no `mp4/aac` pair: a track stored in MP4 is remuxed to raw AAC for a request that advertises nothing, rather than being marked direct play for a container the bundled player cannot demux.
|
||||
- The convention is a query parameter rather than a request header, so that it is part of the request's own contract, is trivially testable, and is forwarded by the web app's manifest proxy without depending on header forwarding.
|
||||
|
||||
### Delivery shape
|
||||
|
||||
The `TimeAddressedSegments` delivery shape is a sequence of approximately fixed duration segments addressed and seeked by time, so that finding a time never requires mapping a byte range to it. The nominal segment duration is 6 seconds, and it is carried in the delivery decision so that the producer of the segments and the player agree on it. A segment is cut at the first packet at or after its nominal boundary, so its real start is not always an exact multiple of the nominal duration; the producer records the real start in its index, and the segment route reports it in a response header. Direct play is `ByteRangeSeekable`, because the original file is served by the existing range-capable stream endpoint.
|
||||
|
||||
### Segment addressing
|
||||
|
||||
The segments are exposed through a dedicated segment route, `.../stream/deliveries/{deliveryId}/segments/{segmentIndex}`, which extends the track stream endpoint's contract. The playback manifest carries its relative path in `segmentStreamPathTemplate`, with `{deliveryId}` and `{segmentIndex}` placeholders, and the web application rewrites that path to its own segment proxy so that the browser never reaches the API server. The manifest also reports the opaque `deliveryId` the placeholders are expanded with.
|
||||
|
||||
- An index addresses a whole segment, so no byte range is ever sent for a normalized delivery.
|
||||
- The delivery handle the manifest issued is the only authority on the delivery of the segments. It is a random, opaque value bound to the user and the track, and it captures the delivery decision, the quality cap and the source file version the manifest declared. The segment route resolves it instead of recomputing the decision from a capability list, rereading the user's quality setting, or restating a file that may have changed. A changed file is rejected as a conflict rather than starting a second production whose segments would be mixed with the declared one.
|
||||
- Library ownership is still evaluated on every segment request, so revoked access stops playback immediately. The track membership and the library content locations are the ones captured when the manifest was issued, so deleting a track row while its file remains, or removing a content location, can keep that media streamable until the handle expires. That is the deliberate trade-off for not reloading the track and library graph for every six second segment; the handle lifetime is bounded to 12 hours.
|
||||
- The handles are process local, like the normalized audio cache they address. They expire after a bounded lifetime, are bounded globally and per user, and a repeated manifest for the same delivery inputs reuses the existing handle, so the registry cannot grow without bound. Expired handles are removed in issue order from a queue, so the sweep is amortized constant time rather than a scan of every handle.
|
||||
- A production is atomic: the first segment request may wait for the whole normalized track to be produced and cached, and the following segment requests are served from that cache.
|
||||
- The player keeps a bounded lookahead of one segment ahead of the segment the demuxer consumed, so the link is not idle between segments and the streamed indicator can run ahead. The lookahead stops while playback is paused unless the user enabled the keep-downloading-while-paused preference, and it never advances itself, so it cannot turn into a full download of the track.
|
||||
- Gapless prefetch starts only near the end of the current track, not at load time. A normalized next track therefore transitions without a gap only when its production is already cached or finishes within that lead; otherwise it starts normally at the boundary. The lead is deliberately shorter than a long production, because holding a normalization slot for a track the user may never reach is worse than a small gap.
|
||||
- The player keeps every segment it has fetched for the lifetime of the track, so seeking back into a fetched segment does not fetch it again. A seek reads the target segment from its first packet and drops the packets that end before the target, instead of seeking inside the segment: a container that numbers its frames across the whole track would otherwise add that number to the segment offset twice. A segment is short, so reading it from its start is exact for every delivered container.
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive Outcomes
|
||||
|
||||
| Aspect | Benefit |
|
||||
|---|---|
|
||||
| Decoupling | The player states what it can play and never has to know the server's codecs; the server states the delivery and never has to know the player's implementation |
|
||||
| Efficiency | A container a player cannot demux but a codec it can decode is repackaged instead of re-encoded, and only a genuinely unsupported codec is re-encoded |
|
||||
| Determinism | The containers the server produces each codec in and the transcode preference order are fixed, so the same input always yields the same delivery |
|
||||
| Seekability | Time addressed segments make a normalized delivery seekable without a byte to time index |
|
||||
| Testability | The decision is a pure function of the stored container and codec and the advertised capabilities |
|
||||
|
||||
### Risks and Mitigations
|
||||
|
||||
| Risk | Mitigation Strategy |
|
||||
|---|---|
|
||||
| The probe reports a codec as a free form description that does not name the codec the player advertises | The stored description is canonicalized to the advertised codec names before comparison, and the MPEG layer is matched by its layer number, so a description that names no decodable codec is left unmatched and forces a transcode |
|
||||
| A player advertises a container the server cannot produce | The delivered container is always chosen from the containers the server produces the codec in, never from the container the player names, so a client supplied container never reaches the transcoder or a cache name; a codec the player cannot be served in any server container is not used |
|
||||
| The real segment start drifts from the nominal grid | The nominal duration is carried by the manifest, and the exact indexed start of each segment is reported in `X-Segment-Start-Seconds` and used by the player, so neither side assumes an exact grid |
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### 1. Decide the delivery from the container only
|
||||
|
||||
**Rejected**: a container can carry several codecs (for example `OGG` carries both Vorbis and Opus), so the container alone cannot tell whether the player can decode the audio, and the difference between a remux and a transcode would be lost.
|
||||
|
||||
### 2. Let the player decide, by sending its full codec support to the server and reading the probe result itself
|
||||
|
||||
**Rejected**: it leaks the server's storage and probe details to the client and duplicates the decision on both sides. The server owns the probe result and the producible formats.
|
||||
|
||||
### 3. Carry the capabilities in a request header
|
||||
|
||||
**Rejected**: a header has to be explicitly forwarded by the web app's manifest proxy and is harder to exercise from a browser or a request file than a query parameter, with no benefit that a query parameter does not already provide.
|
||||
|
||||
### 4. Deliver a remuxed track as a single byte range seekable file instead of segments
|
||||
|
||||
**Rejected**: it makes remuxed and transcoded tracks two different delivery shapes for the player to consume, and it reintroduces the byte to time mapping the time addressed shape exists to avoid. Both normalized deliveries use the same shape.
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
# Architecture Decision Record (ADR): 0017 - One Generic Favorites Aggregate Keyed by Media Kind and Item Id
|
||||
|
||||
## Status
|
||||
|
||||
**Accepted** (2026-10-21)
|
||||
|
||||
## Context
|
||||
|
||||
A user must be able to mark any media item as a favorite: today the artists, albums and tracks of a music library and the books of a book library, and later videos and photos. Playlists already reference media items across bounded contexts by storing a media kind and a media item Id without a foreign key.
|
||||
|
||||
Favorites raise the same question with different constraints:
|
||||
|
||||
1. **One concept, many contexts**: a favorite is the same fact for every media kind, so a table and an aggregate per media kind would repeat one model four times now, and again for every media kind that is added.
|
||||
2. **Bounded context isolation**: as specified by DDD, an aggregate does not reference objects of another bounded context, only identifiers placed in `ExternalIdentifiers` directories. A favorites aggregate that held an `Artist`, a `Book` or any other media entity would couple favorites to every media context.
|
||||
3. **Referential integrity across kinds**: one table cannot declare a foreign key to the tables of several media kinds. A favorite must also outlive the item it references, because a library scan or a manual delete can remove an item, and the owner of the favorite has to be able to see and remove it afterwards instead of the favorite silently disappearing.
|
||||
4. **Concurrent toggles**: a favorite toggle is rendered on many pages, and a user can have several tabs open, so the same add can arrive twice at nearly the same moment.
|
||||
5. **Access control**: favoriting an item must not reveal whether an item exists in a library the user cannot access, and listing must not expose the display data of such a library.
|
||||
|
||||
## Decision
|
||||
|
||||
Store favorites as one generic `Favorite` aggregate in `FavoriteBoundedContext`, in one `Favorites` table. The table has a surrogate `FavoriteId` primary key and a unique business key `(UserId, MediaKind, MediaItemId)`. A media item is referenced only by its `FavoriteMediaKind` and the external `MediaItemId`; there is no foreign key to a media table. There are no per-kind favorite aggregates, tables, endpoints or contracts.
|
||||
|
||||
The decision includes these rules:
|
||||
|
||||
- **Add is idempotent.** Adding an item the user already favorited returns the existing favorite and raises no event.
|
||||
- **Remove is idempotent.** Removing a favorite that is already absent succeeds without changing anything and raises no event.
|
||||
- **The owner always comes from the authenticated principal.** No route, query or body carries the owner, and no administrator or library-owner override exposes another user's favorites.
|
||||
- **Access is checked where it can leak.** Adding evaluates the library ownership policy of the item's library. Listing evaluates it for each distinct library in the returned page and hides the display data of inaccessible libraries. Removing and checking the status read only the current user's own favorites, so they evaluate no library policy.
|
||||
- **Dangling favorites stay visible.** A favorite whose item no longer exists, or whose library is no longer accessible, is returned as an unavailable item with empty display fields so its owner can see and remove it.
|
||||
- **Reads use the shared pagination contract.** The repository accepts the shared `PaginationDataDto` and returns the shared `PaginatedResultDto<T>`, like every other paginated listing. When the request provides neither `currentPage` nor `perPage`, every matching favorite is returned in a single page; when a page is requested, the page defaults to `1` and the page size defaults to `200`. A page beyond the last one is clamped to the last page, and there is no separate maximum page size. The status check accepts 1 to 100 Ids of one kind per request.
|
||||
|
||||
### Model
|
||||
|
||||
| Element | Decision |
|
||||
|---|---|
|
||||
| Aggregate | `Favorite` is the root, with a `FavoriteId`, a `UserId`, a `MediaItemId`, a `FavoriteMediaKind` and the audit columns. It has no entities. The user and the media item are referenced only through the identifier types in the context's `ExternalIdentifiers` directories; the kind is the shared `FavoriteMediaKind` enumeration. The media item identifier is generic across artists, albums, tracks, books and the planned video and photo kinds. |
|
||||
| Media kind | `FavoriteMediaKind` has `MusicArtist`, `MusicAlbum`, `MusicTrack`, `Book`, `Video` and `Photo`, and it is stored by name. `Favorite.IsSupported` is `true` for the first four, and creating a favorite of the planned `Video` and `Photo` kinds is rejected with the validation error `FavoriteMediaKindIsNotSupported`. A planned kind becomes supported by lifting the restriction, with no change to the storage schema. |
|
||||
| Domain events | `FavoriteAdded` is raised when a favorite is created, and `FavoriteRemoved` when it is removed. |
|
||||
| Storage | The `Favorites` table holds the Id, the owner, the media kind, the media item Id and the audit columns. The owner is a foreign key that cascades, so favorites leave with their user. The media item is not a foreign key. |
|
||||
| Invariant | A unique index on `(UserId, MediaKind, MediaItemId)` makes the storage medium the owner of the rule "one favorite per user and item", and serves the status check that looks up a user's favorites among checked Ids. Indexes on `(UserId, CreatedOnUtc)` and `(UserId, MediaKind, CreatedOnUtc)` serve the listing of every kind and of one kind. |
|
||||
| Display data | The repository resolves, per kind and with projections that do not materialize the entities, the library Id of an item and the generic display fields of a page of favorites. The display fields are the title, the collection Id and title, the creator Id and name, and the cover path. Each kind fills what it has, and "no value" is the empty Guid or the empty string. Adding a media kind adds one branch to each resolution and one entry to the enumeration, with no new table, endpoint or contract. |
|
||||
|
||||
### Operations
|
||||
|
||||
- **Add**: the handler validates, requires the current user, rejects an unsupported kind, resolves the library of the item, evaluates the library ownership policy and returns the existing favorite without an event when the user already favorited the item. Otherwise it creates the aggregate, inserts it, saves the unit of work, queues the aggregate's events and reads the row back. If the unique index rejects a concurrent add, the handler re-reads the existing favorite and returns it without an event.
|
||||
- **Remove**: the handler validates, requires the current user and loads the favorite by user, kind and item. A missing favorite is a successful removal with no event. Otherwise it removes the aggregate, deletes the row, saves the unit of work and queues the removal event. A concurrent removal is treated as success; any other concurrency conflict is reported.
|
||||
- **List**: the repository scopes the query to the current user inside the storage query and returns the paginated listing ordered by the time of favoriting, with the shared pagination metadata. The handler evaluates the library policy once per distinct library in the page and maps a favorite with missing or inaccessible display data to an unavailable item with empty display fields.
|
||||
- **Status**: the repository scopes the check to the current user and returns the Ids, among the checked ones, that the user favorited. The response carries only those Ids.
|
||||
- **Errors**: `FavoriteAlreadyExists` remains defined but no operation produces it. `FavoriteNotFound` is used only where a stored favorite cannot be read back; removal of an absent favorite succeeds. `FavoriteMediaKindIsNotSupported` is returned by Add for the planned kinds.
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive Outcomes
|
||||
|
||||
| Aspect | Benefit |
|
||||
|---|---|
|
||||
| One model | Multiple media kinds share one aggregate, one table, four operations and one set of contracts |
|
||||
| Context isolation | The aggregate holds identifiers only, so favorites depend on no media bounded context and could move to their own service |
|
||||
| Survives deletion | A favorite is not removed by deleting or rescanning its item, and its owner is shown an unavailable item that can be removed |
|
||||
| Race safe | The storage unique index, not the existence check alone, guarantees a single favorite per user and item, and a concurrent duplicate add resolves to the existing favorite |
|
||||
| No existence oracle | An inaccessible item and a missing item are indistinguishable when adding, and inaccessible display data is never listed |
|
||||
| No schema change for new kinds | The kind is stored by name, so a planned kind only needs its restriction lifted and its two resolutions written |
|
||||
|
||||
### Risks and Mitigations
|
||||
|
||||
| Risk | Mitigation Strategy |
|
||||
|---|---|
|
||||
| Without a foreign key, rows can point at items that no longer exist | This is intended: the listing returns such rows as unavailable and removal never needs the item. Nothing relies on the item being present |
|
||||
| The per-kind resolution is a switch in the repository, so a new kind could be added to the enumeration without a resolution | `GetMediaItemLibraryIdAsync` reports no library for a kind without a branch, so an add of it is reported as not found, and `Favorite.IsSupported` has to be extended together with the branch |
|
||||
| The listing evaluates the library policy once per distinct library of a page | The policy is evaluated once per distinct library, not once per favorite, so the cost grows with the number of distinct libraries rather than with the number of favorites. A client that needs a bound requests a page size, like every other paginated listing |
|
||||
| The display projections can drift from how the catalogues show their items | The projections reuse the same sources as the listings of each catalogue, so a change to how a catalogue shows an item has to be mirrored in the matching branch |
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### 1. One favorites table and aggregate per media kind
|
||||
|
||||
A `FavoriteArtist`, `FavoriteAlbum`, `FavoriteTrack` and `FavoriteBook` aggregate, each with a real foreign key to its media table.
|
||||
|
||||
**Rejected**: it repeats the same model, endpoints and contracts per kind, and again for every planned kind. The foreign keys would also make the favorite die with its item, which removes the user's ability to see and remove it, and each aggregate would need to reference a media bounded context directly.
|
||||
|
||||
### 2. A flag on each media entity
|
||||
|
||||
An `IsFavorite` column on artists, albums, tracks and books.
|
||||
|
||||
**Rejected**: a favorite is private to a user, and a flag on a shared catalogue row cannot be. A join table per user would be needed anyway, which brings back the first alternative.
|
||||
|
||||
### 3. Reuse the playlist model with a system playlist
|
||||
|
||||
Store favorites as the entries of a special playlist per user.
|
||||
|
||||
**Rejected**: a playlist is an ordered list that allows duplicates and is positioned by the user, while a favorite is an unordered set with exactly one entry per item and a listing ordered by the time of favoriting. The playlist operations, the position keys and the entry limits do not apply, and the favorites of artists, albums and books are not playable entries.
|
||||
|
||||
### 4. Enforce uniqueness only in the handler
|
||||
|
||||
Check for an existing favorite and rely on it, with no unique index.
|
||||
|
||||
**Rejected**: two requests of the same user can both pass the check, so duplicates would be created under concurrency. The storage medium must own the invariant, and the handler's check is kept only to make the common repeated add idempotent without a failure.
|
||||
|
||||
### 5. Return a conflict when an item is already a favorite
|
||||
|
||||
Report `FavoriteAlreadyExists` instead of returning the existing favorite.
|
||||
|
||||
**Rejected**: a toggle rendered on several pages, and several open tabs, make a repeated add a normal event rather than an error. An idempotent add keeps the client simple, since it does not have to distinguish a created favorite from an existing one. `FavoriteAlreadyExists` remains defined in the favorites error set, but no operation produces it.
|
||||
|
||||
## Amendment: Explicit Default Media Kind (2026-10-29)
|
||||
|
||||
`FavoriteMediaKind` now declares `None = 0` as its first member and default value, so an unset kind is never mistaken for `MusicArtist`. The other members keep their order and now occupy values 1 to 6. `None` is not a favoritable kind: the application validators reject it with `FavoriteMediaKindIsInvalid`, `Favorite.IsSupported` reports it as unsupported, and no operation creates a favorite of it. A stored favorite whose kind was recorded as `None` is still rehydrated without failure, so the read paths remain tolerant of legacy or malformed rows. Because the kind is stored by name, no data migration is required.
|
||||
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
# Architecture Decision Record (ADR): 0018 - Media Neutral Consumption History, Resume Points, and Derived Statistics
|
||||
|
||||
## Status
|
||||
|
||||
**Accepted** (2026-10-26)
|
||||
|
||||
## Context
|
||||
|
||||
Consumption is one concept across media kinds. A music track and a book already produce sessions today, and video, photo, podcast and audiobook catalogues are planned. The same facts apply to each kind: who consumed an item, when the session started and ended, how long it was actively consumed, how far it reached, and where it can be resumed. A separate model per kind would repeat the aggregate, table, endpoints and contracts for every catalogue.
|
||||
|
||||
The feature raises questions:
|
||||
|
||||
1. **One concept, many media kinds**: consuming a track, a book or a video is the same fact for statistics, deletion and visibility, so a history per kind would repeat the model, the endpoints and the contracts.
|
||||
2. **Two lifecycles**: history is a session with a start, progress and a terminal state, while resuming is the latest position of an item. History can be deleted without losing the position, and completion deletes the position but keeps the history.
|
||||
3. **Reference integrity across catalogues**: one table cannot declare a foreign key to the tables of several media kinds, and a history row must survive the deletion of the item it references.
|
||||
4. **Derived statistics**: a stored counter would disagree with the history after every deletion and would have to be rebuilt whenever a counting rule changes.
|
||||
5. **Library policy**: whether a position is remembered and when a session is complete are per-library settings, not fixed properties of a media kind.
|
||||
6. **Privacy**: a regular user must never read or delete another user's history, while an administrator must be able to do both without a separate permission toggle.
|
||||
|
||||
## Decision
|
||||
|
||||
Use one `MediaConsumptionBoundedContext` that owns two independent write aggregates and one read model:
|
||||
|
||||
- `MediaConsumptionRecord` is the history of one consumption session.
|
||||
- `MediaResumePoint` is the latest position of one user and item.
|
||||
- `ConsumptionStatistics` is a read model computed from the records on every request.
|
||||
|
||||
The decision includes these rules:
|
||||
|
||||
- **History and resume are separate aggregates.** A record has its own identifier, status, start, activity and end times, consumed duration, latest position, latest progress fraction and consecutive page count. A resume point has its own identifier and the business key `(UserId, MediaKind, MediaItemId)`. The storage layer owns the unique index of that key. A record is never the source of a resume point, and a resume point is never part of the record.
|
||||
- **The latest reported position wins.** `LastPosition` is replaced by every report that carries a position, and `LastProgressFraction` by every report. Both may move backwards. Seeking from 75 percent back to the beginning and continuing from there leaves the resume point at the new position, not at the highest position ever reached. No monotonic rule is applied to either field.
|
||||
- **Consumed duration is monotonic within one record.** It measures active listening, watching or reading time, it never decreases, and a report below the stored value is rejected. It is the only measurement with that rule.
|
||||
- **Completion is explicit or threshold based.** A session stopped at or after the library completion threshold is recorded as `Completed` and its resume point is deleted. Completion never requires playback to the final second of a media file. A library that tracks progress without a completion threshold completes only when completion is reported explicitly.
|
||||
- **Progress tracking and completion thresholds are per-library settings.** `ShouldTrackConsumptionProgress` and `CompletionThresholdPercentage` live in `LibraryConsumptionSettings` on the library aggregate. Defaults are applied by library type when a library is created, and when progress tracking is enabled later without a threshold. The per-library value always wins once it is set.
|
||||
- **Statistics are derived, never stored.** `ConsumptionStatistics` aggregates the records in the application layer on every request. There is no rollup table, no projection table and no counter aggregate, so deleting a record changes the statistics immediately. The `MediaConsumptionRule` value objects own the counting rules per media kind.
|
||||
- **Tags and genres are lowercase and shared across kinds.** `Tag` and `Genre` normalize names with `Trim().ToLowerInvariant()`, and the statistics group them by that normalized name across media kinds. The application resolves the terms of each consumed record through the catalogue repository of its media kind, in a per-kind branch, and the photo branch is added when the photo catalogue exists. For a music track, the terms fall back from the track to its album and then to its artist.
|
||||
- **Access is based on the user and the administrator role.** A regular user reads and deletes only their own history, statistics and resume points. An administrator reads any user's history and statistics, and deletes any user's history and resume points. A resume point is readable only by its owner. There is no per-user permission toggle. Lifecycle writes (`start`, `progress`, `complete`, `stop`) are owner only, so an administrator does not write another user's session.
|
||||
|
||||
### Model
|
||||
|
||||
| Element | Decision |
|
||||
|---|---|
|
||||
| Bounded context | `MediaConsumptionBoundedContext` in the Domain layer. User, library and media item references are identifier copies under its `ExternalIdentifiers` directories, so the context depends on no other bounded context. |
|
||||
| `MediaConsumptionRecord` | The write aggregate of a session. It holds a `MediaConsumptionRecordId`, the owner, the library, the media kind, the media item identifier, the status, the start, last activity and end times, the consumed duration, the latest position and progress fraction, and the consecutive page count. No album, artist, series or catalogue hierarchy is stored on the record. |
|
||||
| `MediaResumePoint` | The write aggregate of the latest position. It holds a `MediaResumePointId`, the owner, the library, the media kind, the media item identifier, the latest position, the latest progress fraction and the last consumption time. It is created only for a resumable kind whose library tracks progress. |
|
||||
| `ConsumptionStatistics` | A read model, not an aggregate and not a table. It is built from `MediaConsumptionRecordEntity` collections in the application handlers and mapped to the summary, recent, most consumed, tag and genre responses. |
|
||||
| `MediaKind` | The shared enumeration in `Lumina.Domain.SharedKernel`. `MusicTrack` and `Book` are supported by the current catalogues. `PodcastEpisode`, `Audiobook`, `Movie`, `TvEpisode`, `Photo` and `Video` have rules and are listed for clients, but are rejected by the lifecycle endpoints until their catalogues exist. `None` is invalid. |
|
||||
| `MediaConsumptionRule` | The shared value object hierarchy that owns resumability (`PositionKind`, `CanResume`), one-shot behavior and counting (`Counts`). It is reused by both aggregates and the statistics read model, so callers never switch on `MediaKind` for these rules. |
|
||||
| Completion settings | `LibraryConsumptionSettings` on the `Library` aggregate. It stores `ShouldTrackConsumptionProgress` and an optional `CompletionThresholdPercentage`. The validator rejects a threshold when tracking is off, and a threshold outside 0 to 100 when it is supplied. |
|
||||
| Storage | `MediaConsumptionRecords` and `MediaResumePoints`. The owner is a cascading foreign key to `Users`; the media item is a plain identifier with no foreign key to a media catalogue. Both tables carry an optimistic concurrency version and the audit columns. |
|
||||
| Invariants | The resume points have a unique index on `(UserId, MediaKind, MediaItemId)`. Records are indexed by `(UserId, MediaKind, MediaItemId, LastActivityOnUtc)` for the history lists and by `(UserId, MediaKind, StartedOnUtc)` for date filtered statistics. |
|
||||
| Domain events | `MediaConsumptionStartedDomainEvent`, `MediaConsumptionProgressedDomainEvent`, `MediaConsumptionCompletedDomainEvent` and `MediaConsumptionStoppedDomainEvent`. Resume point changes raise no event; the history events are the published seam. |
|
||||
|
||||
### Counting rules
|
||||
|
||||
The statistics count a session when the rule of its media kind says so. Duration totals every record, including the records that do not count, because the time was consumed regardless.
|
||||
|
||||
| Media kind | A session counts when |
|
||||
|---|---|
|
||||
| `MusicTrack` | The session completed, or the consumed duration reached 30 seconds |
|
||||
| `PodcastEpisode` | The session completed, or the consumed duration reached 30 seconds |
|
||||
| `Audiobook` | The session completed, or the consumed duration reached 60 seconds |
|
||||
| `Movie` | The session completed, or the consumed duration reached 3 minutes |
|
||||
| `TvEpisode` | The session completed, or the consumed duration reached 3 minutes |
|
||||
| `Book` | The session completed, or more than 5 consecutive pages were read |
|
||||
| `Photo` | Every session counts |
|
||||
| `Video` | The session completed, or the consumed duration reached 3 minutes |
|
||||
|
||||
### Operations
|
||||
|
||||
- **Start**: validates the request, requires the current user, evaluates the library ownership policy, rejects an unsupported kind, resolves the item through the catalogue repository of its kind within the route library, and loads the library settings. When tracking is on and the kind can resume, the new record is initialized from the stored resume point; the consumed duration always starts at zero. A one-shot kind such as a photo is created completed in the same call.
|
||||
- **Progress**: loads the record of the current user, applies the latest position, fraction, duration and consecutive page count, and upserts the resume point when tracking is on and the kind can resume. Progress never completes a session.
|
||||
- **Complete**: loads the record of the current user, makes it terminal as `Completed`, and deletes the resume point for the same user, kind and item.
|
||||
- **Stop**: loads the record and the library settings. It stops the record without a threshold check when tracking is off or no threshold is set. When tracking is on and a threshold is set, a final fraction at or above it completes the record and deletes the resume point; otherwise the record is stopped and the resume point is upserted.
|
||||
- **Statistics**: the statistics repository binds the target user and every optional filter and returns read-only record entities. The application handlers aggregate the records, resolve display data and tags or genres through the catalogue repositories, paginate, and map the DTOs.
|
||||
- **Deletion**: deleting a record, every record of an item, or the whole history is idempotent and never deletes resume points. Clearing resume points never deletes history. An administrator may delete any user's history or resume points through the per-user routes; reading a resume point stays owner only.
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive Outcomes
|
||||
|
||||
| Aspect | Benefit |
|
||||
|---|---|
|
||||
| One model | Music, books and every planned kind share one history, one resume representation, one set of lifecycle endpoints and one statistics read model |
|
||||
| Context isolation | Both aggregates hold identifiers only, so the context depends on no media catalogue and could move to its own service |
|
||||
| Independent lifecycles | History and resume can be deleted, completed and queried independently without one becoming the source of truth for the other |
|
||||
| Correct statistics | Statistics always agree with the stored history, and a deleted record or a changed counting rule takes effect on the next request |
|
||||
| Per-library policy | Progress tracking and completion thresholds are chosen per library instead of being hardcoded for a media kind |
|
||||
| Privacy by default | A regular user cannot read or delete another user's data, and a wrong user id is reported as not authorized rather than revealing existence |
|
||||
|
||||
### Risks and Mitigations
|
||||
|
||||
| Risk | Mitigation Strategy |
|
||||
|---|---|
|
||||
| Without a foreign key, a record can point at an item that no longer exists | This is intended: the history keeps its counts and duration, and the list returns the item as unavailable with blank display data so the user can delete it |
|
||||
| A client can report a lower position after a higher one | This is the required behavior: the latest position wins, and only the consumed duration is monotonic |
|
||||
| Statistics recompute from all matching records on every request | The repository filters by user, library, kind and date range in the query. A rollup can be added later as an optimization without changing the write model |
|
||||
| A resume point can become orphaned when an item or library is deleted | Reading a resume point resolves the item through its catalogue first; a missing item or a library mismatch deletes the orphan and reports the item as not found |
|
||||
| A forgotten `InProgress` record stays in history | The client ends a session on stop, skip, track change, reaching the end, a playback failure or unload. Pause and seek only report progress and leave the session in progress. A lost start is not expired by the server, so its record remains in history until the user deletes it. The limitation is accepted instead of adding expiry or cleanup of abandoned records |
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### 1. Add a history and resume model per media kind
|
||||
|
||||
A `BookReadingHistory`, a `VideoWatchHistory` and a `PhotoViewHistory`, each with its own aggregate, table, endpoints and contracts.
|
||||
|
||||
**Rejected**: it repeats the same aggregate, table, endpoints and contracts for every kind, and it makes cross-kind statistics, deletion and admin visibility a union of several models. It also reintroduces the same extension cost for every planned catalogue.
|
||||
|
||||
### 2. Store the resume position inside the record
|
||||
|
||||
Keep the latest position only on `MediaConsumptionRecord` and find the last record when a client resumes.
|
||||
|
||||
**Rejected**: the history is a session log, while resuming is one current value per item. Finding it would mean reading the latest record and keeping abandoned records alive, and deleting history would silently remove the ability to resume. The two values have different lifetimes, business keys and deletion rules, so they are separate aggregates.
|
||||
|
||||
### 3. Store statistics as counter columns or a rollup table
|
||||
|
||||
Maintain total duration, counted sessions and completed sessions as counters, or project them into a table.
|
||||
|
||||
**Rejected**: a counter is a second source of truth. Deleting history, changing a counting rule or fixing a bad session would leave it wrong until a rebuild, while deriving the statistics from the records is always correct and needs no rebuild.
|
||||
|
||||
### 4. Hardcode resumability and completion thresholds per media kind
|
||||
|
||||
Decide in the aggregate that music can never resume, that books always complete at 100 percent, and that video always completes at 90 percent.
|
||||
|
||||
**Rejected**: users want to resume a movie without watching the credits to the last second, some music libraries want to resume, and a book library may want an explicit completion only. The library owns these choices, and the media kind only supplies the default and the shape of a position.
|
||||
@@ -286,6 +286,7 @@ class Track
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"container": "FLAC",
|
||||
"bitrate": 980,
|
||||
"acoustId": "f0e1d2c3-b4a5-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"replayGainTrackGain": -7.5,
|
||||
|
||||
@@ -5,12 +5,26 @@
|
||||
- _**Metadata**_: Information describing a media item
|
||||
- _**User**_: A person who interacts with the media library
|
||||
- _**Playlist**_: A curated list of media items, potentially cross-media-type
|
||||
- _**Favorite**_: The marker a user places on a media item of any media kind, private to that user. It references the item only by its kind and its Id, so one concept serves music, books and the media kinds that are planned
|
||||
- _**FavoriteMediaKind**_: The set of media item kinds that can be marked as a favorite
|
||||
- _**Tag**_: A label for categorizing and organizing media items
|
||||
- _**Collection**_: A user-defined group of any media items
|
||||
- _**File**_: The actual digital file of a media item
|
||||
- _**Stream**_: A media item accessed via streaming rather than local storage
|
||||
- _**Language Track**_: An audio or text track in a specific language
|
||||
- _**Media Contributor**_: A person, group, or organization that contributed to a media item, together with the role they played
|
||||
- _**Direct Play**_: Delivery of a track's audio as stored, because the player can demux its container and decode its codec
|
||||
- _**Remux**_: Delivery of a track's audio with its codec repackaged into a container the player can demux, without re-encoding it
|
||||
- _**Transcode**_: Delivery of a track's audio re-encoded into a codec the player can decode
|
||||
- _**Playback Capabilities**_: The container and codec combinations a player advertises it can demux and decode directly
|
||||
- _**Delivery Shape**_: The way delivered audio is addressed and seeked, by byte range or as fixed duration, time addressed segments
|
||||
- _**Media Consumption**_: The recording of what a user consumed, how far they reached and how long they consumed it, across every media kind
|
||||
- _**Media Consumption Record**_: The record of one consumption session of a media item by a user, from its start to its progress, completion or stop, private to that user. It stores no queue, current index, repeat or shuffle state
|
||||
- _**Media Resume Point**_: The latest position of one media item for one user, stored separately from the consumption history so the user can resume the item. There is at most one per user, media kind and media item
|
||||
- _**Consumption Statistics**_: The read model derived from the consumption records on every request. It is not an aggregate, it is not stored, and it has no counter or rollup table
|
||||
- _**Counted Session**_: A consumption record that counts towards the statistics, because it completed or because its media kind's counting rule was reached
|
||||
- _**ShouldTrackConsumptionProgress**_: The per-library setting that decides whether the latest position of an item is remembered, so the user can resume it
|
||||
- _**CompletionThresholdPercentage**_: The optional per-library percentage of an item that must be consumed for a session to count as completed when it stops. When it is absent and tracking is on, completion is recorded only when it is reported explicitly
|
||||
|
||||
## Video Content
|
||||
- _**TV Show**_: A series of episodes typically organized into seasons
|
||||
@@ -88,8 +102,11 @@
|
||||
- SheetMusic
|
||||
- Photo
|
||||
- PhotoAlbum
|
||||
- MediaConsumptionRecord
|
||||
- MediaResumePoint
|
||||
- User
|
||||
- Playlist
|
||||
- Favorite
|
||||
- Collection
|
||||
- SubtitleFile
|
||||
- Lyrics
|
||||
@@ -107,7 +124,10 @@
|
||||
- PodcastLibrary (root: PodcastLibrary, entities: Podcast, PodcastEpisode)
|
||||
- WrittenContentLibrary (root: WrittenContentLibrary, entities: Book, EBook, BookSeries, ComicBook, ComicSeries, Magazine, MagazineIssue, Newspaper, Manga, GraphicNovel, AcademicPaper, SheetMusic, Screenplay)
|
||||
- PhotoLibrary (root: PhotoLibrary, entities: Photo, PhotoAlbum, AlbumArtwork, MoviePoster)
|
||||
- UserProfile (root: User, entities: Playlist, Collection)
|
||||
- UserProfile (root: User, entities: Collection)
|
||||
- PlaylistManagement (root: Playlist, entities: PlaylistEntry)
|
||||
- Favorites (root: Favorite, no entities)
|
||||
- MediaConsumption (roots: MediaConsumptionRecord, MediaResumePoint, no entities)
|
||||
- SupplementaryContentLibrary (root: SupplementaryContentLibrary, entities: SubtitleFile, Lyrics, LanguageTrack)
|
||||
- FileSystemManagement (root: File, entities: Stream)
|
||||
|
||||
@@ -160,6 +180,14 @@
|
||||
- StreamInfo
|
||||
- StreamingQuality
|
||||
- UserPreferences
|
||||
- LibraryConsumptionSettings
|
||||
- MediaConsumptionRecordId
|
||||
- MediaResumePointId
|
||||
- MediaPosition
|
||||
- MediaConsumptionRule (abstract)
|
||||
- DurationThresholdConsumptionRule (abstract)
|
||||
- PageThresholdConsumptionRule (abstract)
|
||||
- EverySessionConsumptionRule (abstract)
|
||||
- Rating (abstract)
|
||||
- AudioRating
|
||||
- Genre
|
||||
@@ -203,6 +231,16 @@
|
||||
- MediaItemRemoved
|
||||
- PlaylistCreated
|
||||
- PlaylistUpdated
|
||||
- PlaylistEntryAdded
|
||||
- PlaylistEntryRemoved
|
||||
- PlaylistEntriesReordered
|
||||
- PlaylistDeleted
|
||||
- FavoriteAdded
|
||||
- FavoriteRemoved
|
||||
- MediaConsumptionStarted
|
||||
- MediaConsumptionProgressed
|
||||
- MediaConsumptionCompleted
|
||||
- MediaConsumptionStopped
|
||||
- UserPreferencesChanged
|
||||
- MetadataUpdated
|
||||
- FileTranscoded
|
||||
@@ -217,6 +255,13 @@
|
||||
- UserExperience
|
||||
- Aggregates: UserProfile
|
||||
- Services: RecommendationEngine, ContentCurationService, UserActivityTrackingService
|
||||
- PlaylistManagement
|
||||
- Aggregates: Playlist
|
||||
- Favorites
|
||||
- Aggregates: Favorite
|
||||
- MediaConsumption
|
||||
- Aggregates: MediaConsumptionRecord, MediaResumePoint
|
||||
- Read models: ConsumptionStatistics
|
||||
- ContentDelivery
|
||||
- Aggregates: FileSystemManagement
|
||||
- Services: StreamingService, ContentSynchronizationService
|
||||
@@ -232,6 +277,10 @@
|
||||
- PhotoRepository
|
||||
- UserRepository
|
||||
- PlaylistRepository
|
||||
- FavoriteRepository
|
||||
- MediaConsumptionRecordRepository
|
||||
- MediaResumePointRepository
|
||||
- ConsumptionStatisticsRepository
|
||||
- CollectionRepository
|
||||
- FileRepository
|
||||
- StreamRepository
|
||||
@@ -0,0 +1,8 @@
|
||||
POST {{host}}/api/v1/users/me/favorites
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"mediaKind": "MusicTrack",
|
||||
"mediaItemId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/users/me/favorites/status?mediaKind=MusicTrack&mediaItemIds=9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f&mediaItemIds=8e9f0a1b-2c3d-4e5f-9a6b-7c8d9e0f1a2b
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/users/me/favorites?mediaKind=MusicTrack¤tPage=1&perPage=200
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,2 @@
|
||||
DELETE {{host}}/api/v1/users/me/favorites/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/{{$guid}}/playback-manifest?capabilities=mp3/mp3,flac/flac,ogg/opus,ogg/vorbis,wav/pcm,mp4/aac
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,10 @@
|
||||
POST {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/tracks/shuffle
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"count": 100,
|
||||
"artistId": null,
|
||||
"albumId": null,
|
||||
"excludedTrackIds": []
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/{{$guid}}/stream
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Range: bytes=0-1048575
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/{{$guid}}/stream/deliveries/8f14e45fceea167a5a36dedd4bea2543/segments/0
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -3,7 +3,6 @@ Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
|
||||
@@ -14,6 +14,8 @@ Content-Type: application/json
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [
|
||||
{ "kind": "Artist", "representation": "{0}", "isOptional": false },
|
||||
{ "kind": "Separator", "representation": "", "isOptional": false }
|
||||
|
||||
@@ -16,6 +16,8 @@ Content-Type: application/json
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [
|
||||
{ "kind": "Artist", "representation": "{0}", "isOptional": false },
|
||||
{ "kind": "Separator", "representation": "", "isOptional": false }
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
DELETE {{host}}/api/v1/users/me/consumption-history
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
DELETE {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,11 @@
|
||||
### Current user, every library
|
||||
DELETE {{host}}/api/v1/users/me/media-resume-points
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Current user, one library
|
||||
DELETE {{host}}/api/v1/users/me/media-resume-points?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
DELETE {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/media-resume-points
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
DELETE {{host}}/api/v1/users/me/consumption-history/media-items/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
DELETE {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/media-items/Book/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
DELETE {{host}}/api/v1/users/me/consumption-history/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
DELETE {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,3 @@
|
||||
### All users (admin)
|
||||
GET {{host}}/api/v1/users/consumption-statistics?fromUtc=2026-10-01T00:00:00Z&toUtc=2026-10-31T23:59:59Z
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
GET {{host}}/api/v1/users/me/consumption-statistics?fromUtc=2026-10-01T00:00:00Z&toUtc=2026-10-31T23:59:59Z
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
GET {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-statistics?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a&mediaKind=Book
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
GET {{host}}/api/v1/users/me/consumption-statistics/genres?mediaKind=Book
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
GET {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-statistics/genres
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
GET {{host}}/api/v1/users/me/consumption-history/most-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
GET {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/most-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
GET {{host}}/api/v1/users/me/consumption-history/recently-consumed?currentPage=1&perPage=50
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
GET {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-history/recently-consumed?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a&mediaKind=MusicTrack¤tPage=1&perPage=50&fromUtc=2026-10-01T00:00:00Z&toUtc=2026-10-31T23:59:59Z
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Current user
|
||||
GET {{host}}/api/v1/users/me/consumption-statistics/tags?mediaKind=MusicTrack
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Another user (admin)
|
||||
GET {{host}}/api/v1/users/2cff0c0f-3a67-4e30-b94f-f4e948a3b64f/consumption-statistics/tags
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,29 @@
|
||||
### Music track
|
||||
POST {{host}}/api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/complete
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"position": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 300,
|
||||
"location": null
|
||||
},
|
||||
"progressFraction": 1,
|
||||
"consumedDurationInSeconds": 300
|
||||
}
|
||||
|
||||
### Book
|
||||
POST {{host}}/api/v1/users/me/consumption-records/8f7e6d5c-4b3a-4928-8170-6f5e4d3c2b1a/complete
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"position": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/8[chapter-4]!/4/2/2)"
|
||||
},
|
||||
"progressFraction": 1,
|
||||
"consumedDurationInSeconds": 900
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Music track session
|
||||
GET {{host}}/api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Book session
|
||||
GET {{host}}/api/v1/users/me/consumption-records/8f7e6d5c-4b3a-4928-8170-6f5e4d3c2b1a
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Music track
|
||||
GET {{host}}/api/v1/users/me/media-resume-points/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Book
|
||||
GET {{host}}/api/v1/users/me/media-resume-points/Book/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,31 @@
|
||||
### Music track
|
||||
PUT {{host}}/api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/progress
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"position": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 92.5,
|
||||
"location": null
|
||||
},
|
||||
"progressFraction": 0.31,
|
||||
"consumedDurationInSeconds": 92.5,
|
||||
"consecutivePagesRead": 0
|
||||
}
|
||||
|
||||
### Book
|
||||
PUT {{host}}/api/v1/users/me/consumption-records/8f7e6d5c-4b3a-4928-8170-6f5e4d3c2b1a/progress
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"position": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/6[chapter-2]!/4/2/2)"
|
||||
},
|
||||
"progressFraction": 0.18,
|
||||
"consumedDurationInSeconds": 300,
|
||||
"consecutivePagesRead": 2
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
### Music track
|
||||
POST {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/media-items/MusicTrack/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/consumption-records
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
|
||||
### Book
|
||||
POST {{host}}/api/v1/libraries/5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f/media-items/Book/7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d/consumption-records
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,29 @@
|
||||
### Music track
|
||||
POST {{host}}/api/v1/users/me/consumption-records/2c1b0a9f-8e7d-4c6b-5a4f-3e2d1c0b9a8f/stop
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"position": {
|
||||
"kind": "TimeOffset",
|
||||
"timeOffsetSeconds": 60,
|
||||
"location": null
|
||||
},
|
||||
"progressFraction": 0.6,
|
||||
"consumedDurationInSeconds": 60
|
||||
}
|
||||
|
||||
### Book
|
||||
POST {{host}}/api/v1/users/me/consumption-records/8f7e6d5c-4b3a-4928-8170-6f5e4d3c2b1a/stop
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"position": {
|
||||
"kind": "Location",
|
||||
"timeOffsetSeconds": null,
|
||||
"location": "epubcfi(/6/6[chapter-2]!/4/2/2)"
|
||||
},
|
||||
"progressFraction": 0.18,
|
||||
"consumedDurationInSeconds": 300
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/users/me/settings/playback-state
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -0,0 +1,8 @@
|
||||
PUT {{host}}/api/v1/users/me/settings/playback-state
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"volume": 0.75,
|
||||
"isMuted": false
|
||||
}
|
||||
@@ -5,9 +5,23 @@ Content-Type: application/json
|
||||
{
|
||||
"isPaginationEnabled": true,
|
||||
"itemsPerPage": 50,
|
||||
"ignoreThePrefixForAlphaPicker": true,
|
||||
"shouldIgnoreThePrefixForAlphaPicker": true,
|
||||
"isThemeCachingEnabled": true,
|
||||
"shouldAggregateMetadataWhenMissing": true,
|
||||
"shouldRenderPdfAsImages": false,
|
||||
"shouldPreserveBookStyles": true
|
||||
"shouldPreserveBookStyles": true,
|
||||
"shouldKeepDownloadingWhilePaused": true,
|
||||
"shouldAutoplay": true,
|
||||
"isGaplessPlaybackEnabled": true,
|
||||
"replayGainMode": "Off",
|
||||
"streamingQuality": "Auto",
|
||||
"vuMeterOrientation": "Vertical",
|
||||
"vuMeterSegmentCount": 12,
|
||||
"vuMeterSegmentGap": 1,
|
||||
"vuMeterMediumThreshold": 0.6,
|
||||
"vuMeterHighThreshold": 0.8,
|
||||
"vuMeterShowPeak": true,
|
||||
"vuMeterPeakHoldDurationInMilliseconds": 650,
|
||||
"vuMeterReleasePerSecond": 3,
|
||||
"vuMeterPeakReleasePerSecond": 0.65
|
||||
}
|
||||
@@ -13,8 +13,18 @@ The web client of Lumina is a themed shell: every page is rendered inside the te
|
||||
- [Safety Limits](#safety-limits)
|
||||
- [Template Resolution](#template-resolution)
|
||||
- [The Layout Template (shared/layout)](#the-layout-template-sharedlayout)
|
||||
- [The Audio Player Bar](#the-audio-player-bar)
|
||||
- [The VU Meter](#the-vu-meter)
|
||||
- [Play Affordances on the Music Pages](#play-affordances-on-the-music-pages)
|
||||
- [The audio player sub templates](#the-audio-player-sub-templates)
|
||||
- [The Navigation Template (shared/nav-menu)](#the-navigation-template-sharednav-menu)
|
||||
- [Page Templates](#page-templates)
|
||||
- [The Playlist Pages](#the-playlist-pages)
|
||||
- [The Shared Add to Playlist Action](#the-shared-add-to-playlist-action)
|
||||
- [The Album Track Actions Menu](#the-album-track-actions-menu)
|
||||
- [The Favorites Page](#the-favorites-page)
|
||||
- [The Statistics Page](#the-statistics-page)
|
||||
- [Favorite Toggles](#favorite-toggles)
|
||||
- [The Scripts Section](#the-scripts-section)
|
||||
- [Assets](#assets)
|
||||
- [Configuration Options](#configuration-options)
|
||||
@@ -161,7 +171,14 @@ Known page keys:
|
||||
| `shared/layout` | The layout that wraps the shell of every page. |
|
||||
| `shared/nav-menu` | The navigation menu of the theme. |
|
||||
| `shared/not-found` | The 404 page. |
|
||||
| `shared/audio-player` | The audio player bar shell. |
|
||||
| `shared/audio-player/queue-item` | The queue item of the audio player bar. |
|
||||
| `shared/audio-player/playlist-item` | The playlist item of the audio player bar. |
|
||||
| `library/written-content-library/book-library/books/index` | The books browsing page. |
|
||||
| `playlists/index` | The page that lists and deletes the playlists of the current user. |
|
||||
| `playlists/item` | The page that creates a playlist, or edits, reorders, plays and deletes an existing playlist of the current user. The `isNew` page data field tells the two modes apart. |
|
||||
| `favorites/index` | The page that lists, filters and removes the favorites of the current user across media kinds. |
|
||||
| `library/statistics/index` | The page that shows the consumption statistics of the current user or, for an administrator, of another user or every user, across every media kind. |
|
||||
| `shared/file-system-browser` | The file system browser component shell. |
|
||||
| `shared/file-system-browser/tree-node` | The tree view node of the file system browser. |
|
||||
| `shared/file-system-browser/explorer-item` | The file system entry of the file system browser. |
|
||||
@@ -222,6 +239,185 @@ The layout template of the bundled theme shows the intended shape:
|
||||
|
||||
The rendered page content, navigation and scripts are inserted unescaped with `{{&...}}`, because they are trusted application HTML. The layout is best effort: when the theme cannot be loaded or rendered, the application falls back to its built-in layout, so a broken theme never takes the whole site down.
|
||||
|
||||
### The Audio Player Bar
|
||||
|
||||
Every authenticated page renders the audio player bar through the `audioPlayer` field of the layout model. The bar starts hidden, and the global audio player script shows it when playback starts, expands it and hides it again. The markup comes from the `shared/audio-player` template of the active theme; when the theme does not provide that template, the application renders its own fallback markup, so the player always has a bar to bind to.
|
||||
|
||||
The theme owns the position, orientation and size of the bar, and it owns the room reserved for it on the main content element. The application fallback happens to fix the bar to the bottom, but that is only the fallback layout: a theme can make it a vertical bar on a side, a horizontal bar at the bottom, or any other placement, and can expand its queue in any direction. A layout must keep these element hooks, which the audio player drives (the id control is bound by the global site script, which routes it to the audio player):
|
||||
|
||||
| Element | Hook | Meaning |
|
||||
| --- | --- | --- |
|
||||
| The bar container, with the `audio-player-container` class | `not-shown` class | The bar is hidden. The theme decides how that state is presented and which space it releases. |
|
||||
| The bar container | `expanded` class | The bar is expanded. This is the layout-neutral state a theme styles for its own layout. |
|
||||
| The bar container | `inert` attribute | Set while the bar is hidden and removed when it is shown, so a collapsed bar keeps none of its focusable controls in the tab order. |
|
||||
| The expanded area, with the `audio-player-expanded` class | Layout child of the bar container | The cover art, now playing details and queue of the expanded bar. Its position is theme-owned. The fallback stylesheet places it above the bar in a flex column, but the player does not require that layout. A theme that animates the area should keep it in the DOM while the transition runs. |
|
||||
| The condensed bar, with the `audio-player-bar` class | Layout child of the bar container | The row of controls. Its position is theme-owned; the fallback stylesheet places it at the bottom edge of the container. |
|
||||
| The main content element | `audio-player-not-shown` class | The bar is hidden, so the content area releases the room the theme reserved for the bar. |
|
||||
| The main content element | `audio-player-bar-expanded` class | The bar is expanded. This is the layout-neutral state for the main content element's own adjustment. |
|
||||
| The expand and collapse control | `id="audio-player-expand-toggle"` | A focusable control, such as a `button`, that expands or collapses the bar. Its label may describe the action in the theme's own layout. |
|
||||
| The queue-to-playlist combo box | `data-audio-player-playlist-combobox` | A standard application combo box (`enlightenment-combobox`) in the expanded area that lists the playlists of the current user. Its root carries the hook; its selected text carries the chosen playlist Id in `data-value`. When the theme does not render the hook, the player builds a built-in combo box of the same markup and places it in a `audio-player-queue-area` wrapper above the queue, so the action never becomes a new column of the expanded layout. |
|
||||
| The queue-to-playlist button | `data-audio-player-add-queue-to-playlist` | A focusable control in the expanded area that appends the current queue, in order, to the playlist selected in the combo box. When the theme does not render it, the player builds a built-in button next to the combo box. The player disables it while the queue is empty, while no playlist exists, and while an add is in flight. |
|
||||
|
||||
The `shared/audio-player` template receives the following model:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `appBase` | The absolute base URL of the Web application, used to reference the application scripts. |
|
||||
| `assetBase` | The base URL of the theme assets, used by the theme template to reference its own assets. |
|
||||
| `queueItemTemplate` | The raw source of the `shared/audio-player/queue-item` sub template, inlined by the application into a plain text script element. |
|
||||
| `playlistItemTemplate` | The raw source of the `shared/audio-player/playlist-item` sub template, inlined by the application into a plain text script element. |
|
||||
| `strings` | The localized strings of the bar, keyed by their resource names. A shell template uses `toggleExpanded`, `previous`, `next`, `stop`, `repeat`, `repeatOff`, `repeatAll`, `repeatOne`, `queue`, `albumArtwork`, `addQueueToPlaylist`, `addToPlaylist`, `selectPlaylist` and `add` for its controls; the player reads the play, pause, mute, unmute, volume, seek, buffering, success and failure labels from the global scripts configuration instead, so a themed shell does not need to render them. |
|
||||
|
||||
The bundled themes reserve the room for their bottom bar like this. It is an example of a bottom layout, not a required layout:
|
||||
|
||||
```css
|
||||
main {
|
||||
bottom: 50px;
|
||||
transition: bottom 1s ease, height 1s ease;
|
||||
}
|
||||
|
||||
main.audio-player-not-shown {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
main.audio-player-bar-expanded {
|
||||
bottom: calc(100% - 22px); /* expanded height, less the menu height */
|
||||
}
|
||||
```
|
||||
|
||||
A theme with a vertical bar instead reserves a side column, a theme with a bar on top reserves top space, and a theme whose expanded bar overlays the content reserves no space at all. The application fallback layout reserves the room itself, because the application stylesheet does not position the content area of a theme. A theme that omits its own space reservation leaves its bar overlapping its content.
|
||||
|
||||
The flex column used by the application fallback is also only a default. The player toggles the state classes and never reads the geometry of the bar, so a theme can lay the container out in any direction, place the expanded area to the left, right, above or below the condensed bar, and make the queue scroll vertically or horizontally. The player's only layout-dependent behavior is scrolling the `data-audio-player-queue` element so the current entry aligns to its start on both axes.
|
||||
|
||||
A theme that restyles the fallback transition can set `--audio-player-expanded-duration` on `.audio-player-container` to keep its height, fade and padding transitions on the same duration. The bundled themes set it to `1s`, matching their own height transition; the application fallback uses `0.4s`. A theme that uses a different transition can ignore the property.
|
||||
|
||||
The markup inside the bar exposes the hook attributes the audio player script binds. A theme that replaces the bar markup must keep all of them; the part of the bar whose hook is missing stays inert. The deprecated `queuechange` event keeps its ordered descriptor array payload for older theme scripts; new code must use `queuestatechange`, whose payload is the compact queue summary.
|
||||
|
||||
| Hook attribute | Meaning |
|
||||
| --- | --- |
|
||||
| `data-audio-player-play-pause` | The play and pause control. The player adds the `is-playing` class to it while a track plays. |
|
||||
| `data-audio-player-stop` | The stop control. Clicking it stops playback; a condensed bar then slides out of view, while an expanded bar stays on screen. |
|
||||
| `data-audio-player-previous` | The previous control. It either returns to the previous queue entry or restarts the current track, following the navigation history. |
|
||||
| `data-audio-player-next` | The next control. It starts the next queue entry and loads another shuffle or autoplay batch when the queue is at its end. The player sets `disabled` and the `is-disabled` class when there is no next entry. |
|
||||
| `data-audio-player-repeat` | The repeat toggle. The player writes `data-audio-player-repeat-mode` (`off`, `all` or `one`), toggles `aria-pressed`, the `is-active` class and, for one, the `is-one` class. |
|
||||
| `data-audio-player-progress` | The progress bar, a `role="slider"` element with `tabindex="0"` that the player scrubs and whose ARIA value attributes it writes. It carries `data-audio-player-progress-state` (`idle`, `ready` or `buffering`) and the `is-buffering` class while it loads. |
|
||||
| `data-audio-player-progress-played` | The played layer of the bar. The player publishes its start and width as the custom properties `--audio-player-progress-played-start` and `--audio-player-progress-played-width`. |
|
||||
| `data-audio-player-progress-downloaded` | The downloaded but not played layer. `--audio-player-progress-downloaded-start` and `--audio-player-progress-downloaded-width`. |
|
||||
| `data-audio-player-progress-undownloaded` | The not yet downloaded layer. `--audio-player-progress-undownloaded-start` and `--audio-player-progress-undownloaded-width`. |
|
||||
| `data-audio-player-current-time` | The current position, written as `m:ss`. |
|
||||
| `data-audio-player-total-time` | The duration, written as `m:ss`, or `--:--` while it is unknown. |
|
||||
| `data-audio-player-track-name` | The track name. |
|
||||
| `data-audio-player-album-name` | The album name, shown underneath the track name. The player leaves it empty when the descriptor has no album title, including when the title is the stored `Unknown Album` placeholder, so a track without an album shows only its name. |
|
||||
| `data-audio-player-now-playing-title` | The current track name of the expanded player, under its cover. |
|
||||
| `data-audio-player-now-playing-release-type` | The release type of the current track's album, such as Album, Live or EP. Multiple types are joined with commas. It is left empty when the album has no release type. |
|
||||
| `data-audio-player-now-playing-release` | The release name of the current track's album in the expanded player. It is left empty when the album has no displayable title. |
|
||||
| `data-audio-player-now-playing-year` | The release year of the current track's album in the expanded player. It is left empty when the year is not known. |
|
||||
| `data-audio-player-now-playing-artist` | The artist name of the current track's album in the expanded player. It is left empty until the album details are available. |
|
||||
| `data-audio-player-favorite` | The favorite toggle of the current track, in the condensed bar between repeat and mute. The player sets its media kind and track Id, and hides it while no track is loaded. A missing hook gets the built-in toggle in that place. |
|
||||
| `data-audio-player-artwork-carousel` | The carousel of the stored artwork of the current track's album. The player appends one `button.artwork-carousel-item` per stored image, carrying `data-artwork-path`, and toggles the `selected` class and `aria-pressed` on the chosen item. The element is hidden with the `hidden` attribute while the album has no stored artwork. |
|
||||
| `data-audio-player-cover-thumbnail`, `data-audio-player-cover-image` | The cover art of the condensed bar and of the expanded bar. Choosing an album artwork in the carousel replaces both images until the next track. |
|
||||
| `data-audio-player-vu-meter` | The root of the VU meter of the condensed bar, between the album art and the current time label. The player fills it with its channels, segments and peak markers, exactly as described in [The VU Meter](#the-vu-meter). A theme that does not render the hook gets the built-in meter inserted in that place. |
|
||||
| `data-audio-player-volume` | The volume slider, a `role="slider"` element with `tabindex="0"` that the player scrubs and whose ARIA value attributes it writes. The fill is published as `--audio-player-volume-start` and `--audio-player-volume-width`. |
|
||||
| `data-audio-player-volume-level` | The volume fill. It carries no geometry of its own: the stylesheet drives it from the custom properties above. |
|
||||
| `data-audio-player-mute` | The mute toggle. The player toggles the `is-muted` class and the `aria-pressed` state on it. |
|
||||
| `data-audio-player-queue` | The queue list of the expanded bar. The player writes `data-audio-player-queue-entry-id` on every rendered item root, whether it comes from the theme sub template or from the built-in markup, and makes the root focusable, so clicking an item or pressing Enter or Space on it starts that entry. The element must stay the scroll container of the list, because the player scrolls the current entry to the start of whichever axis the theme makes scrollable when playback advances or the bar expands. |
|
||||
|
||||
Each progress layer also carries `data-audio-player-progress-layer` (`played`, `downloaded` or `undownloaded`) in the markup, so a theme can select a layer by its state as well as by its class. The player writes no inline geometry on any of the bar elements: it publishes the geometry of each state as the custom properties above, which the application stylesheet consumes, so a theme restyles or reorients either bar by consuming the same properties.
|
||||
|
||||
#### The VU Meter
|
||||
|
||||
The condensed bar shows a segmented VU meter that follows the level of the track itself. The renderer taps it after the track's ReplayGain normalization and before the output volume and mute stage, so lowering the volume or muting the player never changes the height of the meter for the same moment of audio. The meter is a spectrum meter with one channel per frequency band, with 24 logarithmically spaced bands between 40 Hz and 16 kHz, each drawn as a stack of segments. The number of segments, the gap between them, the two threshold zones, the peak marker and its hold and falloff times, and the orientation are per-user settings, so the meter reflects the values the user saved on the settings page.
|
||||
|
||||
The meter is built from elements rather than a canvas, exactly like the three state progress bar, so a theme restyles every part of it. The root carries the `audio-player-vu-meter` class and the `data-audio-player-vu-meter` hook, and the player fills it with:
|
||||
|
||||
| Element | Class and hook | State the player writes |
|
||||
| --- | --- | --- |
|
||||
| A channel, one per band | `audio-player-vu-channel`, `data-audio-player-vu-channel` (the zero based band index) | None. The channel is a layout container. |
|
||||
| A segment, one per configured segment of a channel | `audio-player-vu-segment`, `data-audio-player-vu-segment` | `data-audio-player-vu-segment-state` (`active` or `inactive`) and `data-audio-player-vu-segment-zone` (`normal`, `medium` or `high`). The zone is derived from the position of the segment and the two thresholds of the settings. |
|
||||
| A peak marker, one per channel | `audio-player-vu-peak`, `data-audio-player-vu-peak` | `data-audio-player-vu-peak-state` (`active` or `inactive`). The marker is removed with the `hidden` attribute while the show peak setting is off. |
|
||||
|
||||
The segments are rendered in ascending level order, so the first segment of a channel is the quietest one. The root also carries `data-audio-player-vu-meter-orientation` (`vertical` or `horizontal`), `data-audio-player-vu-meter-segments` (the configured segment count) and `data-audio-player-vu-meter-show-peak` (`true` or `false`), so a theme can select a state or a layout from the root as well.
|
||||
|
||||
The player publishes no geometry other than two custom properties, which a theme maps to whichever axis its own layout uses:
|
||||
|
||||
| Custom property | Published on | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `--audio-player-vu-segment-gap` | The meter root | The configured gap between segments and between channels, as a CSS length in pixels. |
|
||||
| `--audio-player-vu-segment-count` | The meter root | The configured number of segments per channel, as a plain number, so a stylesheet can size the meter from it. |
|
||||
| `--audio-player-vu-peak-position` | Each peak marker | The held peak of its channel, as a percentage of the channel axis, from `0%` at the quiet end to `100%` at the loud end. |
|
||||
|
||||
The fallback stylesheet sizes the vertical meter from whole pixel square cells rather than stretching it over a box, because a box divided into rows gives fractional heights that browsers snap unevenly. The cell is the largest whole pixel size that fits the configured segments in `--audio-player-vu-extent` (48px by default), capped by `--audio-player-vu-max-cell` (4px), and a theme can override either property. With the default 12 segments and a 1px gap the cells are 3px squares.
|
||||
|
||||
The application fallback stylesheet gives the meter its own default look: 24 columns of segments whose active state uses one of three colors, with the inactive segments transparent, and a peak line that spans the short axis of the channel. A theme can replace all of it. The colors are custom properties declared on the bar container (`--audio-player-vu-normal-color`, `--audio-player-vu-medium-color`, `--audio-player-vu-high-color`, `--audio-player-vu-inactive-color`, `--audio-player-vu-peak-color` and `--audio-player-vu-background-color`), so a theme recolors the meter without touching the markup, and it can give each zone, each state and each orientation its own shape, image or animation.
|
||||
|
||||
The meter is decorative for assistive technology and carries `aria-hidden="true"`, because the same information is available through the now playing labels and the progress bar. It reads the analyzer that the player renderer taps after the track's ReplayGain normalization and before the output volume, so it needs no extra request and no extra decode, it is unaffected by the volume and mute controls, and it never affects playback. When the player is paused, stopped, ended or failed, the displayed levels fall to zero instead of freezing.
|
||||
|
||||
#### Play Affordances on the Music Pages
|
||||
|
||||
The artist page, the album page and the track page render play triggers, and the card actions menus render play and shuffle triggers, all handled by the global audio player script through event delegation. The music library cards on the home page, the artist cards and the album cards offer both actions, so the whole library, an artist or a release can be started in order or shuffled. A theme template that replaces one of those pages or menus opts in by rendering the same trigger attributes: the player binds one listener on the document, so a trigger works anywhere in the swapped page content and the page needs no script of its own.
|
||||
|
||||
The trigger attributes are:
|
||||
|
||||
| Attribute | Meaning |
|
||||
| --- | --- |
|
||||
| `data-audio-player-play` | Marks the element as a play trigger. Clicking it replaces the queue with the described context and starts playback. |
|
||||
| `data-audio-player-play-next` | Marks the element as a play next trigger. While something is current, clicking it inserts the described track or context after the current entry without starting playback and discards the pending autoplay continuation. When nothing is current, the player starts the described context instead, because there is no entry to queue after. |
|
||||
| `data-audio-player-play-shuffled` | Marks the element as a shuffled play trigger. Clicking it starts the described context and turns shuffle on for the scope in `data-audio-player-shuffle-scope`. |
|
||||
| `data-audio-player-play-library` | Marks the element as a library play trigger. Clicking it starts the whole library named by `data-library-id` in artist page order, without needing a track, album or artist context. |
|
||||
| `data-audio-player-play-library-shuffled` | Marks the element as a library shuffle trigger. Clicking it starts a shuffled playback of the whole library named by `data-library-id`, without needing a track, album or artist context. |
|
||||
| `data-audio-player-shuffle-scope` | The scope of a shuffled play trigger: `release`, `artist` or `library`. A shuffled play trigger without this attribute shuffles the release it started. |
|
||||
|
||||
All triggers read the play descriptor from the same `data-*` attributes:
|
||||
|
||||
| Attribute | Meaning |
|
||||
| --- | --- |
|
||||
| `data-library-id` | The Id of the media library the context belongs to. Required by every trigger. |
|
||||
| `data-track-id` | The Id of the track. Required by a track trigger. |
|
||||
| `data-album-id` | The Id of the album. Required by a track trigger and by an album context trigger. |
|
||||
| `data-artist-id` | The Id of the artist. Required by a track trigger, an album context trigger and an artist context trigger. |
|
||||
| `data-title` | The display title of the track or context, shown in the bar while the context loads. Optional. |
|
||||
| `data-album-title` | The display title of the album the track belongs to, shown under the track name in the bar. Optional, and meaningful on a track trigger. An album context already uses its `data-title` as the album title while the context loads, so it does not need this attribute. |
|
||||
| `data-duration` | The duration of the track in seconds. Optional, and meaningful on a track trigger. |
|
||||
| `data-cover-art-path` | The artwork path of the cover, relative to the API server base, exactly like the artwork path the album page uses. Optional. |
|
||||
| `data-cover-art-url` | An absolute cover art URL, or a relative artwork path. Optional, and used in preference to `data-cover-art-path` when both are present. |
|
||||
|
||||
The context a trigger describes decides the required parameters and the queue it builds:
|
||||
|
||||
| Trigger | Required attributes | Queue |
|
||||
| --- | --- | --- |
|
||||
| Track | `data-library-id`, `data-track-id`, `data-album-id`, `data-artist-id` | The single track. |
|
||||
| Album | `data-library-id`, `data-album-id`, `data-artist-id` | The tracks of the release, in disc and then track number order. |
|
||||
| Artist | `data-library-id`, `data-artist-id` | Every release of the artist in the order the artist page presents them, each in disc and track number order. |
|
||||
| Library | `data-library-id` | Every track of the first artist of the library that has tracks, in artist page order, followed by the remaining artists in the same order. |
|
||||
|
||||
The album queue is read through `api-get-tracks`, the artist queue through `api-get-albums` and then `api-get-tracks`, and a track trigger uses the descriptor alone. A library trigger reads `api-get-artists` to find the first artist that has tracks and then builds that artist's queue; when playback reaches the end, the continuation walks the remaining artists in library order. The queue script documents these endpoints and their order in full.
|
||||
|
||||
An album or artist trigger carries its effective cover into the entries it queues. A `data-cover-art-url` is kept as the resolved cover URL of the context, so a theme that supplies only that attribute does not lose the cover when the queue is built. An album trigger falls back to the context cover for a release without one. An artist trigger falls back to the artist cover, and a library trigger falls back to the cover of the artist the release belongs to, so a release with its own cover always keeps that cover. The `data-cover-art-path` is kept on every entry for artwork matching, even when the trigger supplies a cover URL.
|
||||
|
||||
Each page exposes the values its own triggers need. The album page provides `artistId`, `albumId`, `libraryId`, `albumTitle`, `albumCoverPath` and `albumHasTracks` for the album trigger. Its per-track triggers are rendered from the track rows the page loads from `tracksUrl`, which returns the `id`, `title`, `trackNumber`, `discNumber` and `durationInSeconds` of each track; `albumJson` carries the album model the template script starts from, and `trackUrl` is the template of a track page route. The artist page provides `artistId`, `libraryId`, `artistName`, `artistCoverPath` and `artistHasReleases` for the play all trigger, and `albumsUrl` and `albumUrl` for the release list and its cards. The release rows returned by `albumsUrl` carry the `id`, `title` and `coverPath` used by the album card Play and Shuffle actions. The track page provides `artistId`, `albumId`, `trackId`, `libraryId`, `trackTitle`, `trackDurationInSeconds`, `albumTitle` and `albumCoverPath` for its trigger. The artist index page provides `libraryId` and `itemsUrl` for its artist cards, and each row of `itemsUrl` carries the `id`, `name` and `coverPath` used by the artist card Play and Shuffle actions. The home page library cards are application markup, and each music library card uses the library `id` for its Play and Shuffle actions. A theme template that changes these pages uses the same values and endpoints to render equivalent triggers.
|
||||
|
||||
The application fallback templates render the triggers on the existing `confirm-button` controls: the page-level controls carry their localized label, and the per-track control carries a text play glyph with an accessible label. The card actions menus of music libraries, artists and albums render Play and Shuffle; the album card menu also keeps Remove beside them. A theme may use any markup and classes; only the trigger and descriptor attributes are required, and a trigger must be a focusable element, such as a `button`. The bundled themes render these triggers on the pages and card menus they provide, so a custom theme that replaces one of those templates must render them again to keep playback and shuffle reachable from that page.
|
||||
|
||||
#### The audio player sub templates
|
||||
|
||||
Like the file system browser, the audio player is split into a shell template and the sub templates of its dynamic content, all provided as mirrored files under `templates/shared/audio-player/`. The shell template inlines the raw source of each sub template into a plain text script element, so that the browser never parses the theme markup into live elements and requests their resources before the player renders them:
|
||||
|
||||
```html
|
||||
<script type="text/plain" id="audio-player-template-queue-item">{{{queueItemTemplate}}}</script>
|
||||
<script type="text/plain" id="audio-player-template-playlist-item">{{{playlistItemTemplate}}}</script>
|
||||
```
|
||||
|
||||
The sub templates are rendered client side by the audio player script with the same Mustache syntax as the server side engine. They receive the following fields:
|
||||
|
||||
| Template | Fields |
|
||||
| --- | --- |
|
||||
| `queue-item` | `entryId` (the identity of this occurrence in the queue), `index` (the one based position in the queue), `trackId`, `albumId`, `artistId`, `libraryId`, `title`, `duration` (the formatted `m:ss` duration), `durationSeconds`, `coverArtUrl` (the resolved cover art URL, which is the music placeholder when the entry has no artwork), `isCurrent`, `isPlayed`, `isLast`, `isContinuation` (the entry was added by the autoplay continuation) and `isShuffled` (the entry was added by a shuffle batch). The item root must keep the `audio-player-queue-item` class, the stylesheet hook of a queue item: the player appends the rendered element as-is, so the class is what lets the theme style it. The player writes `is-current`, `is-played`, `is-continuation` and `is-shuffled` on the root itself, so a theme item does not need to render those state classes, and it writes `data-audio-player-queue-entry-id`, so a theme item does not need to render the identity either. A theme item should render the favorite toggle with the `data-favorite-toggle`, `data-favorite-media-kind` and `data-favorite-media-item-id` attributes. The player appends the built-in toggle when it is missing. |
|
||||
| `playlist-item` | `index`, `trackId`, `albumId`, `artistId`, `libraryId`, `title`, `duration`, `durationSeconds`, `coverArtUrl` and `isCurrent`. The item root must keep the `audio-player-playlist-item` class, the stylesheet hook of a playlist item. The shell inlines this sub template for theme authors, but the player does not render a saved playlist list with it yet; the saved playlist page renders its own rows from the page data described below. |
|
||||
|
||||
A theme can omit any sub template: the player then renders that part with its own built-in markup. When a theme replaces the shell, it must keep the two plain text script element ids above, the element hooks of the bar, and the `audio-player-container`, `not-shown` and `expanded` classes the player toggles.
|
||||
|
||||
Every field of the `queue-item` and `playlist-item` models is untrusted: titles and identifiers come from file metadata and the music endpoints. Render these fields with the escaped form, `{{field}}`. The template engine also supports the unescaped form `{{{field}}}`, but these models contain no trusted HTML, so unescaped tags must not be used for them. Escaping does not neutralise whitespace in an unquoted attribute, so every model value placed in an attribute must sit inside quoted attribute marks, for example `data-track-id="{{trackId}}"` and never `data-track-id={{trackId}}`.
|
||||
|
||||
### The Navigation Template (shared/nav-menu)
|
||||
|
||||
The navigation template renders the menu of the active theme. Its model contains the site name and two menu structures, one for the mobile menu and one for the desktop menu bar:
|
||||
@@ -317,6 +513,192 @@ Page templates are rendered into a content section that the layout wraps. A page
|
||||
{{/scripts}}
|
||||
```
|
||||
|
||||
#### The Playlist Pages
|
||||
|
||||
`playlists/index` receives a model with the following fields:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `getPlaylistsUrl` | The route that returns the playlists of the current user. |
|
||||
| `addUrl` | The route of the dedicated page that creates a playlist. |
|
||||
| `itemUrl` | The route template of a playlist page. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the playlist. |
|
||||
| `deleteUrl` | The route template that deletes a playlist. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the playlist. |
|
||||
| `antiforgeryToken` | The anti-forgery token the page submits with its mutating requests. |
|
||||
| `strings` | The localized strings of the page, keyed by their resource names. |
|
||||
|
||||
`playlists/item` receives a model with the following fields:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `isNew` | `true` on the create page, `false` on the page of an existing playlist. The same page key serves both modes. |
|
||||
| `playlistId` | The Id of the playlist the page shows, or the empty Id on the create page. |
|
||||
| `playlistJson` | The playlist metadata and only the first page of its ordered entries, serialized as JSON. `entries.count` is the total number of entries, and `entries.currentPage`, `entries.perPage` and `entries.numberOfPages` describe the page. Each entry carries `mediaItemId` and `mediaItemType`, which are generic across media kinds, together with the generic display fields `libraryId`, `collectionId`, `creatorId`, `mediaItemTitle`, `collectionTitle`, `creatorName`, `durationInSeconds` and `coverPath`. For a music entry, the collection is the album and the creator is the artist. On the create page it is an empty music playlist. |
|
||||
| `entriesPerPage` | The number of entries per page the page requests. The page fetches the next pages with `getPlaylistUrl` and the same size. |
|
||||
| `createPlaylistUrl` | The route that creates a playlist. Only meaningful when `isNew` is `true`. |
|
||||
| `itemUrl` | The route template of the page of an existing playlist. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the playlist, and the page script navigates to it after a successful create. |
|
||||
| `getPlaylistUrl` | The route that returns a page of the playlist. It takes `currentPage` and `perPage` query parameters and returns `entries` with `data`, `currentPage`, `perPage`, `count` and `numberOfPages`. When both pagination parameters are omitted, every entry is returned in one page. The `perPage` is the page size the theme requests. |
|
||||
| `updatePlaylistUrl` | The route that updates the name and description of the playlist. |
|
||||
| `deletePlaylistUrl` | The route that deletes the playlist. |
|
||||
| `addEntryUrl` | The route that adds a track to the playlist. |
|
||||
| `removeEntryUrl` | The route template that removes an entry. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the entry. |
|
||||
| `moveEntryUrl` | The route that moves one entry of the playlist to a new position. The empty `00000000-0000-0000-0000-000000000000` entry segment is replaced by the entry Id; the body carries `targetPosition`. |
|
||||
| `getEnabledLibrariesUrl` | The route that lists the media libraries the current user can browse. |
|
||||
| `getArtistsUrl` | The route that lists the artists of a music library. It takes `libraryId` as a query parameter. |
|
||||
| `getArtistAlbumsUrl` | The route template that lists the releases of an artist. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the artist, and the library Id is passed as a query parameter. |
|
||||
| `getAlbumTracksUrl` | The route template that lists the tracks of an album. The two `00000000-0000-0000-0000-000000000000` segments are replaced by the Ids of the artist and the album, and the library Id is passed as a query parameter. |
|
||||
| `indexUrl` | The route of the playlists page. |
|
||||
| `antiforgeryToken` | The anti-forgery token the page submits with its mutating requests. |
|
||||
| `strings` | The localized strings of the page, keyed by their resource names. |
|
||||
|
||||
The fallback views keep these element hooks, which the application script drives: on the list page, `playlists-container`, `no-playlists` and `playlist-count`; on the item page, `playlist-details-form`, `playlist-title`, `playlist-name-input`, `playlist-description-input`, `save-playlist-button`, `cancel-playlist-button`, `play-playlist-button`, `delete-playlist-button`, `playlist-entries`, `no-tracks`, `load-more-entries-button`, `playlist-library-combobox`, `playlist-artist-combobox`, `playlist-album-combobox`, `playlist-track-combobox`, `add-track-button` and `no-music-libraries`. The four track picker controls are standard application combo boxes, not native `select` elements. A theme that restructures a page must keep the hooks the page script needs for that page.
|
||||
|
||||
The playlist rows use the same play affordance contract as the music pages: an element with `data-audio-player-play` and the `data-track-id`, `data-library-id`, `data-album-id`, `data-artist-id`, `data-title`, `data-album-title`, `data-duration` and `data-cover-art-path` attributes is handed to the global player by event delegation. The page fills `data-track-id` from the entry `mediaItemId`, because a music entry references a track. The Play playlist control fetches every page of the playlist in order, builds an explicit queue from the playable entries and starts it through the player control API, so a theme template must keep the `play-playlist-button` hook for that control.
|
||||
|
||||
The playlist rows are reordered by dragging the handle with the `playlist-entry-drag-handle` class, and the row carries the `is-dragging` class while it is being dragged. The up and down controls remain available for keyboard and touch users, and the page uses the `playlist-entry-move-up`, `playlist-entry-move-down` and `playlist-entry-remove` classes to disable them while an entry mutation is in flight. A theme template that changes the row structure must keep the `playlist-entry` class and the `data-entry-id` attribute on the row, so the page script can find the row and commit its new position. A playable row also renders the heart of the global favorites script (`data-favorite-toggle`, with the kind `MusicTrack`) and the declarative add-to-playlist action (`data-playlist-add` with the track, library, album, artist and title attributes), so the row can be favorited and saved without leaving the playlist. A theme template that replaces the row must keep both controls to keep those actions reachable.
|
||||
|
||||
#### The Shared Add to Playlist Action
|
||||
|
||||
The music library card on the home page, the artist cards, the album cards and the actions menu of an album track row share one add-to-playlist action. The action is a menu item with the `card-action-add-to-playlist` class in both cases. Their click handler calls `window.LuminaPlaylists.showAddScopeDialogAsync(scope)`, where `scope` carries `libraryId`, the optional `artistId`, `albumId` and `trackId`, the `title` shown in the dialog, the page-local `addToPlaylistLabel`, and the optional `returnFocus` element that gets the focus back when the dialog closes. The helper is provided by `wwwroot/js/playlists.js`, which every layout loads. The page passes its own localized label from its page resource as `addToPlaylistLabel`.
|
||||
|
||||
The dialog is rendered by the application, not by the theme: it is a standard application dialog surface with a standard `enlightenment-combobox` of the playlists of the current user. When the scope carries a `trackId`, the dialog appends that single track through the single entry route. Otherwise, the server resolves the ordered track Ids of the scope and appends them to the selected playlist in one batch request. In both cases it shows the result notification and dispatches the `lumina:playlist-updated` event so an open playlist page refreshes. A theme that renders the dialog itself does not get this behavior; it must keep the action wired to the shared helper or reimplement the whole flow.
|
||||
|
||||
A page or a theme template can also render a declarative action that needs no script of its own. The global playlist script binds one click listener on the document, so the action works anywhere in the swapped page content, inside the player bar, and on controls that a page renders later. The action is any focusable element, normally a `button`, that carries these attributes:
|
||||
|
||||
| Attribute | Meaning |
|
||||
| --- | --- |
|
||||
| `data-playlist-add` | Required. Marks the element as an add-to-playlist action. |
|
||||
| `data-playlist-library-id` | Required. The Id of the media library the scope belongs to. An action without it is inert, because a scope is always resolved inside one library. |
|
||||
| `data-playlist-track-id` | Optional. The Id of a single track. When present, the action appends that track through the single entry route and the album and artist attributes are only descriptive. |
|
||||
| `data-playlist-album-id` | Optional. The Id of the album of a scope that is not a single track. |
|
||||
| `data-playlist-artist-id` | Optional. The Id of the artist of a scope that is not a single track. |
|
||||
| `data-playlist-title` | Optional. The title shown in the dialog, so the user sees what the action will add. |
|
||||
|
||||
The default action is prevented and the event stops propagating at the document listener, so link navigation is suppressed. An ancestor handler that already ran is not undone. A disabled action stays inert. Playlist rows and theme markup use these attributes; the player queue action uses its own combobox and button instead.
|
||||
|
||||
The layout provides the shared configuration as `window.playlistConfiguration`:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `getPlaylistsUrl` | The route that returns the playlists of the current user. |
|
||||
| `addPlaylistEntryUrl` | The route that appends one track to a playlist. The empty `00000000-0000-0000-0000-000000000000` segment is replaced by the playlist Id; the body carries `trackId`. |
|
||||
| `addScopeEntriesUrl` | The route that appends a whole library, artist or album scope to a playlist. The empty `00000000-0000-0000-0000-000000000000` segment is replaced by the playlist Id; the body carries `libraryId` and the optional `artistId` and `albumId`, and the server resolves and appends the tracks in catalogue order in the database. |
|
||||
| `createPlaylistUrl` | The route of the dedicated create playlist page, linked from the empty state of the dialog. |
|
||||
| `strings` | The localized dialog labels, including `selectPlaylist`, `noPlaylists`, `createPlaylist`, `tracksAdded`, `tracksAddFailed` and `noTracksToAdd`. |
|
||||
|
||||
The player queue action does not use the declarative attributes. Its label comes from the `PlaylistAddToPlaylist` layout resource, exposed to the player as `strings.addToPlaylist` in the audio player configuration.
|
||||
|
||||
#### The Album Track Actions Menu
|
||||
|
||||
Every rendered track row of the album details page carries the same `card-actions-trigger` button with the vertical dots as the card menus, plus the `track-actions-trigger` class that places it inline in the row. The page script creates the same `card-actions-menu` markup on demand. The menu has three application actions: `card-action-add-to-playlist` opens the shared add-to-playlist dialog for that track, `card-action-add-to-queue` calls `window.LuminaAudioPlayer.instance.appendToQueueAsync(descriptor)`, and `card-action-play-all-from-here` calls `playAsync` with an explicit queue built from the clicked track and every track that follows it in the album order. The player starts the clicked track for the last action, and replaces the queue. A theme that renders the album page must keep the track row markup and the script behavior, or provide its own equivalent.
|
||||
|
||||
#### The Favorites Page
|
||||
|
||||
`favorites/index` receives a model with the following fields:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `getFavoritesUrl` | The route that returns a page of the favorites of the current user. It takes the optional `mediaKind`, `currentPage` and `perPage` query parameters, and returns `data`, `currentPage`, `perPage`, `count` and `numberOfPages`. When both pagination parameters are omitted, every matching favorite is returned in one page. The `perPage` is the page size the theme requests; the server has no separate maximum page size, like every other paginated collection of the API. |
|
||||
| `getFavoriteStatusUrl` | The route that tells which of a list of media items of one kind are favorites of the current user. It takes the `mediaKind` query parameter and one `mediaItemIds` parameter per Id, with at most 100 Ids. |
|
||||
| `addFavoriteUrl` | The route that marks a media item as a favorite. The body carries `mediaKind` and `mediaItemId`. |
|
||||
| `removeFavoriteUrl` | The route template that removes a favorite. Its named `{mediaKind}` and `{mediaItemId}` placeholders are replaced by the media kind name and the Id of the media item. |
|
||||
| `artistUrl` | The route template of an artist page. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the artist. |
|
||||
| `albumUrl` | The route template of an album page. The two `00000000-0000-0000-0000-000000000000` segments are replaced, in order, by the Ids of the artist and the album. |
|
||||
| `trackUrl` | The route template of a track page. The three `00000000-0000-0000-0000-000000000000` segments are replaced, in order, by the Ids of the artist, the album and the track. |
|
||||
| `bookUrl` | The route template of a book page. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the book. |
|
||||
| `antiforgeryToken` | The anti-forgery token the page submits with its mutating requests. |
|
||||
| `strings` | The localized strings of the page, keyed by their resource names. |
|
||||
|
||||
The pages of the media items read the library of the item from the `libraryId` query parameter, so the page script appends `libraryId` to the link of an item from the `libraryId` of the favorite. The link of a track needs the artist and the album of the item, which are the `creatorId` and the `collectionId` of the favorite. An item of the response with `isAvailable` set to `false` has no library and no display fields, so the page shows it as an unavailable item, without a link, and keeps its heart so the favorite can still be removed. The generic display fields of an item are `title`, `collectionTitle`, `creatorName` and `coverPath`; for a track the collection is the album and the creator is the artist, for an album the creator is the artist, for a book the creator is its first author, and for an artist there is neither. The series of a book is not catalogued yet, so a book has no collection.
|
||||
|
||||
The fallback view keeps these element hooks, which the application script drives: `favorites-container`, `no-favorites`, `favorite-count`, `favorites-kind-filter`, `load-more-favorites-button` and `retry-favorites-button`. The bundled themes ship no template for `favorites/index`, so the fallback view is what a healthy site shows, and a theme that wants its own page provides `templates/favorites/index.html` and must keep the hooks the page script needs.
|
||||
|
||||
The fallback view renders one card per favorite, from the most recently favorited, in pages of 50 that `load-more-favorites-button` extends. Each card carries a favorite heart (a `card-favorite-toggle` button, described below), already in the favorited state, and a favorite is removed from the page by unfavoriting its card: the page script does not call the remove route itself, the global favorites script does, and the page listens to the `lumina:favorite-changed` event described below, removes the card of an item that is no longer a favorite, and updates the counter and the empty state without another request. A failed first page or reload clears the rendered cards and shows the localized failure message with `retry-favorites-button`, so the user can load the current filter again instead of being left with a truncated list. A theme template that renders the page itself gets the same behavior by rendering hearts on its cards and handling that event.
|
||||
|
||||
#### The Statistics Page
|
||||
|
||||
`library/statistics/index` receives a model with the following fields:
|
||||
|
||||
The five URLs that return the data of a selected user accept an optional `userId` query parameter. The page script appends it when an administrator selected a user, including `Me`, and omits it for a regular user. The Web proxy calls the `/users/{userId}/...` API route when `userId` is present and the `/users/me/...` route when it is absent.
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `getStatisticsUrl` | The route that returns the statistics of the selected user. It takes the optional `userId`, `libraryId`, `mediaKind`, `fromUtc` and `toUtc` query parameters, and returns the summary of that user. |
|
||||
| `getAllUsersStatisticsUrl` | The route that returns the statistics of every user. It takes the optional `libraryId`, `mediaKind`, `fromUtc` and `toUtc` filters, and returns the combined totals and one summary per user. |
|
||||
| `getRecentlyConsumedUrl` | The route that returns a page of the recently consumed items of the selected user. It takes the optional `userId`, the same filters, and the optional `currentPage` and `perPage` query parameters, and returns `data`, `currentPage`, `perPage`, `count` and `numberOfPages`. |
|
||||
| `getMostConsumedUrl` | The route that returns a page of the most consumed items of the selected user, with the same query parameters and response shape. |
|
||||
| `getTagConsumptionUrl` | The route that returns the tag breakdown of the selected user. It takes the optional `userId`, `libraryId`, `mediaKind`, `fromUtc` and `toUtc` query parameters. |
|
||||
| `getGenreConsumptionUrl` | The route that returns the genre breakdown of the selected user, with the same query parameters as the tag route. |
|
||||
| `getLibrariesUrl` | The route that returns the libraries available for the library filter. |
|
||||
| `getUsersUrl` | The route that returns the users available for the administrator user selector, or an empty string for a regular user. |
|
||||
| `deleteConsumptionItemHistoryUrl` | The route that deletes every consumption record of one media item. It is extended with `mediaKind`, `mediaItemId` and `libraryId`, and with `userId` when a user is named. |
|
||||
| `clearConsumptionHistoryUrl` | The route that deletes the consumption history of the selected user. It is extended with `userId` when the administrator selected a user. |
|
||||
| `clearResumePointsUrl` | The route that deletes the resume points of the selected user. It is extended with `userId` when the administrator selected a user. |
|
||||
| `culture` | The culture of the page, for example `en-US`, used to format dates and percentages in the browser. |
|
||||
| `isAdmin` | Whether the current user is an administrator and can select another user or all users. |
|
||||
| `currentUserId` | The Id of the current user, or `null` when it cannot be determined. |
|
||||
| `strings` | The localized strings of the page, keyed by their resource names. |
|
||||
|
||||
A summary carries `userId` on a per-user result, plus `totalConsumedDurationInSeconds`, `countedSessionCount`, `completedSessionCount`, `stoppedSessionCount`, `completionRate` and `mediaKindSummaries`. The all-users result carries a `total` summary without `userId` and a `users` list of per-user summaries. A media kind summary carries `mediaKind` and the same totals without `userId`.
|
||||
|
||||
A row of the recently consumed or most consumed list carries `mediaKind`, `mediaItemId`, `libraryId`, `isAvailable`, `title`, `collectionTitle`, `creatorName`, `coverPath`, `lastConsumedOnUtc`, `countedSessionCount`, `completedSessionCount` and `consumedDurationInSeconds`. A tag or genre row carries `name`, `consumedItemCount` and `consumedDurationInSeconds`. Names are lowercase and grouped across media kinds. An item that is no longer available keeps its counts and duration but has blank display fields, so the page shows it as unavailable without a link.
|
||||
|
||||
The page script loads the libraries for the filter, and the users only when the current user is an administrator. The user selector offers the current user, every other user, and `All users`. The all-users selection loads the combined totals and the per-user table, and hides the tag breakdown and the history lists, which are only meaningful per user. Any other selection loads the summary, the media kind breakdown, the tag and genre bars, and the two history lists. Applying the filters reloads every section with the selected library, media kind and date range. Clearing the history or the resume points asks for confirmation first, and refreshing after a deletion reloads every section.
|
||||
|
||||
The fallback view keeps these element hooks, which the application script drives: `statistics-user-filter`, `statistics-user-filter-toggle`, `statistics-user-filter-dropdown`, `statistics-library-filter`, `statistics-library-filter-toggle`, `statistics-library-filter-dropdown`, `statistics-kind-filter`, `statistics-kind-filter-toggle`, `statistics-from-date`, `statistics-to-date`, `statistics-apply-filters`, `statistics-reset-filters`, `statistics-loading`, `statistics-load-failed`, `retry-statistics-button`, `statistics-content`, `statistics-total-duration`, `statistics-counted-sessions`, `statistics-completed-sessions`, `statistics-completion-rate`, `statistics-media-kind-breakdown`, `statistics-no-media-kind`, `statistics-users-section`, `statistics-users-table`, `statistics-no-users`, `statistics-terms`, `statistics-genres`, `statistics-tags`, `statistics-no-genres`, `statistics-no-tags`, `statistics-history-section`, `statistics-clear-history`, `statistics-clear-resume-points`, `statistics-recently-consumed`, `statistics-no-recently-consumed`, `statistics-most-consumed`, `statistics-no-most-consumed`, `statistics-all-users-note` and `statistics-empty-state`. A theme template that renders the page itself gets the same behavior by keeping these hooks and rendering the localized strings from the page model.
|
||||
|
||||
#### Favorite Toggles
|
||||
|
||||
A favorite toggle is the heart of a media card, of a track row, or of the condensed audio player bar. It is rendered by a page or by a theme template, and it is driven entirely by the global script `wwwroot/js/favorites.js`, which every layout loads next to `playlists.js`. The script binds one click listener and one mutation observer on the document, so a toggle works anywhere in the swapped page content, including toggles that a page script adds later, and a page needs no script of its own. A theme owns the look of the toggle, and the script never renders markup: it only writes the attributes, the class and the texts described below.
|
||||
|
||||
A toggle is any focusable element, normally a `button`, that carries these attributes:
|
||||
|
||||
| Attribute | Meaning |
|
||||
| --- | --- |
|
||||
| `data-favorite-toggle` | Required. Marks the element as a favorite toggle. |
|
||||
| `data-favorite-media-kind` | Required. The media kind of the item: `MusicArtist`, `MusicAlbum`, `MusicTrack` or `Book`. The name is matched case insensitively. The planned kinds `Video` and `Photo` cannot be favorited yet, so a toggle that carries one stays in the `failed` state. |
|
||||
| `data-favorite-media-item-id` | Required. The Id of the media item. An empty or malformed Id leaves the toggle in the `failed` state. |
|
||||
|
||||
The script reads which items the current user favorited with `getFavoriteStatusUrl` and writes the result on the toggle. It collects the toggles of a tick and sends one status request per kind, deduplicates the Ids, and splits the Ids of a kind into requests of at most 100, so a page that renders many toggles costs few requests. The script writes these on the element:
|
||||
|
||||
| Written on the toggle | Meaning |
|
||||
| --- | --- |
|
||||
| `aria-pressed` | `true` when the item is a favorite, `false` otherwise. It keeps the previous value while a request is in flight. |
|
||||
| `data-favorite-state` | `favorited` or `not-favorited` when the state is known, `loading` while the state is read or a change is in flight, and `failed` when the state could not be read or the attributes are invalid. |
|
||||
| `is-favorite` class | Present exactly when the item is a favorite. |
|
||||
| `aria-busy` | `true` only while the state is loading or a change is in flight. |
|
||||
| `aria-label` | The localized name of the action the next click performs: the `remove` string when the item is a favorite, the `add` string otherwise. |
|
||||
| `title` | The same localized text as the `aria-label`. It is the hover text of a heart, which has no visible text. |
|
||||
| The text of `.favorite-toggle-label` | When the toggle contains an element with the `favorite-toggle-label` class, the same localized text as the `aria-label`. The bundled themes and the application views render no such element. |
|
||||
|
||||
A theme restyles a toggle from the `is-favorite` class or from the `aria-pressed` and `data-favorite-state` attributes. Until the first state arrives the toggle shows `loading`, so a theme should not style a toggle that has no state yet as pressed.
|
||||
|
||||
A click on a toggle adds the favorite when the item is not one, and removes it otherwise, through the add and remove routes of the configuration. A click is ignored while a request for the same item is in flight, whichever toggle of the item it comes from, and a click on a toggle whose state is unknown reads the state again instead of guessing. The script keeps every toggle of the same item on the page in sync. When a change fails, every toggle returns to the state it had, and the global API helper shows the failure as a notification. When a state read fails, the global API helper shows the failure as a notification. The click handler prevents the default action, so a toggle inside a link or a card does not also navigate.
|
||||
|
||||
After every successful change the script dispatches the `lumina:favorite-changed` event on `document`, with `detail` carrying `mediaKind` (the canonical kind name), `mediaItemId` (the lowercase Id) and `isFavorite` (the new state), so a page that lists favorites can react while it stays decoupled from the toggle that caused the change.
|
||||
|
||||
The layout provides the shared configuration as `window.favoritesConfiguration`:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `getFavoriteStatusUrl` | The route that tells which of the checked media items are favorites. |
|
||||
| `addFavoriteUrl` | The route that marks a media item as a favorite. The body carries `mediaKind` and `mediaItemId`. |
|
||||
| `removeFavoriteUrlTemplate` | The route template that removes a favorite. Its named `{mediaKind}` and `{mediaItemId}` placeholders are replaced by the media kind name and the Id of the media item. |
|
||||
| `strings` | The localized labels: `add` and `remove`. |
|
||||
|
||||
The script also exposes `window.LuminaFavorites` for page scripts that need more than the markup contract:
|
||||
|
||||
| Member | Behavior |
|
||||
| --- | --- |
|
||||
| `hydrate(rootElement)` | Reads the state of the toggles inside the element, the whole document by default, and writes it on them. It never rejects. The script already hydrates the toggles of the page and the ones added to it, so this is only needed for toggles in an element that is not attached to the document. |
|
||||
| `isFavorite(mediaKind, mediaItemId)` | Returns a promise of whether the item is a favorite. The answer always comes from the server, and the check is batched with the others of the same tick. It rejects when the kind or the Id is invalid, or when the request failed. |
|
||||
| `setFavoriteAsync(mediaKind, mediaItemId, shouldFavorite)` | Adds or removes the favorite, with the same in-flight rule, synchronization and failure notification from the global API helper as a click, and returns a promise of whether the item now has the requested state. A call for an item that is already being changed returns the running change when it asks for the same state, and `false` otherwise. |
|
||||
|
||||
The hearts are rendered on the cards of the books list, of the artists list and of the albums on the artist page (the kinds `Book`, `MusicArtist` and `MusicAlbum`), on the cards of the favorites page, on the rows of the track table of the album page (the kind `MusicTrack`, after the duration), on the rows of a saved playlist, on the favorite toggle of the condensed audio player bar for the current track, and on every queue item of the player (the kind `MusicTrack`). The detail pages of an artist, an album, a track and a book render no toggle. A theme that replaces a list must render the hearts again to keep favoriting reachable from it, and a theme queue item uses the same `data-favorite-toggle` contract.
|
||||
|
||||
A card heart is a plain `button` with the `card-favorite-toggle` class, with the three data attributes and nothing else, appended to the `media-card` element as a sibling of the `media-panel` link and of the `card-actions-trigger`. The stylesheet draws the heart with `::after`, like the dots of the actions trigger. The heart has the box of the actions trigger, sits immediately on its left, is shown on hover, while the actions menu of the card is open, and while any control of the card has the focus, shows the heart in the blue of the trigger, and shows it in red when the item is a favorite (`aria-pressed="true"` or the `is-favorite` class). A heart in the `loading` state is dimmed, and one in the `failed` state has an error border. A `media-card` that has no `card-actions-trigger`, like the cards of the favorites page, gets the heart in the place of the trigger, always visible so that it stays reachable by keyboard and on touch screens. A track row heart is a `button` with the `card-favorite-toggle track-favorite-toggle` classes inside a `td` with the `track-favorite-cell` class that follows the duration cell, and the `colgroup` of the table gets a `col` with the `track-favorite-column` class after the duration column. It is static, always visible and centered, like the actions trigger of the row. The hover text of every heart is the `title` that the script writes.
|
||||
|
||||
The bundled themes render the hearts on those cards and rows, and carry the card rules in their `assets/site.css`; the rules of the track row and of its columns are in the application stylesheet, `wwwroot/css/site.css`, which every page loads. The application fallback views render the same hearts. A custom theme that replaces one of these templates must render the hearts again to keep favoriting reachable from that page.
|
||||
|
||||
### The Scripts Section
|
||||
|
||||
JavaScript is always allowed in themes: script elements in templates are served and rendered as-is, and script files under `assets/` are served normally. A theme relies on scripts for the client side navigation of the application, because pages are swapped in place by the global AJAX navigator, so themes are expected to ship their own JavaScript. Because JavaScript is enabled, *themes can execute malicious code*, so, be aware about the source of your installed themes! Themes bundled with the application are reviewed and safe.
|
||||
|
||||
@@ -216,6 +216,11 @@ internal sealed class Id3TagDto
|
||||
/// </summary>
|
||||
public string? AudioCodec { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or initializes the container of the audio file of the track, for example MP3, FLAC, OGG, AAC, MP4 or WAV.
|
||||
/// </summary>
|
||||
public string? Container { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or initializes the official website associated with the artist.
|
||||
/// </summary>
|
||||
|
||||
@@ -164,6 +164,7 @@ internal static class Id3TagMapper
|
||||
Channels: data.Channels,
|
||||
BitDepth: data.BitDepth,
|
||||
AudioCodec: NullIfWhiteSpace(data.AudioCodec),
|
||||
Container: NullIfWhiteSpace(data.Container),
|
||||
Bitrate: data.Bitrate,
|
||||
MusicBrainzRecordingId: ParseGuid(data.MusicBrainzRecordingId),
|
||||
MusicBrainzTrackId: ParseGuid(data.MusicBrainzReleaseTrackId),
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.ID3.Core.Tags;
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the canonical name of the container of an audio file from the concrete type the tagging library parsed it as.
|
||||
/// </summary>
|
||||
internal static class AudioContainerResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves the container of the audio file parsed by <paramref name="tagFile"/>.
|
||||
/// </summary>
|
||||
/// <param name="tagFile">The parsed audio file whose container is resolved.</param>
|
||||
/// <returns>The canonical name of the container, for example MP3, FLAC, OGG, AAC, MP4 or WAV, or <see langword="null"/> when the container cannot be recognized.</returns>
|
||||
public static string? Resolve(TagLib.File tagFile)
|
||||
{
|
||||
// The concrete type of the parsed file is the most reliable description of its container, because it is chosen by the parser from the
|
||||
// actual bytes of the file, while the mime type only describes the extension. The scanning pipeline resolves the container the same way,
|
||||
// so that the container captured during a scan and the one captured during metadata enrichment always agree.
|
||||
return tagFile switch
|
||||
{
|
||||
TagLib.Mpeg.File => "MP3",
|
||||
TagLib.Flac.File => "FLAC",
|
||||
TagLib.Mpeg4.File => "MP4",
|
||||
TagLib.Aac.File => "AAC",
|
||||
TagLib.Ogg.File => "OGG",
|
||||
TagLib.Riff.File => "WAV",
|
||||
TagLib.Aiff.File => "AIFF",
|
||||
TagLib.Ape.File => "APE",
|
||||
TagLib.WavPack.File => "WAVPACK",
|
||||
TagLib.Asf.File => "WMA",
|
||||
TagLib.Dsf.File => "DSF",
|
||||
TagLib.Matroska.File => "MATROSKA",
|
||||
TagLib.MusePack.File => "MPC",
|
||||
TagLib.Audible.File => "AA",
|
||||
_ => ResolveFromMimeType(tagFile.MimeType)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the container from the mime type reported by the tagging library, for the containers that have no dedicated parser.
|
||||
/// </summary>
|
||||
/// <param name="mimeType">The mime type reported by the tagging library.</param>
|
||||
/// <returns>The name of the container, or <see langword="null"/> when it cannot be derived.</returns>
|
||||
public static string? ResolveFromMimeType(string? mimeType)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mimeType))
|
||||
return null;
|
||||
|
||||
// The library reports its mime types with the "taglib/" prefix, so only the last segment names the container.
|
||||
string[] segments = mimeType.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
string? container = segments.Length > 0 ? segments[^1] : null;
|
||||
return string.IsNullOrWhiteSpace(container) ? null : container.ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,7 @@ internal sealed class Id3TagReader
|
||||
BitDepth = audioProperties.BitsPerSample > 0 ? audioProperties.BitsPerSample : null,
|
||||
Bitrate = audioProperties.AudioBitrate > 0 ? audioProperties.AudioBitrate : null,
|
||||
AudioCodec = NullIfWhiteSpace(audioProperties.Description),
|
||||
Container = AudioContainerResolver.Resolve(tagFile),
|
||||
Website = NullIfWhiteSpace(GetExtendedField(extendedFields, "WOAR", "website")),
|
||||
MusicBrainzArtistId = NullIfWhiteSpace(tag.MusicBrainzArtistId),
|
||||
MusicBrainzReleaseArtistId = NullIfWhiteSpace(tag.MusicBrainzReleaseArtistId),
|
||||
|
||||
@@ -183,6 +183,7 @@ internal static partial class MusicBrainzMapper
|
||||
Channels: null,
|
||||
BitDepth: null,
|
||||
AudioCodec: null,
|
||||
Container: null,
|
||||
Bitrate: null,
|
||||
MusicBrainzRecordingId: ParseGuid(recording.Id),
|
||||
MusicBrainzTrackId: null,
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface ICommandHandler<in TCommand, TResult> where TCommand : ICommand
|
||||
/// Handles the specified command and returns a result.
|
||||
/// </summary>
|
||||
/// <param name="command">The command to handle.</param>
|
||||
/// <param name="cancellationToken">Token to monitor for cancellation requests.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing the result of the command execution.</returns>
|
||||
Task<TResult> HandleAsync(TCommand command, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public interface IQueryHandler<in TQuery, TResult> where TQuery : IQuery
|
||||
/// Handles the specified query and returns a result.
|
||||
/// </summary>
|
||||
/// <param name="query">The query to handle.</param>
|
||||
/// <param name="cancellationToken">Token to monitor for cancellation requests.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing the result of the query execution.</returns>
|
||||
Task<TResult> HandleAsync(TQuery query, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the generic display data of a favorited media item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For a music artist the title is the artist name and there is no collection or creator. For a music album the title is the album title,
|
||||
/// there is no collection, and the creator is the artist. For a music track the title is the track title, the collection is the album and
|
||||
/// the creator is the artist. For a book the title is the book title, there is no collection yet because the series of a book is not catalogued, and the creator is its
|
||||
/// first author.
|
||||
/// </remarks>
|
||||
/// <param name="LibraryId">The Id of the media library that contains the media item.</param>
|
||||
/// <param name="Title">The title of the media item.</param>
|
||||
/// <param name="CollectionId">The Id of the collection that contains the media item, or an empty Guid when there is none.</param>
|
||||
/// <param name="CollectionTitle">The title of the collection that contains the media item, or an empty string when there is none.</param>
|
||||
/// <param name="CreatorId">The Id of the creator of the media item, or an empty Guid when there is none.</param>
|
||||
/// <param name="CreatorName">The name of the creator of the media item, or an empty string when there is none.</param>
|
||||
/// <param name="CoverPath">The path of the cover art of the media item, if available.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}; Title: {Title}")]
|
||||
public sealed record FavoriteItemDisplayDto(
|
||||
Guid LibraryId,
|
||||
string Title,
|
||||
Guid CollectionId,
|
||||
string CollectionTitle,
|
||||
Guid CreatorId,
|
||||
string CreatorName,
|
||||
string? CoverPath
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a stored favorite together with the display data of the media item it references.
|
||||
/// </summary>
|
||||
/// <param name="Favorite">The stored favorite.</param>
|
||||
/// <param name="Display">The display data of the referenced media item, or <see langword="null"/> when it no longer exists.</param>
|
||||
[DebuggerDisplay("Id: {Favorite.Id}; MediaKind: {Favorite.MediaKind}")]
|
||||
public sealed record FavoriteItemDto(
|
||||
FavoriteEntity Favorite,
|
||||
FavoriteItemDisplayDto? Display
|
||||
);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the consumption statistics of every user, together with their combined totals.
|
||||
/// </summary>
|
||||
/// <param name="Total">The combined consumption statistics of every user.</param>
|
||||
/// <param name="Users">The consumption statistics of each user.</param>
|
||||
[DebuggerDisplay("UserCount: {Users.Count}; CountedSessionCount: {Total.CountedSessionCount}")]
|
||||
public sealed record AllUsersConsumptionStatisticsDto(
|
||||
ConsumptionTotalsDto Total,
|
||||
IReadOnlyList<ConsumptionStatisticsDto> Users
|
||||
);
|
||||
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a media item of the consumption history, together with its aggregated consumption counts and display details.
|
||||
/// </summary>
|
||||
/// <param name="MediaKind">The kind of the consumed media item.</param>
|
||||
/// <param name="MediaItemId">The Id of the consumed media item.</param>
|
||||
/// <param name="LibraryId">The Id of the media library that contains the media item.</param>
|
||||
/// <param name="IsAvailable">Whether the media item still exists and can be accessed by the user. When <see langword="false"/>, the title, collection title, creator name, and cover path are blank, while the identity and aggregation fields remain.</param>
|
||||
/// <param name="Title">The title of the media item, or an empty string when the item is not available.</param>
|
||||
/// <param name="CollectionTitle">The title of the collection that contains the media item, or an empty string when there is none.</param>
|
||||
/// <param name="CreatorName">The name of the creator of the media item, or an empty string when there is none.</param>
|
||||
/// <param name="CoverPath">The path of the cover art of the media item, if available.</param>
|
||||
/// <param name="LastConsumedOnUtc">The date and time when the media item was last consumed.</param>
|
||||
/// <param name="CountedSessionCount">The number of consumption sessions of the media item that count towards statistics.</param>
|
||||
/// <param name="CompletedSessionCount">The number of consumption sessions of the media item that completed.</param>
|
||||
/// <param name="ConsumedDurationMilliseconds">The active duration consumed in the media item, over all of its sessions, in milliseconds.</param>
|
||||
[DebuggerDisplay("MediaKind: {MediaKind}; MediaItemId: {MediaItemId}; CountedSessionCount: {CountedSessionCount}")]
|
||||
public sealed record ConsumedItemDto(
|
||||
MediaKind MediaKind,
|
||||
Guid MediaItemId,
|
||||
Guid LibraryId,
|
||||
bool IsAvailable,
|
||||
string Title,
|
||||
string CollectionTitle,
|
||||
string CreatorName,
|
||||
string? CoverPath,
|
||||
DateTime LastConsumedOnUtc,
|
||||
int CountedSessionCount,
|
||||
int CompletedSessionCount,
|
||||
long ConsumedDurationMilliseconds
|
||||
);
|
||||
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a media consumption session.
|
||||
/// </summary>
|
||||
/// <param name="Id">The Id of the consumption record.</param>
|
||||
/// <param name="LibraryId">The Id of the media library that contains the consumed media item.</param>
|
||||
/// <param name="MediaItemId">The Id of the consumed media item.</param>
|
||||
/// <param name="MediaKind">The kind of media that was consumed.</param>
|
||||
/// <param name="Status">The state of the consumption session.</param>
|
||||
/// <param name="StartedOnUtc">The date and time when the session started.</param>
|
||||
/// <param name="LastActivityOnUtc">The date and time when the session last received activity.</param>
|
||||
/// <param name="EndedOnUtc">The date and time when the session completed or stopped, if it has ended.</param>
|
||||
/// <param name="ConsumedDurationMilliseconds">The active duration consumed by the session, in milliseconds.</param>
|
||||
/// <param name="LastPosition">The last known position for the media item, if any.</param>
|
||||
/// <param name="LastProgressFraction">The latest reported progress fraction of the media item.</param>
|
||||
/// <param name="ConsecutivePagesRead">The number of consecutive pages read in the session.</param>
|
||||
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; Status: {Status}")]
|
||||
public sealed record ConsumptionRecordDto(
|
||||
Guid Id,
|
||||
Guid LibraryId,
|
||||
Guid MediaItemId,
|
||||
MediaKind MediaKind,
|
||||
ConsumptionStatus Status,
|
||||
DateTime StartedOnUtc,
|
||||
DateTime LastActivityOnUtc,
|
||||
DateTime? EndedOnUtc,
|
||||
long ConsumedDurationMilliseconds,
|
||||
MediaPositionDto? LastPosition,
|
||||
double LastProgressFraction,
|
||||
int ConsecutivePagesRead
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the consumption statistics of a user.
|
||||
/// </summary>
|
||||
/// <param name="UserId">The Id of the user the statistics belong to.</param>
|
||||
/// <param name="TotalConsumedDurationMilliseconds">The total duration consumed over every recorded session, in milliseconds.</param>
|
||||
/// <param name="CountedSessionCount">The number of recorded sessions that count towards statistics.</param>
|
||||
/// <param name="CompletedSessionCount">The number of recorded sessions that completed.</param>
|
||||
/// <param name="StoppedSessionCount">The number of recorded sessions that stopped before they completed and count towards statistics.</param>
|
||||
/// <param name="CompletionRate">The fraction of the counted sessions that completed, between 0 and 1, or 0 when there is no counted session.</param>
|
||||
/// <param name="MediaKindSummaries">The consumption statistics broken down by media kind.</param>
|
||||
[DebuggerDisplay("UserId: {UserId}; CountedSessionCount: {CountedSessionCount}")]
|
||||
public sealed record ConsumptionStatisticsDto(
|
||||
Guid UserId,
|
||||
long TotalConsumedDurationMilliseconds,
|
||||
int CountedSessionCount,
|
||||
int CompletedSessionCount,
|
||||
int StoppedSessionCount,
|
||||
double CompletionRate,
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto> MediaKindSummaries
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the combined consumption statistics of every user.
|
||||
/// </summary>
|
||||
/// <param name="TotalConsumedDurationMilliseconds">The total duration consumed over every recorded session of every user, in milliseconds.</param>
|
||||
/// <param name="CountedSessionCount">The number of recorded sessions of every user that count towards statistics.</param>
|
||||
/// <param name="CompletedSessionCount">The number of recorded sessions of every user that completed.</param>
|
||||
/// <param name="StoppedSessionCount">The number of recorded sessions of every user that stopped before they completed and count towards statistics.</param>
|
||||
/// <param name="CompletionRate">The fraction of the counted sessions of every user that completed, between 0 and 1, or 0 when there is no counted session.</param>
|
||||
/// <param name="MediaKindSummaries">The combined consumption statistics broken down by media kind.</param>
|
||||
[DebuggerDisplay("CountedSessionCount: {CountedSessionCount}; CompletedSessionCount: {CompletedSessionCount}")]
|
||||
public sealed record ConsumptionTotalsDto(
|
||||
long TotalConsumedDurationMilliseconds,
|
||||
int CountedSessionCount,
|
||||
int CompletedSessionCount,
|
||||
int StoppedSessionCount,
|
||||
double CompletionRate,
|
||||
IReadOnlyList<MediaKindConsumptionStatisticsDto> MediaKindSummaries
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the consumption statistics of a genre, grouped across media kinds.
|
||||
/// </summary>
|
||||
/// <param name="Name">The lowercase name of the genre.</param>
|
||||
/// <param name="ConsumedItemCount">The number of distinct media items that carry the genre and were consumed.</param>
|
||||
/// <param name="ConsumedDurationMilliseconds">The active duration consumed in the media items that carry the genre, in milliseconds.</param>
|
||||
[DebuggerDisplay("Name: {Name}; ConsumedItemCount: {ConsumedItemCount}")]
|
||||
public sealed record GenreConsumptionDto(
|
||||
string Name,
|
||||
int ConsumedItemCount,
|
||||
long ConsumedDurationMilliseconds
|
||||
);
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the consumption statistics of a user for one kind of media.
|
||||
/// </summary>
|
||||
/// <param name="MediaKind">The kind of media the statistics belong to.</param>
|
||||
/// <param name="TotalConsumedDurationMilliseconds">The total duration consumed over every recorded session of the media kind, in milliseconds.</param>
|
||||
/// <param name="CountedSessionCount">The number of recorded sessions of the media kind that count towards statistics.</param>
|
||||
/// <param name="CompletedSessionCount">The number of recorded sessions of the media kind that completed.</param>
|
||||
/// <param name="StoppedSessionCount">The number of recorded sessions of the media kind that stopped before they completed and count towards statistics.</param>
|
||||
/// <param name="CompletionRate">The fraction of the counted sessions of the media kind that completed, between 0 and 1, or 0 when there is no counted session.</param>
|
||||
[DebuggerDisplay("MediaKind: {MediaKind}; CountedSessionCount: {CountedSessionCount}")]
|
||||
public sealed record MediaKindConsumptionStatisticsDto(
|
||||
MediaKind MediaKind,
|
||||
long TotalConsumedDurationMilliseconds,
|
||||
int CountedSessionCount,
|
||||
int CompletedSessionCount,
|
||||
int StoppedSessionCount,
|
||||
double CompletionRate
|
||||
);
|
||||
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a position reached in a media item during a consumption session.
|
||||
/// </summary>
|
||||
/// <param name="Kind">The kind of representation used by the position.</param>
|
||||
/// <param name="TimeOffsetMilliseconds">The position within the media item, in milliseconds, when the position is a time offset.</param>
|
||||
/// <param name="Location">The opaque locator within the media item, when the position is not a time offset.</param>
|
||||
[DebuggerDisplay("Kind: {Kind}; TimeOffsetMilliseconds: {TimeOffsetMilliseconds}")]
|
||||
public sealed record MediaPositionDto(
|
||||
MediaPositionKind Kind,
|
||||
long? TimeOffsetMilliseconds,
|
||||
string? Location
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the point at which a user can resume consuming a media item.
|
||||
/// </summary>
|
||||
/// <param name="Id">The Id of the resume point.</param>
|
||||
/// <param name="LibraryId">The Id of the media library that contains the media item.</param>
|
||||
/// <param name="MediaItemId">The Id of the media item to resume.</param>
|
||||
/// <param name="MediaKind">The kind of media that is resumed.</param>
|
||||
/// <param name="LastPosition">The position at which the media item can be resumed.</param>
|
||||
/// <param name="LastProgressFraction">The progress fraction at which the media item can be resumed.</param>
|
||||
/// <param name="LastConsumedOnUtc">The date and time when the media item was last consumed.</param>
|
||||
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
|
||||
public sealed record ResumePointDto(
|
||||
Guid Id,
|
||||
Guid LibraryId,
|
||||
Guid MediaItemId,
|
||||
MediaKind MediaKind,
|
||||
MediaPositionDto LastPosition,
|
||||
double LastProgressFraction,
|
||||
DateTime LastConsumedOnUtc
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the consumption statistics of a tag, grouped across media kinds.
|
||||
/// </summary>
|
||||
/// <param name="Name">The lowercase name of the tag.</param>
|
||||
/// <param name="ConsumedItemCount">The number of distinct media items that carry the tag and were consumed.</param>
|
||||
/// <param name="ConsumedDurationMilliseconds">The active duration consumed in the media items that carry the tag, in milliseconds.</param>
|
||||
[DebuggerDisplay("Name: {Name}; ConsumedItemCount: {ConsumedItemCount}")]
|
||||
public sealed record TagConsumptionDto(
|
||||
string Name,
|
||||
int ConsumedItemCount,
|
||||
long ConsumedDurationMilliseconds
|
||||
);
|
||||
+14
-32
@@ -9,35 +9,17 @@ namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.A
|
||||
/// <summary>
|
||||
/// Lightweight read model of an album, containing only the fields needed to display the album in a card-based grid or a list.
|
||||
/// </summary>
|
||||
public sealed record AlbumLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the album.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the album.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of tracks of the release.
|
||||
/// </summary>
|
||||
public int TotalTracks { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the image representing the album, if available.
|
||||
/// </summary>
|
||||
public string? CoverPath { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the release year of the album (the re-release year, if available, or the original release year), if known.
|
||||
/// </summary>
|
||||
public int? ReleaseYear { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set of types of the release.
|
||||
/// </summary>
|
||||
public List<MusicReleaseType>? ReleaseTypes { get; init; }
|
||||
}
|
||||
/// <param name="Id">The Id of the album.</param>
|
||||
/// <param name="Title">The title of the album.</param>
|
||||
/// <param name="TotalTracks">The number of tracks of the release.</param>
|
||||
/// <param name="CoverPath">The path of the image representing the album, if available.</param>
|
||||
/// <param name="ReleaseYear">The release year of the album (the re-release year, if available, or the original release year), if known.</param>
|
||||
/// <param name="ReleaseTypes">The set of types of the release.</param>
|
||||
public sealed record AlbumLiteRow(
|
||||
Guid Id,
|
||||
string Title,
|
||||
int TotalTracks,
|
||||
string? CoverPath,
|
||||
int? ReleaseYear,
|
||||
List<MusicReleaseType>? ReleaseTypes
|
||||
);
|
||||
+8
-17
@@ -7,20 +7,11 @@ namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.A
|
||||
/// <summary>
|
||||
/// Lightweight read model of an artist, containing only the fields needed to display the artist in a card-based grid or a list.
|
||||
/// </summary>
|
||||
public sealed record ArtistLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the artist.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the artist.
|
||||
/// </summary>
|
||||
public required string Name { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the image representing the artist, if available.
|
||||
/// </summary>
|
||||
public string? CoverPath { get; init; }
|
||||
}
|
||||
/// <param name="Id">The Id of the artist.</param>
|
||||
/// <param name="Name">The name of the artist.</param>
|
||||
/// <param name="CoverPath">The path of the image representing the artist, if available.</param>
|
||||
public sealed record ArtistLiteRow(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string? CoverPath
|
||||
);
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the normalized audio of a track, produced and cached as a sequence of fixed duration segments.
|
||||
/// </summary>
|
||||
/// <param name="TrackId">The Id of the track whose audio the cached entry holds, so the caller can verify that the entry is the one it authorized.</param>
|
||||
/// <param name="CacheId">The opaque identifier of the cached entry that holds the normalized audio.</param>
|
||||
/// <param name="Mode">The way the audio is delivered, which is a remux or a transcode.</param>
|
||||
/// <param name="Container">The container of the delivered audio.</param>
|
||||
/// <param name="Codec">The codec of the delivered audio.</param>
|
||||
/// <param name="SegmentDurationSeconds">The duration of each segment of the delivered audio, in seconds.</param>
|
||||
/// <param name="DurationInSeconds">
|
||||
/// The duration of the produced and cached audio, in seconds, rounded up to the next second. It is the produced end rather than the probed duration, so
|
||||
/// it always covers every produced segment.
|
||||
/// </param>
|
||||
/// <param name="Segments">The segments that make up the delivered audio, in playback order.</param>
|
||||
[DebuggerDisplay("TrackId: {TrackId} CacheId: {CacheId} Container: {Container} Codec: {Codec}")]
|
||||
public sealed record NormalizedTrackDto(
|
||||
Guid TrackId,
|
||||
string CacheId,
|
||||
PlaybackDeliveryMode Mode,
|
||||
string Container,
|
||||
string Codec,
|
||||
int SegmentDurationSeconds,
|
||||
int DurationInSeconds,
|
||||
IReadOnlyList<NormalizedTrackSegmentDto> Segments
|
||||
);
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the request to produce the normalized audio of a track, as the delivery decision of a playback manifest describes it.
|
||||
/// </summary>
|
||||
/// <param name="TrackId">The Id of the track whose audio is normalized. It binds the produced cache entry to the track the caller authorized.</param>
|
||||
/// <param name="UserId">The Id of the user whose request starts the production. It is used for the per-user admission limit, and never for the cache identity.</param>
|
||||
/// <param name="SourcePath">The file system path of the stored audio file of the track.</param>
|
||||
/// <param name="AllowedRoots">
|
||||
/// The content locations the source path is allowed to be inside. The service validates the path against them and re-checks it after opening, so a
|
||||
/// caller that forgets to enforce containment cannot hand an arbitrary path to the transcoder.
|
||||
/// </param>
|
||||
/// <param name="SourceContainer">The container of the stored audio file, as captured by the probe, used to pin the ffmpeg demuxer.</param>
|
||||
/// <param name="Mode">The way the audio is delivered, which is a remux or a transcode.</param>
|
||||
/// <param name="Container">The container of the delivered audio, as chosen by the delivery decision.</param>
|
||||
/// <param name="Codec">The codec of the delivered audio, as chosen by the delivery decision.</param>
|
||||
/// <param name="SegmentDurationSeconds">The duration of each segment of the delivered audio, in seconds.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the audio of the track, in seconds.</param>
|
||||
/// <param name="Bitrate">The stored audio bitrate of the track, in kbps, used to estimate a remux of a lossy codec.</param>
|
||||
/// <param name="SampleRate">The sample rate of the stored audio of the track, in Hz, used to estimate the size of a lossless delivery.</param>
|
||||
/// <param name="Channels">The number of audio channels of the track, used to estimate the size of a lossless delivery.</param>
|
||||
/// <param name="BitDepth">The bit depth of the stored audio of the track, if applicable, used to estimate the size of a lossless delivery.</param>
|
||||
/// <param name="Quality">The quality cap applied to the delivered audio when it has to be re-encoded.</param>
|
||||
/// <param name="SourceLength">The length the source file had when the delivery was declared, in bytes. The production is rejected when the file no longer matches.</param>
|
||||
/// <param name="SourceLastModifiedUtc">The last modification time the source file had when the delivery was declared. The production is rejected when the file no longer matches.</param>
|
||||
[DebuggerDisplay("TrackId: {TrackId} Mode: {Mode} Container: {Container} Codec: {Codec}")]
|
||||
public sealed record NormalizedTrackRequestDto(
|
||||
Guid TrackId,
|
||||
Guid UserId,
|
||||
string SourcePath,
|
||||
IReadOnlyList<string> AllowedRoots,
|
||||
string? SourceContainer,
|
||||
PlaybackDeliveryMode Mode,
|
||||
string Container,
|
||||
string Codec,
|
||||
int SegmentDurationSeconds,
|
||||
int DurationInSeconds,
|
||||
int? Bitrate,
|
||||
int SampleRate,
|
||||
int Channels,
|
||||
int? BitDepth,
|
||||
PlaybackStreamingQuality Quality,
|
||||
long SourceLength,
|
||||
DateTime SourceLastModifiedUtc
|
||||
);
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a single produced segment of the normalized audio of a track, ready to be written to the response.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The segment owns a live stream over a leased cache entry, so it is an internal delivery object of the API rather than a serializable
|
||||
/// contract. The caller must dispose the stream once the response is written, which releases the cache reader lease.
|
||||
/// </remarks>
|
||||
/// <param name="Content">The read stream over the segment, which the caller owns and must release once the response is written.</param>
|
||||
/// <param name="Length">The length of the segment, in bytes, taken from the index of the normalized audio.</param>
|
||||
/// <param name="StartSeconds">The exact start of the segment on the track timeline, in seconds, taken from the index of the normalized audio.</param>
|
||||
/// <param name="Container">The container of the delivered audio, used to resolve the media type of the segment.</param>
|
||||
/// <param name="SegmentCount">The number of segments the production holds, so the caller can tell the end of the audio from a missing segment.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the produced normalized audio, in seconds, which can differ from the probed duration.</param>
|
||||
[DebuggerDisplay("Length: {Length} StartSeconds: {StartSeconds} Container: {Container} SegmentCount: {SegmentCount}")]
|
||||
public sealed record NormalizedTrackSegmentDataDto(
|
||||
Stream Content,
|
||||
long Length,
|
||||
decimal StartSeconds,
|
||||
string Container,
|
||||
int SegmentCount,
|
||||
int DurationInSeconds
|
||||
);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a single fixed duration segment of the normalized audio of a track.
|
||||
/// </summary>
|
||||
/// <param name="Index">The zero based position of the segment in the delivered audio.</param>
|
||||
/// <param name="StartSeconds">The time, in seconds from the start of the track, at which the segment starts.</param>
|
||||
/// <param name="DurationSeconds">The duration of the segment, in seconds.</param>
|
||||
/// <param name="Length">The length of the segment, in bytes.</param>
|
||||
[DebuggerDisplay("Index: {Index} StartSeconds: {StartSeconds} DurationSeconds: {DurationSeconds}")]
|
||||
public sealed record NormalizedTrackSegmentDto(
|
||||
int Index,
|
||||
decimal StartSeconds,
|
||||
decimal DurationSeconds,
|
||||
long Length
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a single container and codec combination that a player advertises it can demux and decode directly.
|
||||
/// </summary>
|
||||
/// <param name="Container">The container the player can demux, for example MP3, FLAC, OGG, WAV or MP4.</param>
|
||||
/// <param name="Codec">The codec the player can decode, for example MP3, FLAC, Opus, Vorbis, PCM or AAC.</param>
|
||||
[DebuggerDisplay("Container: {Container} Codec: {Codec}")]
|
||||
public sealed record PlaybackCapabilityDto(
|
||||
string Container,
|
||||
string Codec
|
||||
);
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the decision of how the audio of a track is delivered to a player: as the original file, as the same codec repackaged, or re-encoded.
|
||||
/// </summary>
|
||||
/// <param name="Mode">The way the audio is delivered.</param>
|
||||
/// <param name="Container">The container of the delivered audio, which is the stored container of the track for a direct play.</param>
|
||||
/// <param name="Codec">The codec of the delivered audio, which is the stored codec of the track for a direct play.</param>
|
||||
/// <param name="Shape">The shape the delivered audio is addressed and seeked by.</param>
|
||||
/// <param name="SegmentDurationSeconds">The duration of each segment of the delivered audio, in seconds, or zero when the shape is not time addressed.</param>
|
||||
[DebuggerDisplay("Mode: {Mode} Container: {Container} Codec: {Codec} Shape: {Shape}")]
|
||||
public sealed record PlaybackDeliveryDecisionDto(
|
||||
PlaybackDeliveryMode Mode,
|
||||
string Container,
|
||||
string Codec,
|
||||
PlaybackDeliveryShape Shape,
|
||||
int SegmentDurationSeconds
|
||||
);
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the delivery a playback manifest issued to a user. It composes the exact normalization request the delivery declares,
|
||||
/// so a new production input is added in one place and can never drift between the cache identity and the handle.
|
||||
/// </summary>
|
||||
/// <param name="Request">The complete normalization request the delivery declares, including its user, track, decision, quality and source identity.</param>
|
||||
/// <param name="Shape">The shape the delivered audio is addressed by, which must be time addressed segments for a segment route.</param>
|
||||
/// <param name="LibraryId">The Id of the library the track belongs to, so the segment route can scope the delivery without querying it again.</param>
|
||||
/// <param name="AlbumId">The Id of the album the track belongs to, so the segment route can scope the delivery without querying it again.</param>
|
||||
/// <param name="ArtistId">The Id of the artist that owns the album, so the segment route can scope the delivery without querying it again.</param>
|
||||
[DebuggerDisplay("TrackId: {Request.TrackId} Mode: {Request.Mode} Container: {Request.Container} Codec: {Request.Codec}")]
|
||||
public sealed record PlaybackDeliveryHandleDto(
|
||||
NormalizedTrackRequestDto Request,
|
||||
PlaybackDeliveryShape Shape,
|
||||
Guid LibraryId,
|
||||
Guid AlbumId,
|
||||
Guid ArtistId
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the stored format of a track's audio, that a playback delivery decision is made on.
|
||||
/// </summary>
|
||||
/// <param name="Container">The container of the audio file of the track, for example MP3, FLAC, OGG, MP4 or WAV.</param>
|
||||
/// <param name="Codec">The codec of the audio of the track, as reported by the probe, for example AAC, FLAC, Opus or PCM.</param>
|
||||
[DebuggerDisplay("Container: {Container} Codec: {Codec}")]
|
||||
public sealed record PlaybackSourceFormatDto(
|
||||
string? Container,
|
||||
string? Codec
|
||||
);
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Read model of a track returned by a randomized shuffle query, carrying everything the client needs to queue and play it.
|
||||
/// </summary>
|
||||
/// <param name="TrackId">The Id of the track.</param>
|
||||
/// <param name="Title">The title of the track.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the track in seconds.</param>
|
||||
/// <param name="AlbumId">The Id of the album the track belongs to.</param>
|
||||
/// <param name="AlbumTitle">The title of the album the track belongs to.</param>
|
||||
/// <param name="ArtistId">The Id of the artist the album belongs to.</param>
|
||||
/// <param name="CoverPath">The path of the cover of the album, if available.</param>
|
||||
public sealed record ShuffleTrackRowDto(
|
||||
Guid TrackId,
|
||||
string Title,
|
||||
int DurationInSeconds,
|
||||
Guid AlbumId,
|
||||
string AlbumTitle,
|
||||
Guid ArtistId,
|
||||
string? CoverPath
|
||||
);
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the access information of a set of existing tracks.
|
||||
/// </summary>
|
||||
/// <param name="TrackCount">The number of distinct requested tracks that exist.</param>
|
||||
/// <param name="LibraryIds">The distinct Ids of the media libraries that contain those tracks.</param>
|
||||
[DebuggerDisplay("TrackCount: {TrackCount}; Libraries: {LibraryIds.Count}")]
|
||||
public sealed record TrackAccessSummaryDto(
|
||||
int TrackCount,
|
||||
IReadOnlyList<Guid> LibraryIds
|
||||
);
|
||||
+12
-27
@@ -7,30 +7,15 @@ namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.T
|
||||
/// <summary>
|
||||
/// Lightweight read model of a track, containing only the fields needed to display the track in a list.
|
||||
/// </summary>
|
||||
public sealed record TrackLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the track.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the track.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the track on its disc.
|
||||
/// </summary>
|
||||
public int TrackNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the disc the track belongs to, if applicable.
|
||||
/// </summary>
|
||||
public int? DiscNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the duration of the track in seconds.
|
||||
/// </summary>
|
||||
public int DurationInSeconds { get; init; }
|
||||
}
|
||||
/// <param name="Id">The Id of the track.</param>
|
||||
/// <param name="Title">The title of the track.</param>
|
||||
/// <param name="TrackNumber">The number of the track on its disc.</param>
|
||||
/// <param name="DiscNumber">The number of the disc the track belongs to, if applicable.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the track in seconds.</param>
|
||||
public sealed record TrackLiteRow(
|
||||
Guid Id,
|
||||
string Title,
|
||||
int TrackNumber,
|
||||
int? DiscNumber,
|
||||
int DurationInSeconds
|
||||
);
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the stored probe result of a track, containing only the fields a playback manifest is built from.
|
||||
/// </summary>
|
||||
/// <param name="Path">The file system path of the stored audio file of the track, used to bind a normalized delivery to the file version it was declared for.</param>
|
||||
/// <param name="Container">The container of the audio file of the track, for example MP3, FLAC, OGG, AAC, MP4 or WAV, if applicable.</param>
|
||||
/// <param name="AudioCodec">The audio codec used by the audio file of the track, if applicable.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the audio of the track in seconds.</param>
|
||||
/// <param name="SampleRate">The sample rate of the audio of the track in Hz.</param>
|
||||
/// <param name="Channels">The number of audio channels of the track.</param>
|
||||
/// <param name="BitDepth">The bit depth of the audio of the track, if applicable.</param>
|
||||
/// <param name="Bitrate">The bitrate of the audio of the track, in kbps, if applicable.</param>
|
||||
/// <param name="ReplayGainTrackGain">The ReplayGain track gain of the track, in decibels, if applicable.</param>
|
||||
/// <param name="ReplayGainTrackPeak">The ReplayGain track peak of the track, if applicable.</param>
|
||||
/// <param name="ReplayGainAlbumGain">The ReplayGain album gain of the track, in decibels, if applicable.</param>
|
||||
/// <param name="ReplayGainAlbumPeak">The ReplayGain album peak of the track, if applicable.</param>
|
||||
[DebuggerDisplay("Container: {Container} Codec: {AudioCodec}")]
|
||||
public sealed record TrackPlaybackManifestDto(
|
||||
string Path,
|
||||
string? Container,
|
||||
string? AudioCodec,
|
||||
int DurationInSeconds,
|
||||
int SampleRate,
|
||||
int Channels,
|
||||
int? BitDepth,
|
||||
int? Bitrate,
|
||||
decimal? ReplayGainTrackGain,
|
||||
decimal? ReplayGainTrackPeak,
|
||||
decimal? ReplayGainAlbumGain,
|
||||
decimal? ReplayGainAlbumPeak
|
||||
);
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a track, containing the data needed to stream, or to describe the streaming of, its audio file.
|
||||
/// </summary>
|
||||
/// <param name="Path">The file system path of the track.</param>
|
||||
/// <param name="LibraryId">The Id of the media library the track belongs to.</param>
|
||||
/// <param name="AlbumId">The Id of the album the track belongs to.</param>
|
||||
/// <param name="ArtistId">The Id of the artist that owns the album the track belongs to.</param>
|
||||
/// <param name="Container">The container of the audio file of the track, for example MP3, FLAC, OGG, AAC, MP4 or WAV, if applicable.</param>
|
||||
/// <param name="AudioCodec">The audio codec used by the audio file of the track, if applicable.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the audio of the track in seconds.</param>
|
||||
/// <param name="SampleRate">The sample rate of the audio of the track in Hz.</param>
|
||||
/// <param name="Channels">The number of audio channels of the track.</param>
|
||||
/// <param name="BitDepth">The bit depth of the audio of the track, if applicable.</param>
|
||||
/// <param name="Bitrate">The bitrate of the audio of the track, in kbps, if applicable.</param>
|
||||
public sealed record TrackStreamDto(
|
||||
string Path,
|
||||
Guid LibraryId,
|
||||
Guid AlbumId,
|
||||
Guid ArtistId,
|
||||
string? Container,
|
||||
string? AudioCodec,
|
||||
int DurationInSeconds,
|
||||
int SampleRate,
|
||||
int Channels,
|
||||
int? BitDepth,
|
||||
int? Bitrate
|
||||
);
|
||||
+10
-22
@@ -7,25 +7,13 @@ namespace Lumina.Application.Common.DTO.MediaLibrary.WrittenContentLibrary.BookL
|
||||
/// <summary>
|
||||
/// Lightweight read model of a book, containing only the fields needed to display the book in a card-based grid or a list.
|
||||
/// </summary>
|
||||
public sealed record BookLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the book.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the book.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the release year of the book (re-release year, if available, or original release year), if known.
|
||||
/// </summary>
|
||||
public int? ReleaseYear { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the image representing the cover of the book, if available.
|
||||
/// </summary>
|
||||
public string? CoverPath { get; init; }
|
||||
}
|
||||
/// <param name="Id">The Id of the book.</param>
|
||||
/// <param name="Title">The title of the book.</param>
|
||||
/// <param name="ReleaseYear">The release year of the book (re-release year, if available, or original release year), if known.</param>
|
||||
/// <param name="CoverPath">The path of the image representing the cover of the book, if available.</param>
|
||||
public sealed record BookLiteRow(
|
||||
Guid Id,
|
||||
string Title,
|
||||
int? ReleaseYear,
|
||||
string? CoverPath
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the result of appending entries to a playlist in one bulk operation.
|
||||
/// </summary>
|
||||
/// <param name="FirstPosition">The sparse order key of the first appended entry.</param>
|
||||
/// <param name="AddedCount">The number of entries appended.</param>
|
||||
[DebuggerDisplay("FirstPosition: {FirstPosition}; AddedCount: {AddedCount}")]
|
||||
public sealed record PlaylistBulkAddResultDto(
|
||||
long FirstPosition,
|
||||
int AddedCount
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a stored playlist together with a page of its entries and their display data.
|
||||
/// </summary>
|
||||
/// <param name="Playlist">The stored playlist.</param>
|
||||
/// <param name="Entries">The requested page of entries.</param>
|
||||
[DebuggerDisplay("PlaylistId: {Playlist.Id}; Name: {Playlist.Name}; Entries: {Entries.Count}")]
|
||||
public sealed record PlaylistDetailsDto(
|
||||
PlaylistEntity Playlist,
|
||||
PaginatedResultDto<PlaylistEntryDto> Entries
|
||||
);
|
||||
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the display data of the media item referenced by a playlist entry, together with its collection and creator.
|
||||
/// </summary>
|
||||
/// <param name="TrackId">The Id of the track.</param>
|
||||
/// <param name="TrackTitle">The title of the track.</param>
|
||||
/// <param name="DurationInSeconds">The duration of the track in seconds.</param>
|
||||
/// <param name="LibraryId">The Id of the media library that contains the track.</param>
|
||||
/// <param name="AlbumId">The Id of the album that contains the track.</param>
|
||||
/// <param name="AlbumTitle">The title of the album that contains the track.</param>
|
||||
/// <param name="ArtistId">The Id of the artist that produced the track.</param>
|
||||
/// <param name="ArtistName">The name of the artist that produced the track.</param>
|
||||
/// <param name="CoverPath">The path of the cover art of the album, if available.</param>
|
||||
[DebuggerDisplay("TrackId: {TrackId}; TrackTitle: {TrackTitle}")]
|
||||
public sealed record PlaylistEntryDisplayDto(
|
||||
Guid TrackId,
|
||||
string TrackTitle,
|
||||
int DurationInSeconds,
|
||||
Guid LibraryId,
|
||||
Guid AlbumId,
|
||||
string AlbumTitle,
|
||||
Guid ArtistId,
|
||||
string ArtistName,
|
||||
string? CoverPath
|
||||
);
|
||||
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a stored playlist entry together with the display data of the media item it references and its dense display position.
|
||||
/// </summary>
|
||||
/// <param name="Entry">The stored entry.</param>
|
||||
/// <param name="Display">The display data of the referenced media item, or <see langword="null"/> when it no longer exists.</param>
|
||||
/// <param name="DisplayPosition">The dense zero based position shown to the client.</param>
|
||||
[DebuggerDisplay("EntryId: {Entry.Id}; MediaItemId: {Entry.MediaItemId}; Position: {DisplayPosition}")]
|
||||
public sealed record PlaylistEntryDto(
|
||||
PlaylistEntryEntity Entry,
|
||||
PlaylistEntryDisplayDto? Display,
|
||||
int DisplayPosition
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a playlist in a list, without its entries.
|
||||
/// </summary>
|
||||
/// <param name="Id">The Id of the playlist.</param>
|
||||
/// <param name="Name">The name of the playlist.</param>
|
||||
/// <param name="Description">The description of the playlist, if applicable.</param>
|
||||
/// <param name="Type">The kind of media the playlist holds.</param>
|
||||
/// <param name="EntryCount">The number of entries of the playlist.</param>
|
||||
/// <param name="CreatedOnUtc">The date and time when the playlist was created.</param>
|
||||
/// <param name="UpdatedOnUtc">The date and time when the playlist was last updated, if applicable.</param>
|
||||
[DebuggerDisplay("Id: {Id}; Name: {Name}; EntryCount: {EntryCount}")]
|
||||
public sealed record PlaylistSummaryDto(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string? Description,
|
||||
PlaylistType Type,
|
||||
int EntryCount,
|
||||
DateTime CreatedOnUtc,
|
||||
DateTime? UpdatedOnUtc
|
||||
);
|
||||
@@ -1,12 +1,12 @@
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for a shared reference entity, whose identity is its name and whose rows are shared across the whole storage medium instead of being owned by a single parent.
|
||||
/// Interface for a shared reference entity, whose identity is its normalized name and whose rows are shared across the whole storage medium instead of being owned by a single parent.
|
||||
/// </summary>
|
||||
public interface ISharedReferenceEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name that identifies the shared reference.
|
||||
/// Gets the name that identifies the shared reference, stored in lowercase and culture-invariant form.
|
||||
/// </summary>
|
||||
string? Name { get; }
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a favorite - the marker of a user on a media item of any media kind.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The favorite references the media item by its kind and its Id, without a foreign key, so the same table serves every media context and a
|
||||
/// favorite survives the deletion of the item it references, so its owner can still see and remove it.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
|
||||
public class FavoriteEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the favorite.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that owns the favorite.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of the favorited media item.
|
||||
/// </summary>
|
||||
public required FavoriteMediaKind MediaKind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the favorited media item.
|
||||
/// </summary>
|
||||
public required Guid MediaItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a media consumption session.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; Status: {Status}")]
|
||||
public class MediaConsumptionRecordEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the consumption record.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that started the consumption session.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library that contains the consumed media item.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of media that was consumed.
|
||||
/// </summary>
|
||||
public required MediaKind MediaKind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the consumed media item.
|
||||
/// </summary>
|
||||
public required Guid MediaItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the state of the consumption session.
|
||||
/// </summary>
|
||||
public ConsumptionStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the consumption session started.
|
||||
/// </summary>
|
||||
public required DateTime StartedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the consumption session last received activity.
|
||||
/// </summary>
|
||||
public DateTime LastActivityOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the consumption session completed or stopped, if it has ended.
|
||||
/// </summary>
|
||||
public DateTime? EndedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the active duration consumed by the session, in milliseconds. It is stored as a whole number of milliseconds so that the
|
||||
/// stored value is independent of the persistence medium's support for time values.
|
||||
/// </summary>
|
||||
public long ConsumedDurationMilliseconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of representation used by the last known position, if the session has a known position.
|
||||
/// </summary>
|
||||
public MediaPositionKind? LastPositionKind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last known position within the media item, in milliseconds, when the position is a time offset.
|
||||
/// </summary>
|
||||
public long? LastPositionTimeOffsetMilliseconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last known opaque locator within the media item, when the position is not a time offset.
|
||||
/// </summary>
|
||||
public string? LastPositionLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the latest reported progress fraction of the media item.
|
||||
/// </summary>
|
||||
public double LastProgressFraction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of consecutive pages read in the consumption session.
|
||||
/// </summary>
|
||||
public int ConsecutivePagesRead { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version of the stored row. It is used as an optimistic concurrency token, so that a report that read the record before
|
||||
/// another report changed it can never overwrite the newer state.
|
||||
/// </summary>
|
||||
public long Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaConsumption;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for the point at which a user can resume consuming a media item.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
|
||||
public class MediaResumePointEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the resume point.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that owns the resume point.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library that contains the media item.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of media that is resumed.
|
||||
/// </summary>
|
||||
public required MediaKind MediaKind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media item to resume.
|
||||
/// </summary>
|
||||
public required Guid MediaItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of representation used by the position at which the media item can be resumed.
|
||||
/// </summary>
|
||||
public required MediaPositionKind LastPositionKind { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position within the media item, in milliseconds, when the position is a time offset.
|
||||
/// </summary>
|
||||
public long? LastPositionTimeOffsetMilliseconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the opaque locator within the media item, when the position is not a time offset.
|
||||
/// </summary>
|
||||
public string? LastPositionLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the progress fraction at which the media item can be resumed.
|
||||
/// </summary>
|
||||
public double LastProgressFraction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the media item was last consumed.
|
||||
/// </summary>
|
||||
public DateTime LastConsumedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version of the stored row. It is used as an optimistic concurrency token, so that a report that read the resume point before
|
||||
/// another report changed it can never overwrite the newer state.
|
||||
/// </summary>
|
||||
public long Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+5
@@ -94,6 +94,11 @@ public class MusicLibraryScanItemMetadataEntity : IStorageEntity
|
||||
/// </summary>
|
||||
public string? AudioCodec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the container of the audio file, for example MP3, FLAC, OGG, AAC, MP4 or WAV, if applicable.
|
||||
/// </summary>
|
||||
public string? Container { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bitrate of the audio in kbps, if applicable.
|
||||
/// </summary>
|
||||
|
||||
+5
@@ -141,6 +141,11 @@ public class TrackEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public string? AudioCodec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the container of the audio file, for example MP3, FLAC, OGG, AAC, MP4 or WAV, if applicable.
|
||||
/// </summary>
|
||||
public string? Container { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bitrate of the audio in kbps, if applicable.
|
||||
/// </summary>
|
||||
|
||||
+10
@@ -80,6 +80,16 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public bool ShouldSkipUnchangedDirectoriesDuringScan { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the consumption progress of the media library items is tracked.
|
||||
/// </summary>
|
||||
public bool ShouldTrackConsumptionProgress { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled.
|
||||
/// </summary>
|
||||
public int? CompletionThresholdPercentage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fingerprint of the metadata provider configuration of the media library, used to detect
|
||||
/// whether the configuration changed since the last scan, and thus whether the books need re-enrichment.
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a playlist.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Id: {Id}; Name: {Name}; Type: {Type}")]
|
||||
public class PlaylistEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the playlist.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that owns the playlist.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the playlist.
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description of the playlist, if applicable.
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of media the playlist holds.
|
||||
/// </summary>
|
||||
public required PlaylistType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ordered entries of the playlist.
|
||||
/// </summary>
|
||||
public List<PlaylistEntryEntity> Entries { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of entries the playlist holds.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The count is maintained by the set-based entry operations in the same statement that appends or removes entries and updates the
|
||||
/// playlist, so reading a window of a very large playlist never has to count its entries.
|
||||
/// </remarks>
|
||||
public int EntryCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the concurrency token of the playlist.
|
||||
/// </summary>
|
||||
public long Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for an ordered entry of a playlist.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The entry references a media item by its Id and by the kind of media item, without a foreign key, so a playlist survives the deletion
|
||||
/// of the item it references and the entry can be shown to its owner so that it can be removed.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("Id: {Id}; MediaItemId: {MediaItemId}; MediaItemType: {MediaItemType}; Position: {Position}")]
|
||||
public class PlaylistEntryEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the entry.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the playlist the entry belongs to.
|
||||
/// </summary>
|
||||
public required Guid PlaylistId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media item referenced by the entry.
|
||||
/// </summary>
|
||||
public required Guid MediaItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind of media item referenced by the entry.
|
||||
/// </summary>
|
||||
public PlaylistMediaItemType MediaItemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sparse order key of the entry in the ordered entries of the playlist.
|
||||
/// </summary>
|
||||
public long Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entry was added.
|
||||
/// </summary>
|
||||
public DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entry.
|
||||
/// </summary>
|
||||
public Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entry was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entry.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+81
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -65,6 +66,86 @@ public class UserSettingsEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public bool ShouldPreserveBookStyles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the player keeps downloading a track while playback is paused, or not, up to the entire file.
|
||||
/// </summary>
|
||||
public bool ShouldKeepDownloadingWhilePaused { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the player continues playback at the end of an album or artist, or not.
|
||||
/// </summary>
|
||||
public bool ShouldAutoplay { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the player transitions between consecutive tracks without a gap, or not.
|
||||
/// </summary>
|
||||
public bool IsGaplessPlaybackEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the way ReplayGain normalization is applied to the tracks the user plays.
|
||||
/// </summary>
|
||||
public ReplayGainMode ReplayGainMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the quality cap applied to the audio the server normalizes for the user.
|
||||
/// </summary>
|
||||
public PlaybackStreamingQuality StreamingQuality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the direction in which each channel of the VU meter of the audio player grows.
|
||||
/// </summary>
|
||||
public VuMeterOrientation VuMeterOrientation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of segments each channel of the VU meter is divided into.
|
||||
/// </summary>
|
||||
public int VuMeterSegmentCount { get; set; } = 12;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gap, in pixels, between the segments and the channels of the VU meter.
|
||||
/// </summary>
|
||||
public int VuMeterSegmentGap { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state.
|
||||
/// </summary>
|
||||
public double VuMeterMediumThreshold { get; set; } = 0.6;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the level, between 0 and 1, above which a segment of the VU meter is drawn with its high state.
|
||||
/// </summary>
|
||||
public double VuMeterHighThreshold { get; set; } = 0.8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the VU meter holds the peak level of each channel after it falls, or not.
|
||||
/// </summary>
|
||||
public bool VuMeterShowPeak { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time, in milliseconds, a peak of the VU meter is held before it starts falling.
|
||||
/// </summary>
|
||||
public int VuMeterPeakHoldDurationInMilliseconds { get; set; } = 650;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of level units the display of the VU meter falls per second when the input level drops.
|
||||
/// </summary>
|
||||
public double VuMeterReleasePerSecond { get; set; } = 3.0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of level units the peak of the VU meter falls per second after its hold time elapsed.
|
||||
/// </summary>
|
||||
public double VuMeterPeakReleasePerSecond { get; set; } = 0.65;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last volume the player reported for the user. Written automatically by the player, and not part of the settings the user edits.
|
||||
/// </summary>
|
||||
public double Volume { get; set; } = 1.0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last mute state the player reported for the user. Written automatically by the player, and not part of the settings the user edits.
|
||||
/// </summary>
|
||||
public bool IsMuted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
|
||||
Loaded 100 of 1946 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user