diff --git a/src-tauri/src/api/client.rs b/src-tauri/src/api/client.rs index 02708e40a..bb89a6dcc 100644 --- a/src-tauri/src/api/client.rs +++ b/src-tauri/src/api/client.rs @@ -549,6 +549,40 @@ impl QobuzClient { Ok(serde_json::from_value(response)?) } + /// Get discover albums from a specific browse endpoint (newReleases, idealDiscography, mostStreamed) + pub async fn get_discover_albums( + &self, + endpoint: &str, + genre_ids: Option>, + offset: u32, + limit: u32, + ) -> Result> { + let url = endpoints::build_url(endpoint); + let mut query: Vec<(&str, String)> = vec![]; + + if let Some(gids) = genre_ids { + if !gids.is_empty() { + let ids_str = gids.iter().map(|id| id.to_string()).collect::>().join(","); + query.push(("genre_ids", ids_str)); + } + } + + query.push(("offset", offset.to_string())); + query.push(("limit", limit.to_string())); + + let http_response = self + .http + .get(&url) + .headers(self.authenticated_headers().await?) + .query(&query) + .send() + .await?; + log::info!("[API] get_discover_albums({}) status={}", endpoint, http_response.status()); + let response: serde_json::Value = http_response.json().await?; + + Ok(serde_json::from_value(response)?) + } + /// Get discover playlists with optional tag filter /// Example: tags=label, tags=partner pub async fn get_discover_playlists( diff --git a/src-tauri/src/api/endpoints.rs b/src-tauri/src/api/endpoints.rs index 2e43ac120..1f99aafb5 100644 --- a/src-tauri/src/api/endpoints.rs +++ b/src-tauri/src/api/endpoints.rs @@ -53,6 +53,9 @@ pub mod paths { // Discover (home page content) pub const DISCOVER_INDEX: &str = "/discover/index"; pub const DISCOVER_PLAYLISTS: &str = "/discover/playlists"; + pub const DISCOVER_NEW_RELEASES: &str = "/discover/newReleases"; + pub const DISCOVER_IDEAL_DISCOGRAPHY: &str = "/discover/idealDiscography"; + pub const DISCOVER_MOST_STREAMED: &str = "/discover/mostStreamed"; } /// Build full URL for an endpoint diff --git a/src-tauri/src/commands/search.rs b/src-tauri/src/commands/search.rs index 7d113fd47..205a23fad 100644 --- a/src-tauri/src/commands/search.rs +++ b/src-tauri/src/commands/search.rs @@ -2,7 +2,7 @@ use tauri::State; -use crate::api::{endpoints, endpoints::paths, Album, Artist, ArtistAlbums, DiscoverResponse, DiscoverPlaylistsResponse, LabelDetail, PageArtistResponse, Playlist, ReleasesGridResponse, SearchResultsPage, Track, TracksContainer}; +use crate::api::{endpoints, endpoints::paths, Album, Artist, ArtistAlbums, DiscoverAlbum, DiscoverData, DiscoverResponse, DiscoverPlaylistsResponse, LabelDetail, PageArtistResponse, Playlist, ReleasesGridResponse, SearchResultsPage, Track, TracksContainer}; use crate::api_cache::ApiCacheState; use crate::artist_blacklist::BlacklistState; use crate::AppState; @@ -693,6 +693,34 @@ pub async fn get_discover_playlists( .map_err(|e| e.to_string()) } +/// Get discover albums from a browse endpoint (newReleases, idealDiscography, mostStreamed) +#[tauri::command] +pub async fn get_discover_albums( + endpoint_type: String, + genre_ids: Option>, + offset: Option, + limit: Option, + state: State<'_, AppState>, +) -> Result, String> { + let endpoint = match endpoint_type.as_str() { + "newReleases" => paths::DISCOVER_NEW_RELEASES, + "idealDiscography" => paths::DISCOVER_IDEAL_DISCOGRAPHY, + "mostStreamed" => paths::DISCOVER_MOST_STREAMED, + _ => return Err(format!("Unknown discover endpoint type: {}", endpoint_type)), + }; + + log::debug!( + "Command: get_discover_albums type={} offset={:?} limit={:?}", + endpoint_type, offset, limit + ); + + let client = state.client.read().await; + client + .get_discover_albums(endpoint, genre_ids, offset.unwrap_or(0), limit.unwrap_or(50)) + .await + .map_err(|e| e.to_string()) +} + /// Get artist page (aggregated: bio, top tracks, releases, similar, playlists) #[tauri::command] pub async fn get_artist_page( diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 4f081153a..ab51461c0 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -503,6 +503,7 @@ pub fn run() { commands::get_genres, commands::get_discover_index, commands::get_discover_playlists, + commands::get_discover_albums, commands::get_track, commands::get_artist, commands::get_artist_basic, diff --git a/src/lib/components/VirtualizedFavoritesAlbumGrid.svelte b/src/lib/components/VirtualizedFavoritesAlbumGrid.svelte index 2f7267b83..3c5f9b07c 100644 --- a/src/lib/components/VirtualizedFavoritesAlbumGrid.svelte +++ b/src/lib/components/VirtualizedFavoritesAlbumGrid.svelte @@ -1,7 +1,7 @@ + +
+ +
+
+ +

