feat(api): add 7 label endpoints from v9.7.0.3 spec

Closes the gap between our client and the Qobuz Android app's current
label API (source: c30/b.java). Qobuz is rolling out a web beta so the
legacy /label/get is likely on borrowed time — adding the v9.7.0.3
endpoints now so the migration can happen in follow-up commits.

New endpoints (paths + client + core + bridge + v2 command + registered):
- /label/getAlbums           → v2_get_label_albums
    paginated catalog with sort/order/genre_ids/from_date/to_date
- /label/getNextReleases     → v2_get_label_next_releases
- /label/getAwardedReleases  → v2_get_label_awarded_releases
- /label/getPlaylists        → v2_get_label_playlists
- /label/getTopArtists       → v2_get_label_top_artists
- /label/story               → v2_get_label_story
- /label/getList             → v2_get_label_list (POST, mirrors
    track/getList signing)

New response types in qbz-models:
- LabelListPage<T> — generic { has_more, items: [T], total?, offset?,
  limit? } envelope, tolerant to either V2 list or SearchResultsPage
  shapes until samples land
- LabelStoryResponse, LabelGetListResponse — best-effort with optional
  fields so a shape mismatch is non-fatal

The legacy /label/get + get_label() + v2_get_label + LabelDetail are
retained untouched for now; frontend migration and deletion come next.

cc
This commit is contained in:
vicrodh committed 2026-04-16 22:48:38 -06:00
1 parent e83caa7648
commit 595b71e4eb
8 files changed
+685 -8

No files matched your search

