feat: search and download from YouTube Music
- search music.youtube.com with the Songs filter and resolve each hit so results carry canonical artist, album and duration - fall back to plain ytsearch when the Music search fails - download the Music watch URL first and the regular YouTube URL second - parse explicit artist fields and drop channel/album/playlist entries - update the smoke stub, docs and tests
This commit is contained in:
1 parent
61d8b58223
commit
515b9bbe1b
6 files changed
+215
-29
No files matched your search
@@ -1,9 +1,9 @@
|
||||
# AudioManager
|
||||
|
||||
A self-hosted, mood-first music server. You create private moods, add tracks
|
||||
from YouTube search or a pasted URL, and the server downloads them into a shared
|
||||
media store. Recommendations are discovered and downloaded automatically so a
|
||||
mood keeps playing without a mounted music library.
|
||||
from YouTube Music search or a pasted URL, and the server downloads them into a
|
||||
shared media store. Recommendations are discovered and downloaded automatically
|
||||
so a mood keeps playing without a mounted music library.
|
||||
|
||||
- Server: Kotlin, Ktor, SQLite (Exposed + Flyway), `yt-dlp`, `ffmpeg`.
|
||||
- Client: Compose Multiplatform (Android, desktop, Wasm).
|
||||
@@ -61,8 +61,8 @@ Requirements: JDK 21, `ffmpeg`, `yt-dlp`, and (for the smoke test) `sqlite3`,
|
||||
The server creates `./data/media` (the media store), `./data/downloads`
|
||||
(download temp files) and `./data/musicmanager.db`.
|
||||
|
||||
Downloads require `yt-dlp` to be able to reach YouTube. If YouTube applies bot
|
||||
checks, search and downloads fail with `502 search_failed` / `failed`
|
||||
Downloads require `yt-dlp` to be able to reach YouTube Music. If YouTube applies
|
||||
bot checks, search and downloads fail with `502 search_failed` / `failed`
|
||||
recommendations; retry later or update `yt-dlp`.
|
||||
|
||||
## Configuration
|
||||
@@ -133,10 +133,16 @@ finishes.
|
||||
|
||||
| Method | Path | Purpose |
|
||||
|---|---|---|
|
||||
| `GET` | `/search?q=...&limit=...` | YouTube search |
|
||||
| `GET` | `/search?q=...&limit=...` | YouTube Music search |
|
||||
|
||||
Results longer than 10 minutes (or shorter than 30 seconds) are hidden. Each
|
||||
result reports `downloaded` and `songId` when the track is already in the store.
|
||||
result reports `downloaded`, `songId` and `inMood` when applicable.
|
||||
|
||||
Search uses the YouTube Music catalog (the "Songs" filter), so results are
|
||||
canonical tracks with an artist, album and duration instead of arbitrary
|
||||
uploads. yt-dlp has to resolve every hit to read those fields, which takes
|
||||
roughly 10–15 seconds for ten results. If the Music search fails, the server
|
||||
falls back to the regular YouTube search so the feature keeps working.
|
||||
|
||||
### Playback
|
||||
|
||||
@@ -166,7 +172,7 @@ Ktor routes
|
||||
└── SongRepository ── shared song store keyed by video id
|
||||
└── RadioService ── mixes collection + ready recommendations
|
||||
└── DownloadService── single worker: yt-dlp → media store → index → attach
|
||||
└── DiscoveryService── yt-dlp search → hidden `new` candidates
|
||||
└── DiscoveryService── yt-dlp YouTube Music search → hidden `new` candidates
|
||||
└── TopUpService ── keeps active slots at recommendationCount
|
||||
└── MediaScanner ── rebuilds the index from the media root
|
||||
└── MediaGcService ── refcounted file deletion
|
||||
@@ -188,6 +194,12 @@ depends on tags. One row and one file exist per video, no matter how many moods
|
||||
or users reference it. Covers are cached under `<DATA_DIR>/covers` keyed by song
|
||||
id.
|
||||
|
||||
Downloads are requested from the YouTube Music player
|
||||
(`music.youtube.com/watch?v=<id>`), which makes yt-dlp embed the song's artist,
|
||||
album and release year into the MP3. Videos that are not on the Music host fall
|
||||
back to the regular YouTube URL. Files are MP3 only
|
||||
(`-x --audio-format mp3 --audio-quality 0`).
|
||||
|
||||
A file is deleted only when it has no references from `mood_songs`, an active
|
||||
recommendation (`downloading`, `ready`, `added`, `failed`), or an open playback
|
||||
session. GC runs after removals, after rejections, after mood deletion, and
|
||||
|
||||
Reference in new issue
Block a user