From b6202ebb66c5903df43f0b76ac307a3653dc06ed Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 9 Feb 2026 09:17:44 -0600 Subject: [PATCH] feat: add Rust backend for artist/page and releases/grid endpoints Add PageArtistResponse and ReleasesGridResponse types with all supporting structs for the /artist/page and /artist/getReleasesGrid Qobuz API endpoints. Add client methods and Tauri commands. --- src-tauri/src/api/client.rs | 64 +++++++++++ src-tauri/src/api/endpoints.rs | 3 + src-tauri/src/api/models.rs | 184 +++++++++++++++++++++++++++++++ src-tauri/src/commands/search.rs | 46 +++++++- src-tauri/src/lib.rs | 2 + 5 files changed, 298 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/api/client.rs b/src-tauri/src/api/client.rs index d5df6572d..02031dcaa 100644 --- a/src-tauri/src/api/client.rs +++ b/src-tauri/src/api/client.rs @@ -1120,6 +1120,70 @@ impl QobuzClient { Err(ApiError::ApiResponse(format!("Failed to remove favorite: {}", response.status()))) } } + + // ============ Artist Page Endpoints ============ + + /// Get artist page (aggregated: bio, top tracks, releases, similar, playlists) + pub async fn get_artist_page( + &self, + artist_id: u64, + sort: Option<&str>, + ) -> Result { + let url = endpoints::build_url(paths::ARTIST_PAGE); + let mut query = vec![ + ("artist_id", artist_id.to_string()), + ]; + if let Some(s) = sort { + query.push(("sort", s.to_string())); + } + + log::debug!("[API] get_artist_page({}) sort={:?}", artist_id, sort); + let response: serde_json::Value = self + .http + .get(&url) + .headers(self.api_headers().await?) + .query(&query) + .send() + .await? + .json() + .await?; + + Ok(serde_json::from_value(response)?) + } + + /// Get artist releases grid (paginated by release_type) + pub async fn get_releases_grid( + &self, + artist_id: u64, + release_type: &str, + limit: u32, + offset: u32, + sort: Option<&str>, + ) -> Result { + let url = endpoints::build_url(paths::ARTIST_RELEASES_GRID); + let mut query = vec![ + ("artist_id", artist_id.to_string()), + ("release_type", release_type.to_string()), + ("limit", limit.to_string()), + ("offset", offset.to_string()), + ]; + if let Some(s) = sort { + query.push(("sort", s.to_string())); + } + + log::debug!("[API] get_releases_grid({}) type={} limit={} offset={}", artist_id, release_type, limit, offset); + let response: serde_json::Value = self + .http + .get(&url) + .headers(self.api_headers().await?) + .query(&query) + .send() + .await? + .json() + .await?; + + Ok(serde_json::from_value(response)?) + } } impl Default for QobuzClient { diff --git a/src-tauri/src/api/endpoints.rs b/src-tauri/src/api/endpoints.rs index bce20905a..3d231f7ce 100644 --- a/src-tauri/src/api/endpoints.rs +++ b/src-tauri/src/api/endpoints.rs @@ -21,6 +21,9 @@ pub mod paths { pub const ARTIST_GET: &str = "/artist/get"; pub const ARTIST_SEARCH: &str = "/artist/search"; pub const ARTIST_GET_SIMILAR: &str = "/artist/getSimilarArtists"; + pub const ARTIST_PAGE: &str = "/artist/page"; + pub const ARTIST_RELEASES_GRID: &str = "/artist/getReleasesGrid"; + pub const ARTIST_RELEASES_LIST: &str = "/artist/getReleasesList"; // Playlist pub const PLAYLIST_GET: &str = "/playlist/get"; diff --git a/src-tauri/src/api/models.rs b/src-tauri/src/api/models.rs index 761bb7a4a..07aaa029f 100644 --- a/src-tauri/src/api/models.rs +++ b/src-tauri/src/api/models.rs @@ -470,3 +470,187 @@ pub struct DiscoverAudioInfo { pub maximum_bit_depth: Option, pub maximum_channel_count: Option, } + +// ============ Artist Page Types (/artist/page) ============ + +/// Top-level response from /artist/page +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistResponse { + pub id: u64, + pub name: PageArtistName, + pub artist_category: Option, + pub biography: Option, + pub images: Option, + pub similar_artists: Option, + pub top_tracks: Option>, + pub last_release: Option, + pub releases: Option>, + pub tracks_appears_on: Option>, + pub playlists: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistName { + pub display: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistBiography { + pub content: Option, + pub source: Option, + pub language: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistImages { + pub portrait: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistPortrait { + pub hash: String, + pub format: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistSimilar { + pub has_more: bool, + pub items: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistSimilarItem { + pub id: u64, + pub name: PageArtistName, + pub images: Option, +} + +/// A group of releases by type (e.g., "album", "ep", "live") +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistReleaseGroup { + #[serde(rename = "type")] + pub release_type: String, + pub has_more: bool, + pub items: Vec, +} + +/// A release item (album/ep/live/etc) from /artist/page or /artist/getReleasesGrid +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PageArtistRelease { + pub id: String, + pub title: String, + pub version: Option, + pub tracks_count: Option, + pub artist: Option, + pub artists: Option>, + pub image: Option, + pub label: Option