feat(api): add genre_id filter to get_featured_albums
- Add optional genre_id parameter to client method - Add optional genre_id parameter to Tauri command - Qobuz API filters featured albums by genre when provided
This commit is contained in:
1 parent
8e31717908
commit
c2d61b46dc
2 files changed
+27
-7
No files matched your search
@@ -390,17 +390,29 @@ impl QobuzClient {
|
||||
}
|
||||
|
||||
/// Get featured albums by type (new-releases, press-awards, most-streamed)
|
||||
pub async fn get_featured_albums(&self, featured_type: &str, limit: u32, offset: u32) -> Result<SearchResultsPage<Album>> {
|
||||
pub async fn get_featured_albums(
|
||||
&self,
|
||||
featured_type: &str,
|
||||
limit: u32,
|
||||
offset: u32,
|
||||
genre_id: Option<u64>,
|
||||
) -> Result<SearchResultsPage<Album>> {
|
||||
let url = endpoints::build_url(paths::ALBUM_GET_FEATURED);
|
||||
let mut query = vec![
|
||||
("type".to_string(), featured_type.to_string()),
|
||||
("limit".to_string(), limit.to_string()),
|
||||
("offset".to_string(), offset.to_string()),
|
||||
];
|
||||
|
||||
if let Some(gid) = genre_id {
|
||||
query.push(("genre_id".to_string(), gid.to_string()));
|
||||
}
|
||||
|
||||
let response: Value = self
|
||||
.http
|
||||
.get(&url)
|
||||
.header("X-App-Id", self.app_id().await?)
|
||||
.query(&[
|
||||
("type", featured_type),
|
||||
("limit", &limit.to_string()),
|
||||
("offset", &offset.to_string()),
|
||||
])
|
||||
.query(&query)
|
||||
.send()
|
||||
.await?
|
||||
.json()
|
||||
|
||||
@@ -200,11 +200,19 @@ pub async fn get_featured_albums(
|
||||
featured_type: String,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
genre_id: Option<u64>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SearchResultsPage<Album>, String> {
|
||||
log::info!(
|
||||
"Command: get_featured_albums type={} limit={:?} offset={:?} genre_id={:?}",
|
||||
featured_type,
|
||||
limit,
|
||||
offset,
|
||||
genre_id
|
||||
);
|
||||
let client = state.client.lock().await;
|
||||
client
|
||||
.get_featured_albums(&featured_type, limit.unwrap_or(12), offset.unwrap_or(0))
|
||||
.get_featured_albums(&featured_type, limit.unwrap_or(12), offset.unwrap_or(0), genre_id)
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user