Add genre mixes from clustering recent listens
A new cluster_mix_rule clusters a Listenbrainz user's listens from the last few months by MusicBrainz genre (with tracks played in the same session pulled together) and maintains one Subsonic playlist per cluster, filled with the cluster's most played tracks plus unheard library songs from the best matching library genres. - listenbrainz: fetch raw listens since a timestamp and bulk recording genres, handling rate limits - cluster: tag TF-IDF + co-listen smoothing, spherical k-means with k chosen by silhouette score - mix: match cluster profiles to library genres and pick songs, with a per-artist cap; reuse playlists across rebuilds by genre overlap - subsonic: getGenres, getSongsByGenre, rename/delete playlist, genre and MBID fields on tracks, API error detection - daemon, migration, POST/GET /api/playlist/mix and README docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
This commit is contained in:
13 files changed
+1728
-5
No files matched your search
@@ -4,6 +4,36 @@ use serde::{Deserialize, Serialize};
|
||||
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>,
|
||||
}
|
||||
|
||||
#[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()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user