Added the playlist generator
This commit is contained in:
@@ -289,6 +289,88 @@ pub struct SyncStats {
|
||||
pub skipped: u64,
|
||||
}
|
||||
|
||||
// --- Playlists ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct GenerateRequest {
|
||||
pub strategy: String,
|
||||
#[serde(default)]
|
||||
pub seed_artists: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub genres: Vec<String>,
|
||||
#[serde(default = "default_playlist_count")]
|
||||
pub count: usize,
|
||||
#[serde(default = "default_popularity_bias")]
|
||||
pub popularity_bias: u8,
|
||||
#[serde(default = "default_ordering")]
|
||||
pub ordering: String,
|
||||
#[serde(default)]
|
||||
pub rules: Option<SmartRulesInput>,
|
||||
}
|
||||
|
||||
fn default_playlist_count() -> usize {
|
||||
50
|
||||
}
|
||||
|
||||
fn default_popularity_bias() -> u8 {
|
||||
5
|
||||
}
|
||||
|
||||
fn default_ordering() -> String {
|
||||
"interleave".into()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct SmartRulesInput {
|
||||
#[serde(default)]
|
||||
pub genres: Vec<String>,
|
||||
pub added_within_days: Option<u32>,
|
||||
pub year_range: Option<(i32, i32)>,
|
||||
#[serde(default)]
|
||||
pub artists: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct GeneratedPlaylist {
|
||||
pub tracks: Vec<GeneratedTrack>,
|
||||
pub strategy: String,
|
||||
#[serde(default)]
|
||||
pub resolved_seeds: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct GeneratedTrack {
|
||||
pub track_id: i32,
|
||||
pub file_path: String,
|
||||
pub title: Option<String>,
|
||||
pub artist: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub score: f64,
|
||||
pub duration: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct PlaylistSummary {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub track_count: u64,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct PlaylistDetail {
|
||||
pub playlist: SavedPlaylist,
|
||||
pub tracks: Vec<Track>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct SavedPlaylist {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
// --- Config ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user