+190
View File
@@ -1636,6 +1636,10 @@ impl QobuzClient {
}
/// Get label by ID with albums
///
/// DEPRECATED: `/label/get` is not documented in the v9.7.0.3 spec.
/// Use `get_label_albums` (catalog) + `get_label_page` (metadata).
/// Kept temporarily for backward-compat during frontend migration.
pub async fn get_label(&self, label_id: u64, limit: u32, offset: u32) -> Result<LabelDetail> {
let url = endpoints::build_url(paths::LABEL_GET);
let locale = self.locale().await;
@@ -1659,6 +1663,192 @@ impl QobuzClient {
Ok(serde_json::from_value(response)?)
}
/// Get a label's album catalog (paginated, filterable).
///
/// Replaces the legacy `/label/get?extra=albums` path.
#[allow(clippy::too_many_arguments)]
pub async fn get_label_albums(
&self,
label_id: u64,
limit: u32,
offset: u32,
sort: Option<&str>,
order: Option<&str>,
genre_ids: Option<&str>,
from_date: Option<&str>,
to_date: Option<&str>,
) -> Result<LabelListPage<Album>> {
let url = endpoints::build_url(paths::LABEL_GET_ALBUMS);
let mut params: Vec<(&str, String)> = vec![
("label_id", label_id.to_string()),
("limit", limit.to_string()),
("offset", offset.to_string()),
];
if let Some(v) = sort { params.push(("sort", v.to_string())); }
if let Some(v) = order { params.push(("order", v.to_string())); }
if let Some(v) = genre_ids { params.push(("genre_ids", v.to_string())); }
if let Some(v) = from_date { params.push(("from_date", v.to_string())); }
if let Some(v) = to_date { params.push(("to_date", v.to_string())); }
log::debug!("[API] get_label_albums({}, limit={}, offset={})", label_id, limit, offset);
let response: Value = self
.signed_get(&url, "labelgetalbums", &params)
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
/// Get a label's upcoming releases.
pub async fn get_label_next_releases(
&self,
label_id: u64,
limit: u32,
offset: u32,
genre_ids: Option<&str>,
) -> Result<LabelListPage<Album>> {
let url = endpoints::build_url(paths::LABEL_GET_NEXT_RELEASES);
let mut params: Vec<(&str, String)> = vec![
("label_id", label_id.to_string()),
("limit", limit.to_string()),
("offset", offset.to_string()),
];
if let Some(v) = genre_ids { params.push(("genre_ids", v.to_string())); }
log::debug!("[API] get_label_next_releases({})", label_id);
let response: Value = self
.signed_get(&url, "labelgetnextreleases", &params)
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
/// Get a label's press-awarded releases.
pub async fn get_label_awarded_releases(
&self,
label_id: u64,
limit: u32,
offset: u32,
sort: Option<&str>,
order: Option<&str>,
genre_ids: Option<&str>,
) -> Result<LabelListPage<Album>> {
let url = endpoints::build_url(paths::LABEL_GET_AWARDED_RELEASES);
let mut params: Vec<(&str, String)> = vec![
("label_id", label_id.to_string()),
("limit", limit.to_string()),
("offset", offset.to_string()),
];
if let Some(v) = sort { params.push(("sort", v.to_string())); }
if let Some(v) = order { params.push(("order", v.to_string())); }
if let Some(v) = genre_ids { params.push(("genre_ids", v.to_string())); }
log::debug!("[API] get_label_awarded_releases({})", label_id);
let response: Value = self
.signed_get(&url, "labelgetawardedreleases", &params)
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
/// Get a label's curated playlists (paginated).
pub async fn get_label_playlists(
&self,
label_id: u64,
limit: u32,
offset: u32,
) -> Result<LabelListPage<Playlist>> {
let url = endpoints::build_url(paths::LABEL_GET_PLAYLISTS);
log::debug!("[API] get_label_playlists({})", label_id);
let response: Value = self
.signed_get(&url, "labelgetplaylists", &[
("label_id", label_id.to_string()),
("limit", limit.to_string()),
("offset", offset.to_string()),
])
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
/// Get a label's top artists (paginated).
pub async fn get_label_top_artists(
&self,
label_id: u64,
limit: u32,
offset: u32,
) -> Result<LabelListPage<Artist>> {
let url = endpoints::build_url(paths::LABEL_GET_TOP_ARTISTS);
log::debug!("[API] get_label_top_artists({})", label_id);
let response: Value = self
.signed_get(&url, "labelgettopartists", &[
("label_id", label_id.to_string()),
("limit", limit.to_string()),
("offset", offset.to_string()),
])
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
/// Get a label's editorial / story content.
pub async fn get_label_story(
&self,
label_id: u64,
limit: u32,
offset: u32,
) -> Result<LabelStoryResponse> {
let url = endpoints::build_url(paths::LABEL_STORY);
log::debug!("[API] get_label_story({})", label_id);
let response: Value = self
.signed_get(&url, "labelstory", &[
("label_id", label_id.to_string()),
("limit", limit.to_string()),
("offset", offset.to_string()),
])
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
/// Bulk lookup a set of labels by ID (POST).
///
/// Follows the same signing convention as `get_tracks_batch` (see
/// `track/getList`): the sig covers the joined ID list as a query
/// string key, and the JSON body carries the list itself.
pub async fn get_label_list(&self, label_ids: &[u64]) -> Result<LabelGetListResponse> {
let url = endpoints::build_url(paths::LABEL_GET_LIST);
let headers = self.api_headers().await?;
let timestamp = get_timestamp();
let secret = self.secret().await?;
let ids_str: String = label_ids
.iter()
.map(|id| id.to_string())
.collect::<Vec<_>>()
.join(",");
let sig = sign_request("labelgetList", &[("label_ids", &ids_str)], timestamp, &secret);
let body = serde_json::json!({ "label_ids": label_ids });
log::debug!("[API] get_label_list POST ({} ids)", label_ids.len());
let response: Value = self
.http
.post(&url)
.headers(headers)
.query(&[("request_ts", timestamp.to_string()), ("request_sig", sig)])
.json(&body)
.send()
.await?
.json()
.await?;
Ok(serde_json::from_value(response)?)
}
// === Authenticated endpoints ===
/// Get stream URL for a track (requires auth + signature)
+10
View File
@@ -53,9 +53,19 @@ pub mod paths {
pub const FAVORITE_GET_NEW_RELEASES: &str = "/favorite/getNewReleases";
// Label
// NOTE: /label/get is retained only for backward-compat until the
// frontend is fully migrated; the v9.7.0.3 spec drops it in favor of
// /label/getAlbums.
pub const LABEL_GET: &str = "/label/get";
pub const LABEL_PAGE: &str = "/label/page";
pub const LABEL_EXPLORE: &str = "/label/explore";
pub const LABEL_GET_ALBUMS: &str = "/label/getAlbums";
pub const LABEL_GET_NEXT_RELEASES: &str = "/label/getNextReleases";
pub const LABEL_GET_AWARDED_RELEASES: &str = "/label/getAwardedReleases";
pub const LABEL_GET_PLAYLISTS: &str = "/label/getPlaylists";
pub const LABEL_GET_TOP_ARTISTS: &str = "/label/getTopArtists";
pub const LABEL_STORY: &str = "/label/story";
pub const LABEL_GET_LIST: &str = "/label/getList";
// Award
pub const AWARD_PAGE: &str = "/award/page";