feat: add per-user moods as generated playlists
Add private server-managed playlist moods with curated seeds and related library fill. Moods are created or promoted from existing playlists in the web UI, refresh lazily after their TTL, and are marked stale after a scan. Symfonium stars pin the active mood: opening a mood restores its context, and a starred song becomes a permanent seed. Without an active session the song is pinned to every mood that already contains it. Includes the V4 migration, custom mood endpoints, management UI, tests and smoke coverage. Bump the chart to 0.1.4.
This commit is contained in:
1 parent
e08d993e35
commit
28bfdd9d00
25 files changed
+2039
-14
No files matched your search
@@ -141,7 +141,8 @@ Build a lightweight, self-hosted **OpenSubsonic-compatible music server** in **K
|
||||
4. **Two content types, never mixed:** *music* and *long-form* (audiobooks, podcasts, lectures) live in **separate music folders**. Clients see and select them independently.
|
||||
5. **Multi-user:** users are defined outside the database (config + HashiCorp Vault). Music roots are assigned per user, long-form is shared. Stars, ratings, play counts, bookmarks and playlists are per user.
|
||||
6. **Transcoding:** optional on-the-fly MP3 transcoding with `maxBitRate` and `timeOffset` support.
|
||||
7. **Extensibility:** clean separation between scanner, database layer and HTTP API so a downloader and a discovery/recommendation engine can be added later.
|
||||
7. **Moods:** per-user private playlists generated from curated seeds and related library music. Symfonium likes pin songs to the active mood.
|
||||
8. **Extensibility:** clean separation between scanner, database layer and HTTP API so a downloader and a discovery/recommendation engine can be added later.
|
||||
|
||||
### Explicit non-goals (MVP)
|
||||
|
||||
@@ -152,6 +153,7 @@ Build a lightweight, self-hosted **OpenSubsonic-compatible music server** in **K
|
||||
- User-management API (users come from config/Vault).
|
||||
- TLS inside the app (terminated by the k3s ingress).
|
||||
- Automatic filesystem watching (scans are manual or on boot when the DB is empty).
|
||||
- Downloading or streaming YT Music inside the app (future phase; recommendations are metadata-only until then).
|
||||
- Backups (documented manual procedure only).
|
||||
|
||||
### Roles
|
||||
@@ -198,12 +200,18 @@ src/main/kotlin/win/taptap/musicmanager/
|
||||
| |-- LibraryRepository.kt # Visibility-scoped browsing, feeds, genres, search
|
||||
| |-- UserStateRepository.kt # Play counts, stars, ratings, bookmarks
|
||||
| |-- PlaylistRepository.kt # Playlist CRUD and visibility
|
||||
| |-- MoodRepository.kt # Mood settings, seeds, pinned recommendations
|
||||
| |-- MediaRepository.kt # Scanner persistence and aggregate rebuilds
|
||||
| `-- migrations/ # Flyway SQL (V1__init.sql, ...)
|
||||
|-- scanner/
|
||||
| |-- MediaScanner.kt # Recursive scan, delta updates, orphan cleanup
|
||||
| |-- Mp3TagExtractor.kt # jaudiotagger wrapper (tags, path fallback, duration, bitrate)
|
||||
| `-- CoverArtService.kt # Cover extraction from tags/folders, disk cache, resizing
|
||||
|-- mood/
|
||||
| |-- MoodMixService.kt # Seed + related-library mix generation
|
||||
| |-- MoodService.kt # TTL refresh and per-mood generation locking
|
||||
| |-- MoodSessionTracker.kt # Active mood for Symfonium star pinning
|
||||
| `-- MoodPins.kt # star/unstar -> mood seed translation
|
||||
|-- subsonic/
|
||||
| |-- SubsonicAuth.kt # Token (u, t, s) and password (p, enc:) auth
|
||||
| |-- SubsonicResponse.kt # JSON envelope & error codes
|
||||
@@ -217,7 +225,8 @@ src/main/kotlin/win/taptap/musicmanager/
|
||||
| |-- BrowsingRoutes.kt # indexes, artists, album, song, search3, lists, genres
|
||||
| |-- MediaRoutes.kt # stream, download, getCoverArt, lyrics
|
||||
| |-- InteractionRoutes.kt # scrobble, star/unstar, setRating, getStarred2
|
||||
| `-- PlaylistRoutes.kt # playlists and playlist songs
|
||||
| |-- PlaylistRoutes.kt # playlists and playlist songs
|
||||
| `-- MoodRoutes.kt # custom mood management endpoints
|
||||
|-- transcoding/
|
||||
| `-- FfmpegTranscoder.kt # MP3 transcoding with maxBitRate and timeOffset
|
||||
`-- util/
|
||||
@@ -438,6 +447,7 @@ CREATE TABLE playlists (
|
||||
name TEXT NOT NULL,
|
||||
comment TEXT,
|
||||
is_public BOOLEAN NOT NULL DEFAULT 1,
|
||||
kind TEXT NOT NULL DEFAULT 'user' CHECK (kind IN ('user', 'mood')),
|
||||
created_at TEXT NOT NULL,
|
||||
changed_at TEXT NOT NULL
|
||||
);
|
||||
@@ -448,6 +458,45 @@ CREATE TABLE playlist_songs (
|
||||
position INTEGER NOT NULL,
|
||||
PRIMARY KEY (playlist_id, position)
|
||||
);
|
||||
|
||||
-- Moods are private playlists with generation settings. The current mix lives
|
||||
-- in playlist_songs; these tables hold the anchors and future YT candidates.
|
||||
CREATE TABLE moods (
|
||||
playlist_id TEXT PRIMARY KEY REFERENCES playlists(id) ON DELETE CASCADE,
|
||||
query TEXT,
|
||||
genres TEXT NOT NULL DEFAULT '[]',
|
||||
target_size INTEGER NOT NULL DEFAULT 50,
|
||||
yt_slots INTEGER NOT NULL DEFAULT 0,
|
||||
expand_related BOOLEAN NOT NULL DEFAULT 1,
|
||||
refresh_hours INTEGER NOT NULL DEFAULT 24,
|
||||
generated_at TEXT,
|
||||
generation INTEGER NOT NULL DEFAULT 0,
|
||||
last_error TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE mood_seeds (
|
||||
playlist_id TEXT NOT NULL REFERENCES moods(playlist_id) ON DELETE CASCADE,
|
||||
song_id TEXT NOT NULL REFERENCES songs(id) ON DELETE CASCADE,
|
||||
origin TEXT NOT NULL DEFAULT 'manual'
|
||||
CHECK (origin IN ('manual', 'promoted', 'star', 'yt_like')),
|
||||
added_at TEXT NOT NULL,
|
||||
PRIMARY KEY (playlist_id, song_id)
|
||||
);
|
||||
|
||||
CREATE TABLE mood_recommendations (
|
||||
playlist_id TEXT NOT NULL REFERENCES moods(playlist_id) ON DELETE CASCADE,
|
||||
video_id TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
artist TEXT NOT NULL,
|
||||
duration INTEGER,
|
||||
state TEXT NOT NULL DEFAULT 'new'
|
||||
CHECK (state IN ('new', 'liked', 'rejected', 'downloaded')),
|
||||
matched_song_id TEXT REFERENCES songs(id) ON DELETE SET NULL,
|
||||
times_added INTEGER NOT NULL DEFAULT 0,
|
||||
first_seen TEXT NOT NULL,
|
||||
last_seen TEXT NOT NULL,
|
||||
PRIMARY KEY (playlist_id, video_id)
|
||||
);
|
||||
```
|
||||
|
||||
Required indexes:
|
||||
@@ -457,6 +506,7 @@ Required indexes:
|
||||
- `album_artists(artist_id)`, `song_artists(artist_id)`
|
||||
- `user_song_state(user_name, starred_at)`, `user_stars(user_name, item_type)`
|
||||
- `playlist_songs(song_id)`, `playlists(owner)`
|
||||
- `mood_seeds(song_id)`, `mood_recommendations(matched_song_id)`
|
||||
|
||||
All timestamps are ISO 8601 in UTC.
|
||||
|
||||
@@ -604,6 +654,46 @@ For every `/rest/*` call (except an optional health check):
|
||||
|
||||
No `createUser` / `updateUser` / `deleteUser` endpoints: config/Vault is the source of truth.
|
||||
|
||||
### 7.7 Moods (custom, for Symfonium)
|
||||
|
||||
OpenSubsonic has no mood entity, so a mood is a **private server-managed playlist**. The playlist ID and name stay stable, so Symfonium keeps its reference. Management lives in the built-in `/ui` page under **Moods**.
|
||||
|
||||
Custom endpoints use the normal Subsonic auth and JSON envelope:
|
||||
|
||||
- `getMoods`: list the caller's moods.
|
||||
- `getMood(id)`: settings plus `seed` and `entry` song lists.
|
||||
- `createMood(name, query, genre, songId, targetSize, ytSlots, expandRelated, refreshHours)`: creates a private playlist and generates the first mix.
|
||||
- `updateMood(id, ...)`: updates settings, marks the mix stale and regenerates.
|
||||
- `deleteMood(id)`: deletes the playlist and all mood data.
|
||||
- `refreshMood(id)`: synchronous regeneration.
|
||||
- `promotePlaylistToMood(playlistId, ...)`: keeps the same playlist ID and name; its current songs become `promoted` seeds.
|
||||
- `addMoodSeed(id, songId)` / `removeMoodSeed(id, songId)`: manual anchors.
|
||||
|
||||
Generation rules:
|
||||
|
||||
- Only the owner's **music** folders are used. Shared long-form folders never enter a mood.
|
||||
- Every seed is always included; if there are more seeds than `targetSize`, all seeds are kept.
|
||||
- With `expandRelated`, remaining slots are filled from matching genres/artists and, if needed, other visible music.
|
||||
- `ytSlots` is reserved for the YT Music recommendation phase.
|
||||
- A scan marks all moods stale. `getPlaylist` regenerates stale moods in the background; `refreshMood` forces it immediately.
|
||||
|
||||
Liking in Symfonium:
|
||||
|
||||
- Symfonium's heart calls `star`.
|
||||
- If a mood was opened within the last four hours, the starred song becomes a permanent `star` seed of that mood, even if it was not in the mix.
|
||||
- Without an active mood, the song is pinned to every mood that already contains it.
|
||||
- `unstar` removes only `star` seeds; manual and promoted seeds stay.
|
||||
- `updatePlaylist` and `createPlaylist(playlistId=...)` reject song edits on mood playlists with error 50; renaming is still allowed.
|
||||
|
||||
Symfonium has no built-in weekly sync interval. Automatic sync runs on app start and when it detects server changes. For a deterministic refresh, schedule the Symfonium broadcast API with Tasker/MacroDroid/Automate:
|
||||
|
||||
```text
|
||||
Action: app.symfonium.api.MEDIA_SYNC
|
||||
Package: app.symfonik.music.player
|
||||
Class: app.symfonium.remote.api.ApiReceiver
|
||||
Extra: PROVIDER_ID = <provider id from Settings -> Providers>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Scanner
|
||||
@@ -720,7 +810,7 @@ registry remains private.
|
||||
|
||||
Versions published by CI:
|
||||
|
||||
- `main`: `<chart version>-sha.<commit>`, for example `0.1.3-sha.<commit>`
|
||||
- `main`: `<chart version>-sha.<commit>`, for example `0.1.4-sha.<commit>`
|
||||
- `v*` tag: the tag without the leading `v`, for example `v0.2.0` -> `0.2.0`
|
||||
|
||||
Use it with Helm:
|
||||
@@ -735,7 +825,7 @@ helm search repo taptap/audiomanager
|
||||
Install a published chart:
|
||||
|
||||
```bash
|
||||
VERSION="0.1.3-sha.<commit>"
|
||||
VERSION="0.1.4-sha.<commit>"
|
||||
helm upgrade --install audiomanager taptap/audiomanager \
|
||||
--version "$VERSION" \
|
||||
--namespace audiomanager \
|
||||
@@ -751,7 +841,7 @@ helmCharts:
|
||||
releaseName: audiomanager
|
||||
namespace: audiomanager
|
||||
repo: https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main
|
||||
version: 0.1.3-sha.<commit>
|
||||
version: 0.1.4-sha.<commit>
|
||||
valuesFile: values.yaml
|
||||
```
|
||||
|
||||
@@ -825,6 +915,8 @@ Verify each step with `./gradlew test` and/or `curl`:
|
||||
- [x] 6. **Interaction & playlists:** `getAlbumList2`, `getRandomSongs`, `getStarred2`, `search3`, `scrobble`, `star`/`unstar`, `setRating`, bookmarks, playlists.
|
||||
- [x] 7. **Packaging:** multi-stage Dockerfile (with ffmpeg), Helm chart, Gitea Actions workflow.
|
||||
- [x] 8. **Tests:** integration suite as described above, plus a `curl` smoke script.
|
||||
- [x] 9. **Moods:** `V4__moods.sql`, `MoodRepository`, `MoodMixService`, `MoodService`, `MoodRoutes`, mood UI, Symfonium star pinning, and route tests.
|
||||
- [ ] 10. **YT recommendations:** yt-dlp discovery, mood recommendation UI, liked/wishlist candidates, and the optional downloader.
|
||||
|
||||
---
|
||||
|
||||
@@ -838,3 +930,5 @@ Verify each step with `./gradlew test` and/or `curl`:
|
||||
6. **No XML:** clients that insist on XML are unsupported.
|
||||
7. **No user-management API:** user changes are applied on restart after the Vault secret/config is updated.
|
||||
8. **Backups** are manual and documented; no backup endpoint.
|
||||
9. **YT Music recommendations** are the next phase. `mood_recommendations` and `yt_slots` are already in the schema; generation currently falls back to library music.
|
||||
10. **Mood playlists are fixed queues in Symfonium.** For fresh contents, let the lazy TTL refresh run and sync the client (Tasker recipe above).
|
||||
Reference in new issue
Block a user