feat: download accepted recommendations and track longform progress
CI / chart (push) Successful in 4s
CI / chart-push (push) Successful in 4s
CI / test (push) Successful in 2m5s
CI / image (push) Successful in 3m14s

Accepted recommendations without a library match now enter a download queue.
A worker downloads the MP3 with yt-dlp into "<music>/AudioManager Imports",
runs a scan, matches the new song, links it to the recommendation and adds it
as a seed. Jobs retry three times and expose queued/downloading/done/failed
state (plus the error) on the recommendation DTO, so clients can show progress
and retry. Downloads can be disabled and the target folder chosen.

Long-form gets resume points: GET/PUT /longform/progress, scoped to longform
folders and to the owner, with automatic completion detection. Longform stays
excluded from moods and radio.

The chart mounts the music hostPath writable for imports and passes the new
DOWNLOAD_* settings; version 0.2.3.
This commit is contained in:
TapTap committed 2026-11-15 13:26:22 +00:00
1 parent 51d1b20bf6
commit a5af1ee83f
18 files changed
+996 -9

No files matched your search

+21 -3
View File
@@ -109,7 +109,10 @@ Passwords are read into memory at startup and never written to SQLite. In produc
| `LIBRARY_CONFIG` | `./config/library.yaml` | Library folders |
| `USERS_FILE` | `./config/users.yaml` | Users and passwords |
| `FFMPEG_PATH` | `ffmpeg` | Transcoder binary |
| `YTDLP_PATH` | `yt-dlp` | `yt-dlp` binary used for YT Music discovery |
| `YTDLP_PATH` | `yt-dlp` | `yt-dlp` binary used for discovery and downloads |
| `DOWNLOADS_ENABLED` | `true` | Download accepted recommendations that are not in the library |
| `DOWNLOAD_DIR` | `$DATA_DIR/downloads` | Temporary files for the download worker |
| `DOWNLOAD_FOLDER_ID` | first visible music folder | Folder that receives downloaded MP3s |
## The mood model
@@ -181,6 +184,8 @@ Song objects contain deterministic IDs (`sg-…`), album/artist names, duration,
- `POST /moods/{id}/recommendations/{videoId}/accept` — accept; the library match becomes a seed immediately.
- `POST /moods/{id}/recommendations/{videoId}/reject` — reject; the candidate is not offered again.
Accepted recommendations without a library match are queued for download (`download.state` = `queued|downloading|done|failed` in the recommendation). The worker writes MP3s into `<music folder>/AudioManager Imports`, runs a scan, matches the new song, adds it as a seed and updates the recommendation.
### Radio sessions
- `POST /moods/{id}/sessions` — `{ limit?: 15 }` → session plus the first queue.
@@ -190,6 +195,14 @@ Song objects contain deterministic IDs (`sg-…`), album/artist names, duration,
- `POST /sessions/{id}/add-to-mood` — `{ songId, moodId? }`. Without `moodId`, the session's mood is used. This is the replacement for likes.
- `DELETE /sessions/{id}` — close.
### Long-form
- `GET /library/songs?scope=longform` — the long-form library (shared with every user).
- `GET /longform/progress` — resume points, newest first, with song data.
- `PUT /longform/progress/{songId}` — `{ positionSeconds, durationSeconds?, completed? }`.
Long-form folders are never valid mood seeds and never enter radio.
### System
- `GET /scan` — `{ scanning, count, error }`
@@ -208,12 +221,16 @@ src/main/kotlin/win/taptap/musicmanager/
|-- discovery/
| |-- YtSearch.kt # yt-dlp search and result parsing
| `-- DiscoveryService.kt # Queries, matching, scoring, pruning
|-- download/
| |-- DownloadService.kt # Queue worker, import folder, scan, promotion
| `-- YtDlpDownloader.kt # MP3 download with embedded metadata
|-- api/
| |-- ApiRoutes.kt # /api/v1 wiring, auth and system endpoints
| |-- ApiModels.kt # Native DTOs
| |-- ApiSupport.kt # Token resolution, errors, folder scoping
| |-- LibraryApi.kt # Sync, search, stream, covers
| |-- MoodApi.kt # Mood CRUD, seeds, preview, recommendations
| |-- LongformApi.kt # Long-form resume points
| `-- SessionApi.kt # Radio sessions, events, add-to-mood
|-- radio/
| `-- RadioService.kt # Candidate pool, scoring, diversity, batches
@@ -230,7 +247,7 @@ src/main/kotlin/win/taptap/musicmanager/
`-- util/ # Deterministic IDs, sort names
```
YT discovery runs in the background for stale moods (`refreshHours`) and on demand from the mood screen. Queries come from the mood text, seed artists and genres; results are deduplicated, filtered to music-length videos, matched to library songs by normalized title and artist, and scored. Undecided candidates not seen in a refresh are pruned; accepted and rejected decisions are permanent. Accepted tracks that are not in the library wait for the future downloader, which will drop them into an import folder and rescan.
YT discovery runs in the background for stale moods (`refreshHours`) and on demand from the mood screen. Queries come from the mood text, seed artists and genres; results are deduplicated, filtered to music-length videos, matched to library songs by normalized title and artist, and scored. Undecided candidates not seen in a refresh are pruned; accepted and rejected decisions are permanent. Accepted tracks that are not in the library are downloaded by the worker into `<music>/AudioManager Imports`, scanned, matched and added as seeds automatically.
The old OpenSubsonic layer (`/rest`, `subsonic/`, playlist materialization) was removed in 0.2.0. The server and the KMP client are the two halves of the same product; there is no compatibility layer to preserve and no server-rendered UI.
@@ -294,6 +311,7 @@ deploy into the wrong place. Set `allowDefaultNamespace=true` to opt in to
The chart expects:
- a `users.yaml` Secret (Vault-managed) referenced by `users.existingSecret`;
- a writable music hostPath when automatic downloads are enabled;
- a `library.yaml` ConfigMap;
- read-only hostPaths for music and long-form;
- a registry pull secret for the private image.
@@ -335,5 +353,5 @@ The smoke test generates tagged MP3s, starts the server, and verifies login, syn
- [x] Kotlin Multiplatform client foundation (Android, desktop, web).
- [x] Offline downloads and offline playback across clients.
- [x] YT Music discovery through `yt-dlp`, recommendation list, accept/reject.
- [ ] Optional downloader that writes accepted tracks into an import folder and rescans.
- [x] Downloader that writes accepted tracks into an import folder and rescans.
- [ ] Home-screen widgets, Android Auto, and richer radio tuning.