diff --git a/octo-fiesta/Services/Common/BaseDownloadService.cs b/octo-fiesta/Services/Common/BaseDownloadService.cs index c37f309..2b96507 100644 --- a/octo-fiesta/Services/Common/BaseDownloadService.cs +++ b/octo-fiesta/Services/Common/BaseDownloadService.cs @@ -183,7 +183,35 @@ public abstract class BaseDownloadService : IDownloadService try { // Get metadata - var song = await MetadataService.GetSongAsync(externalProvider, externalId); + // In Album mode, fetch the full album first to ensure AlbumArtist is correctly set + Song? song = null; + + if (SubsonicSettings.DownloadMode == DownloadMode.Album) + { + // First try to get the song to extract album ID + var tempSong = await MetadataService.GetSongAsync(externalProvider, externalId); + if (tempSong != null && !string.IsNullOrEmpty(tempSong.AlbumId)) + { + var albumExternalId = ExtractExternalIdFromAlbumId(tempSong.AlbumId); + if (!string.IsNullOrEmpty(albumExternalId)) + { + // Get full album with correct AlbumArtist + var album = await MetadataService.GetAlbumAsync(externalProvider, albumExternalId); + if (album != null) + { + // Find the track in the album + song = album.Songs.FirstOrDefault(s => s.ExternalId == externalId); + } + } + } + } + + // Fallback to individual song fetch if not in Album mode or album fetch failed + if (song == null) + { + song = await MetadataService.GetSongAsync(externalProvider, externalId); + } + if (song == null) { throw new Exception("Song not found"); diff --git a/octo-fiesta/Services/Deezer/DeezerMetadataService.cs b/octo-fiesta/Services/Deezer/DeezerMetadataService.cs index 60394cd..43aa38c 100644 --- a/octo-fiesta/Services/Deezer/DeezerMetadataService.cs +++ b/octo-fiesta/Services/Deezer/DeezerMetadataService.cs @@ -229,8 +229,8 @@ public class DeezerMetadataService : IMusicMetadataService int trackIndex = 1; foreach (var track in tracksData.EnumerateArray()) { - // Pass the index as fallback for track_position (Deezer doesn't include it in album tracks) - var song = ParseDeezerTrack(track, trackIndex); + // Pass the album artist to ensure proper folder organization + var song = ParseDeezerTrack(track, trackIndex, album.Artist); if (ShouldIncludeSong(song)) { album.Songs.Add(song); @@ -283,7 +283,7 @@ public class DeezerMetadataService : IMusicMetadataService return albums; } - private Song ParseDeezerTrack(JsonElement track, int? fallbackTrackNumber = null) + private Song ParseDeezerTrack(JsonElement track, int? fallbackTrackNumber = null, string? albumArtist = null) { var externalId = track.GetProperty("id").GetInt64().ToString(); @@ -321,6 +321,7 @@ public class DeezerMetadataService : IMusicMetadataService albumForCover.TryGetProperty("cover_medium", out var cover) ? cover.GetString() : null, + AlbumArtist = albumArtist, IsLocal = false, ExternalProvider = "deezer", ExternalId = externalId,