Files
playlistd/src/track.rs
T
Claude a8b1123777 Add discover UI with new song suggestions
Each mix rebuild now also finds songs that aren't in the library: the
user's Listenbrainz recommendations they've never played, plus an LB
Radio prompt per mix when a Listenbrainz token is configured. Each
candidate goes to the mix whose genre profile it fits best and is
skipped if it's already in the library or was played recently.

discover/ is a new React app to listen to the mixes: library songs
stream from Subsonic and suggested songs are found on YouTube with
yt-dlp, both proxied through playlistd with Range support for seeking.
Suggestions can be liked (kept in a "Liked new songs" list) or hidden.

- discover: candidate gathering, genre fit scoring, library filtering
- web: /api/discover routes, Subsonic/YouTube streaming proxy
- youtube: yt-dlp search (skipping hour-long results) and audio URLs
- mix tags now hold library genre names, for display in the UI
- config: listenbrainz.token, discover.ui, discover.ytdlp, discover.format

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-13 16:39:46 +00:00

45 lines
1.2 KiB
Rust

use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Track {
pub id: String,
pub title: String,
#[serde(default)]
pub album: String,
#[serde(default)]
pub artist: String,
#[serde(default)]
pub genre: Option<String>,
/// OpenSubsonic: all of the song's genres
#[serde(default)]
pub genres: Vec<ItemGenre>,
#[serde(rename = "musicBrainzId", default)]
pub music_brainz_id: Option<String>,
/// Seconds
#[serde(default)]
pub duration: Option<u64>,
#[serde(rename = "coverArt", default)]
pub cover_art: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ItemGenre {
pub name: String,
}
impl Track {
/// The song's genres, from the OpenSubsonic `genres` list if the server provides it,
/// otherwise from the plain `genre` field
pub fn genre_names(&self) -> Vec<String> {
if !self.genres.is_empty() {
return self.genres.iter().map(|g| g.name.clone()).collect();
}
self.genre
.iter()
.flat_map(|g| g.split([';', ',', '/']))
.map(|g| g.trim().to_string())
.filter(|g| !g.is_empty())
.collect()
}
}