feat: most-popular search as default Top Results tab
Add /most-popular/get endpoint support (discovered via Burp): - Returns mixed artists/albums/tracks ordered by popularity for a query - New 'Top Results' tab shown first/default in the search panel - Badge column: A (artist, blue), H (hi-res album, gold), A (album, gray), T (track, green) - Full context menu support on all item types in the new tab - Both most-popular and regular search fire on submit in parallel Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,7 @@ void qobuz_backend_get_user(QobuzBackendOpaque *backend);
|
||||
|
||||
// Catalog
|
||||
void qobuz_backend_search(QobuzBackendOpaque *backend, const char *query, uint32_t offset, uint32_t limit);
|
||||
void qobuz_backend_most_popular_search(QobuzBackendOpaque *backend, const char *query, uint32_t limit);
|
||||
void qobuz_backend_get_album(QobuzBackendOpaque *backend, const char *album_id);
|
||||
void qobuz_backend_get_artist(QobuzBackendOpaque *backend, int64_t artist_id);
|
||||
void qobuz_backend_get_playlist(QobuzBackendOpaque *backend, int64_t playlist_id, uint32_t offset, uint32_t limit);
|
||||
|
||||
@@ -384,6 +384,15 @@ impl QobuzClient {
|
||||
|
||||
// --- Search ---
|
||||
|
||||
pub async fn most_popular_search(&self, query: &str, limit: u32) -> Result<serde_json::Value> {
|
||||
let resp = self
|
||||
.get_request("most-popular/get")
|
||||
.query(&[("query", query), ("offset", "0"), ("limit", &limit.to_string())])
|
||||
.send()
|
||||
.await?;
|
||||
Self::check_response(resp).await
|
||||
}
|
||||
|
||||
pub async fn search(&self, query: &str, offset: u32, limit: u32) -> Result<SearchCatalogDto> {
|
||||
let (tracks, albums, artists) = tokio::try_join!(
|
||||
self.search_tracks(query, offset, limit),
|
||||
|
||||
@@ -70,6 +70,7 @@ 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;
|
||||
pub const EV_DEEP_SHUFFLE_OK: c_int = 25;
|
||||
pub const EV_MOST_POPULAR_OK: c_int = 26;
|
||||
|
||||
// ---------- Callback ----------
|
||||
|
||||
@@ -222,6 +223,28 @@ pub unsafe extern "C" fn qobuz_backend_search(
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn qobuz_backend_most_popular_search(
|
||||
ptr: *mut Backend,
|
||||
query: *const c_char,
|
||||
limit: u32,
|
||||
) {
|
||||
let inner = &(*ptr).0;
|
||||
let query = CStr::from_ptr(query).to_string_lossy().into_owned();
|
||||
let client = inner.client.clone();
|
||||
let cb = inner.cb;
|
||||
let ud = inner.ud;
|
||||
|
||||
spawn(inner, async move {
|
||||
let result = client.lock().await.most_popular_search(&query, limit).await;
|
||||
let (ev, json) = match result {
|
||||
Ok(r) => (EV_MOST_POPULAR_OK, serde_json::to_string(&r).unwrap_or_default()),
|
||||
Err(e) => (EV_GENERIC_ERR, err_json(&e.to_string())),
|
||||
};
|
||||
call_cb(cb, ud, ev, &json);
|
||||
});
|
||||
}
|
||||
|
||||
// ---------- Album ----------
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user