feat: restore most-popular search and top results badges
Some checks failed
Build for Windows / build-windows (push) Has been cancelled

This commit is contained in:
joren
2026-03-30 22:53:41 +02:00
parent 3346b424b3
commit 2da934f3f6
7 changed files with 134 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ enum QobuzEvent {
EV_USER_OK = 23,
EV_ARTIST_RELEASES_OK = 24,
EV_DEEP_SHUFFLE_OK = 25,
EV_MOST_POPULAR_OK = 26,
EV_GENRES_OK = 27,
EV_FEATURED_ALBUMS_OK = 28,
};
@@ -55,6 +56,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);

View File

@@ -453,6 +453,24 @@ impl QobuzClient {
})
}
pub async fn get_most_popular(
&self,
query: &str,
offset: u32,
limit: u32,
) -> Result<Value> {
let resp = self
.get_request("most-popular/get")
.query(&[
("query", query.to_string()),
("offset", offset.to_string()),
("limit", limit.to_string()),
])
.send()
.await?;
Self::check_response(resp).await
}
async fn search_tracks(
&self,
query: &str,

View File

@@ -45,6 +45,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;
pub const EV_GENRES_OK: c_int = 27;
pub const EV_FEATURED_ALBUMS_OK: c_int = 28;
@@ -203,6 +204,36 @@ 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
.get_most_popular(&query, 0, limit)
.await;
match result {
Ok(r) => call_cb(
cb,
ud,
EV_MOST_POPULAR_OK,
&serde_json::to_string(&r).unwrap_or_default(),
),
Err(e) => call_cb(cb, ud, EV_SEARCH_ERR, &err_json(&e.to_string())),
}
});
}
// ---------- Album ----------
#[no_mangle]