feat: full artist release list via artist/getReleasesList
Instead of relying on the limited preview in artist/page, fire a separate artist/getReleasesList request per release type (album, epSingle, live, compilation) in parallel when loading an artist. Each result updates its section independently as it arrives, so the page populates progressively without a single large request. Also fixes the artist name in the status bar (was reading wrong field). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -267,6 +267,28 @@ impl QobuzClient {
|
||||
Self::check_response(resp).await
|
||||
}
|
||||
|
||||
pub async fn get_artist_releases_list(
|
||||
&self,
|
||||
artist_id: i64,
|
||||
release_type: &str,
|
||||
limit: u32,
|
||||
offset: u32,
|
||||
) -> Result<Value> {
|
||||
let resp = self
|
||||
.get_request("artist/getReleasesList")
|
||||
.query(&[
|
||||
("artist_id", artist_id.to_string()),
|
||||
("release_type", release_type.to_string()),
|
||||
("sort", "release_date".to_string()),
|
||||
("order", "desc".to_string()),
|
||||
("limit", limit.to_string()),
|
||||
("offset", offset.to_string()),
|
||||
])
|
||||
.send()
|
||||
.await?;
|
||||
Self::check_response(resp).await
|
||||
}
|
||||
|
||||
// --- Search ---
|
||||
|
||||
pub async fn search(&self, query: &str, offset: u32, limit: u32) -> Result<SearchCatalogDto> {
|
||||
|
||||
@@ -68,6 +68,7 @@ pub const EV_POSITION: c_int = 16;
|
||||
pub const EV_TRACK_URL_OK: c_int = 17;
|
||||
pub const EV_TRACK_URL_ERR: c_int = 18;
|
||||
pub const EV_GENERIC_ERR: c_int = 19;
|
||||
pub const EV_ARTIST_RELEASES_OK: c_int = 24;
|
||||
|
||||
// ---------- Callback ----------
|
||||
|
||||
@@ -256,6 +257,38 @@ pub unsafe extern "C" fn qobuz_backend_get_artist(ptr: *mut Backend, artist_id:
|
||||
});
|
||||
}
|
||||
|
||||
// ---------- Artist releases ----------
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn qobuz_backend_get_artist_releases(
|
||||
ptr: *mut Backend,
|
||||
artist_id: i64,
|
||||
release_type: *const c_char,
|
||||
limit: u32,
|
||||
offset: u32,
|
||||
) {
|
||||
let inner = &(*ptr).0;
|
||||
let client = inner.client.clone();
|
||||
let cb = inner.cb; let ud = inner.ud;
|
||||
let rtype = CStr::from_ptr(release_type).to_string_lossy().into_owned();
|
||||
|
||||
spawn(inner, async move {
|
||||
let result = client.lock().await
|
||||
.get_artist_releases_list(artist_id, &rtype, limit, offset)
|
||||
.await;
|
||||
let (ev, json) = match result {
|
||||
Ok(r) => {
|
||||
// Wrap with the release_type so Qt can route to the right section
|
||||
let mut obj = r.as_object().cloned().unwrap_or_default();
|
||||
obj.insert("release_type".to_string(), serde_json::Value::String(rtype));
|
||||
(EV_ARTIST_RELEASES_OK, serde_json::to_string(&obj).unwrap_or_default())
|
||||
}
|
||||
Err(e) => (EV_GENERIC_ERR, err_json(&e.to_string())),
|
||||
};
|
||||
call_cb(cb, ud, ev, &json);
|
||||
});
|
||||
}
|
||||
|
||||
// ---------- Playlist ----------
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user