feat: add genre_ids support to discover playlists endpoint
This commit is contained in:
1 parent
d453bcd559
commit
d912bd1284
2 files changed
+15
-5
No files matched your search
@@ -583,11 +583,12 @@ impl QobuzClient {
|
||||
Ok(serde_json::from_value(response)?)
|
||||
}
|
||||
|
||||
/// Get discover playlists with optional tag filter
|
||||
/// Example: tags=label, tags=partner
|
||||
/// Get discover playlists with optional tag and genre filters
|
||||
/// Example: tags=label, genre_ids=112,119
|
||||
pub async fn get_discover_playlists(
|
||||
&self,
|
||||
tag: Option<String>,
|
||||
genre_ids: Option<Vec<u64>>,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
) -> Result<DiscoverPlaylistsResponse> {
|
||||
@@ -599,6 +600,14 @@ impl QobuzClient {
|
||||
query.push(("tags", t.clone()));
|
||||
}
|
||||
|
||||
// Add genre_ids as comma-separated list if provided
|
||||
if let Some(gids) = genre_ids {
|
||||
if !gids.is_empty() {
|
||||
let ids_str = gids.iter().map(|id| id.to_string()).collect::<Vec<_>>().join(",");
|
||||
query.push(("genre_ids", ids_str));
|
||||
}
|
||||
}
|
||||
|
||||
// Add limit (default 20)
|
||||
let lim = limit.unwrap_or(20);
|
||||
query.push(("limit", lim.to_string()));
|
||||
|
||||
@@ -676,19 +676,20 @@ pub async fn get_discover_index(
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Get discover playlists with optional tag filter
|
||||
/// Get discover playlists with optional tag and genre filters
|
||||
#[tauri::command]
|
||||
pub async fn get_discover_playlists(
|
||||
tag: Option<String>,
|
||||
genre_ids: Option<Vec<u64>>,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<DiscoverPlaylistsResponse, String> {
|
||||
log::debug!("Command: get_discover_playlists tag={:?} limit={:?} offset={:?}", tag, limit, offset);
|
||||
log::debug!("Command: get_discover_playlists tag={:?} genre_ids={:?} limit={:?} offset={:?}", tag, genre_ids, limit, offset);
|
||||
|
||||
let client = state.client.read().await;
|
||||
client
|
||||
.get_discover_playlists(tag, limit, offset)
|
||||
.get_discover_playlists(tag, genre_ids, limit, offset)
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user