mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
fix: use album artist for folder organization in Album download mode
This commit is contained in:
@@ -183,7 +183,35 @@ public abstract class BaseDownloadService : IDownloadService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get metadata
|
// 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)
|
if (song == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Song not found");
|
throw new Exception("Song not found");
|
||||||
|
|||||||
@@ -229,8 +229,8 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
int trackIndex = 1;
|
int trackIndex = 1;
|
||||||
foreach (var track in tracksData.EnumerateArray())
|
foreach (var track in tracksData.EnumerateArray())
|
||||||
{
|
{
|
||||||
// Pass the index as fallback for track_position (Deezer doesn't include it in album tracks)
|
// Pass the album artist to ensure proper folder organization
|
||||||
var song = ParseDeezerTrack(track, trackIndex);
|
var song = ParseDeezerTrack(track, trackIndex, album.Artist);
|
||||||
if (ShouldIncludeSong(song))
|
if (ShouldIncludeSong(song))
|
||||||
{
|
{
|
||||||
album.Songs.Add(song);
|
album.Songs.Add(song);
|
||||||
@@ -283,7 +283,7 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
return albums;
|
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();
|
var externalId = track.GetProperty("id").GetInt64().ToString();
|
||||||
|
|
||||||
@@ -321,6 +321,7 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
albumForCover.TryGetProperty("cover_medium", out var cover)
|
albumForCover.TryGetProperty("cover_medium", out var cover)
|
||||||
? cover.GetString()
|
? cover.GetString()
|
||||||
: null,
|
: null,
|
||||||
|
AlbumArtist = albumArtist,
|
||||||
IsLocal = false,
|
IsLocal = false,
|
||||||
ExternalProvider = "deezer",
|
ExternalProvider = "deezer",
|
||||||
ExternalId = externalId,
|
ExternalId = externalId,
|
||||||
|
|||||||
Reference in New Issue
Block a user