feat: add Qobuz featured albums (New Releases, Press Awards)
- Add album/getFeatured endpoint to API - Create get_featured_albums Tauri command - Add New Releases and Press Awards sections to HomeView - Featured albums load first for faster perceived performance
This commit is contained in:
1 parent
bb996a4002
commit
6f8dc41a98
5 files changed
+121
-2
No files matched your search
@@ -246,6 +246,30 @@ impl QobuzClient {
|
||||
Ok(serde_json::from_value(response)?)
|
||||
}
|
||||
|
||||
/// Get featured albums by type (new-releases, press-awards, most-streamed)
|
||||
pub async fn get_featured_albums(&self, featured_type: &str, limit: u32, offset: u32) -> Result<SearchResultsPage<Album>> {
|
||||
let url = endpoints::build_url(paths::ALBUM_GET_FEATURED);
|
||||
let response: Value = self
|
||||
.http
|
||||
.get(&url)
|
||||
.header("X-App-Id", self.app_id().await?)
|
||||
.query(&[
|
||||
("type", featured_type),
|
||||
("limit", &limit.to_string()),
|
||||
("offset", &offset.to_string()),
|
||||
])
|
||||
.send()
|
||||
.await?
|
||||
.json()
|
||||
.await?;
|
||||
|
||||
let albums = response
|
||||
.get("albums")
|
||||
.ok_or_else(|| ApiError::ApiResponse("No albums in response".to_string()))?;
|
||||
|
||||
Ok(serde_json::from_value(albums.clone())?)
|
||||
}
|
||||
|
||||
/// Get track by ID
|
||||
pub async fn get_track(&self, track_id: u64) -> Result<Track> {
|
||||
let url = endpoints::build_url(paths::TRACK_GET);
|
||||
|
||||
@@ -15,6 +15,7 @@ pub mod paths {
|
||||
// Album
|
||||
pub const ALBUM_GET: &str = "/album/get";
|
||||
pub const ALBUM_SEARCH: &str = "/album/search";
|
||||
pub const ALBUM_GET_FEATURED: &str = "/album/getFeatured";
|
||||
|
||||
// Artist
|
||||
pub const ARTIST_GET: &str = "/artist/get";
|
||||
|
||||
@@ -53,6 +53,21 @@ pub async fn get_album(album_id: String, state: State<'_, AppState>) -> Result<A
|
||||
client.get_album(&album_id).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Get featured albums by type (new-releases, press-awards)
|
||||
#[tauri::command]
|
||||
pub async fn get_featured_albums(
|
||||
featured_type: String,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SearchResultsPage<Album>, String> {
|
||||
let client = state.client.lock().await;
|
||||
client
|
||||
.get_featured_albums(&featured_type, limit.unwrap_or(12), offset.unwrap_or(0))
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_track(track_id: u64, state: State<'_, AppState>) -> Result<Track, String> {
|
||||
let client = state.client.lock().await;
|
||||
|
||||
@@ -191,6 +191,7 @@ pub fn run() {
|
||||
commands::search_tracks,
|
||||
commands::search_artists,
|
||||
commands::get_album,
|
||||
commands::get_featured_albums,
|
||||
commands::get_track,
|
||||
commands::get_artist,
|
||||
// Playback commands
|
||||
|
||||
Reference in new issue
Block a user