{$t(titleKey)}

+
+
+
+ + + {#if searchQuery} + + {/if} +
+ +
+ + +
+
+
+ + +
+ {#if isLoading} +
+
+ {#each { length: 12 } as _} +
+
+
+
+
+ {/each} +
+
+ {:else if getFilteredAlbums().length === 0} +
+

{$t('discover.noResults')}

+
+ {:else} + + {/if} +
+
+ + diff --git a/src/lib/components/views/HomeView.svelte b/src/lib/components/views/HomeView.svelte index 4a45d1bdc..cba1ceecf 100644 --- a/src/lib/components/views/HomeView.svelte +++ b/src/lib/components/views/HomeView.svelte @@ -121,6 +121,9 @@ onPlaylistShareQobuz?: (playlistId: number) => void; activeTrackId?: number | null; isPlaybackActive?: boolean; + onNavigateNewReleases?: () => void; + onNavigateIdealDiscography?: () => void; + onNavigateTopAlbums?: () => void; } let { @@ -159,7 +162,10 @@ onPlaylistCopyToLibrary, onPlaylistShareQobuz, activeTrackId = null, - isPlaybackActive = false + isPlaybackActive = false, + onNavigateNewReleases, + onNavigateIdealDiscography, + onNavigateTopAlbums, }: Props = $props(); // Home settings state @@ -882,7 +888,13 @@ {:else if newReleases.length > 0} - + + {#snippet header()} +

{$t('home.newReleases')}

+ {#if onNavigateNewReleases} + + {/if} + {/snippet} {#snippet children()} {#each newReleases as album} {:else if mostStreamed.length > 0} - + + {#snippet header()} +

{$t('home.popularAlbums')}

+ {#if onNavigateTopAlbums} + + {/if} + {/snippet} {#snippet children()} {#each mostStreamed as album} {:else if essentialDiscography.length > 0} - + + {#snippet header()} +

{$t('home.essentialDiscography')}

+ {#if onNavigateIdealDiscography} + + {/if} + {/snippet} {#snippet children()} {#each essentialDiscography as album (album.id)} diff --git a/src/lib/i18n/locales/de.json b/src/lib/i18n/locales/de.json index 582b3504b..0c11ac7ca 100644 --- a/src/lib/i18n/locales/de.json +++ b/src/lib/i18n/locales/de.json @@ -45,6 +45,16 @@ "startListening": "Beginne mit dem Hören", "startListeningDescription": "Spiele Musik oder füge Favoriten hinzu, um Empfehlungen zu aktivieren." }, + "discover": { + "newReleases": "Neuerscheinungen", + "idealDiscography": "Ideale Diskografie", + "topAlbums": "Beliebte Alben", + "loadingMore": "Mehr laden...", + "noResults": "Keine Alben gefunden", + "searchPlaceholder": "Alben suchen...", + "allGenres": "Alle Genres", + "backToHome": "Zurück zur Startseite" + }, "search": { "title": "Suchen", "placeholder": "Alben, Künstler, Titel suchen...", diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index 516155bd9..ecb6f53c4 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -48,6 +48,16 @@ "startListening": "Start Listening", "startListeningDescription": "Play music or add favorites to activate recommendations." }, + "discover": { + "newReleases": "New Releases", + "idealDiscography": "Ideal Discography", + "topAlbums": "Top Albums", + "loadingMore": "Loading more...", + "noResults": "No albums found", + "searchPlaceholder": "Search albums...", + "allGenres": "All Genres", + "backToHome": "Back to Home" + }, "search": { "title": "Search", "placeholder": "Search albums, artists, tracks...", diff --git a/src/lib/i18n/locales/es.json b/src/lib/i18n/locales/es.json index 1d791f76c..ded3fc4cc 100644 --- a/src/lib/i18n/locales/es.json +++ b/src/lib/i18n/locales/es.json @@ -48,6 +48,16 @@ "startListening": "Empieza a Escuchar", "startListeningDescription": "Reproduce música o agrega favoritos para activar recomendaciones." }, + "discover": { + "newReleases": "Novedades", + "idealDiscography": "Discografía Ideal", + "topAlbums": "Álbumes Populares", + "loadingMore": "Cargando más...", + "noResults": "No se encontraron álbumes", + "searchPlaceholder": "Buscar álbumes...", + "allGenres": "Todos los Géneros", + "backToHome": "Volver al Inicio" + }, "search": { "title": "Buscar", "placeholder": "Buscar álbumes, artistas, pistas...", diff --git a/src/lib/i18n/locales/fr.json b/src/lib/i18n/locales/fr.json index 4fe65e3cf..342d7b288 100644 --- a/src/lib/i18n/locales/fr.json +++ b/src/lib/i18n/locales/fr.json @@ -45,6 +45,16 @@ "startListening": "Commencer l'écoute", "startListeningDescription": "Lisez de la musique ou ajoutez des favoris pour activer les recommandations." }, + "discover": { + "newReleases": "Nouvelles sorties", + "idealDiscography": "Discographie idéale", + "topAlbums": "Albums populaires", + "loadingMore": "Chargement...", + "noResults": "Aucun album trouvé", + "searchPlaceholder": "Rechercher des albums...", + "allGenres": "Tous les genres", + "backToHome": "Retour à l'accueil" + }, "search": { "title": "Recherche", "placeholder": "Rechercher des albums, des artistes, des pistes...", diff --git a/src/lib/stores/navigationStore.ts b/src/lib/stores/navigationStore.ts index 267c7ce22..5d75791e1 100644 --- a/src/lib/stores/navigationStore.ts +++ b/src/lib/stores/navigationStore.ts @@ -22,7 +22,10 @@ export type ViewType = | 'favorites-tracks' | 'favorites-albums' | 'favorites-artists' - | 'favorites-playlists'; + | 'favorites-playlists' + | 'discover-new-releases' + | 'discover-ideal-discography' + | 'discover-top-albums'; export type FavoritesTab = 'tracks' | 'albums' | 'artists' | 'playlists'; // Navigation state diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 24cadd79b..31be7e27d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -314,6 +314,7 @@ import LocalLibraryView from '$lib/components/views/LocalLibraryView.svelte'; import PlaylistManagerView from '$lib/components/views/PlaylistManagerView.svelte'; import BlacklistManagerView from '$lib/components/views/BlacklistManagerView.svelte'; + import DiscoverBrowseView from '$lib/components/views/DiscoverBrowseView.svelte'; // Overlays import QueuePanel from '$lib/components/QueuePanel.svelte'; @@ -3114,6 +3115,9 @@ onPlaylistShareQobuz={sharePlaylistQobuzLinkById} activeTrackId={currentTrack?.id ?? null} isPlaybackActive={isPlaying} + onNavigateNewReleases={() => navigateTo('discover-new-releases')} + onNavigateIdealDiscography={() => navigateTo('discover-ideal-discography')} + onNavigateTopAlbums={() => navigateTo('discover-top-albums')} /> {/if} {:else if activeView === 'search'} @@ -3395,6 +3399,64 @@ onBack={navGoBack} onArtistSelect={handleArtistClick} /> + {:else if activeView === 'discover-new-releases'} + + {:else if activeView === 'discover-ideal-discography'} + + {:else if activeView === 'discover-top-albums'} + {/if}