From a2c0b13c213da86c83228c6686ec5d1e6d83d7f7 Mon Sep 17 00:00:00 2001 From: V1ck3s Date: Mon, 8 Dec 2025 23:22:41 +0100 Subject: [PATCH] fix: getCoverArt now handles album and artist IDs, not just tracks --- octo-fiesta/Controllers/SubSonicController.cs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/octo-fiesta/Controllers/SubSonicController.cs b/octo-fiesta/Controllers/SubSonicController.cs index 04a89f6..280a5c2 100644 --- a/octo-fiesta/Controllers/SubSonicController.cs +++ b/octo-fiesta/Controllers/SubSonicController.cs @@ -278,12 +278,40 @@ public class SubsonicController : ControllerBase } } - // Cover externe - récupérer l'URL depuis les métadonnées + // Cover externe - essayer track, album, puis artist + string? coverUrl = null; + + // Essayer en tant que track var song = await _metadataService.GetSongAsync(provider!, externalId!); if (song?.CoverArtUrl != null) + { + coverUrl = song.CoverArtUrl; + } + + // Si pas trouvé, essayer en tant qu'album + if (coverUrl == null) + { + var album = await _metadataService.GetAlbumAsync(provider!, externalId!); + if (album?.CoverArtUrl != null) + { + coverUrl = album.CoverArtUrl; + } + } + + // Si pas trouvé, essayer en tant qu'artiste + if (coverUrl == null) + { + var artist = await _metadataService.GetArtistAsync(provider!, externalId!); + if (artist?.ImageUrl != null) + { + coverUrl = artist.ImageUrl; + } + } + + if (coverUrl != null) { // Proxy l'image - var response = await _httpClient.GetAsync(song.CoverArtUrl); + var response = await _httpClient.GetAsync(coverUrl); if (response.IsSuccessStatusCode) { var imageBytes = await response.Content.ReadAsByteArrayAsync();