aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheguymadmax <171496228+theguymadmax@users.noreply.github.com>2026-01-28 12:11:23 -0500
committerBond_009 <bond.009@outlook.com>2026-01-28 12:11:23 -0500
commitec4744709df1664f263937ae41baadc48d7d6c9b (patch)
tree74936d58d7d3688926c4413de32d03493bbb715b
parent91dd146c0f57664e7d4a8e63542943eb8d6504e9 (diff)
Backport pull request #15816 from jellyfin/release-10.11.z
Fix artist display order Original-merge: a2b1936e73f6638bf07d5e1afd339a1e4404027a Merged-by: joshuaboniface <joshua@boniface.me> Backported-by: Bond_009 <bond.009@outlook.com>
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs53
-rw-r--r--Jellyfin.Server.Implementations/Item/BaseItemRepository.cs17
2 files changed, 35 insertions, 35 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index c5dc3b054..b392340f7 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1051,16 +1051,16 @@ namespace Emby.Server.Implementations.Dto
// Include artists that are not in the database yet, e.g., just added via metadata editor
// var foundArtists = artistItems.Items.Select(i => i.Item1.Name).ToList();
- dto.ArtistItems = _libraryManager.GetArtists([.. hasArtist.Artists.Where(e => !string.IsNullOrWhiteSpace(e))])
- .Where(e => e.Value.Length > 0)
- .Select(i =>
- {
- return new NameGuidPair
- {
- Name = i.Key,
- Id = i.Value.First().Id
- };
- }).Where(i => i is not null).ToArray();
+ var artistsLookup = _libraryManager.GetArtists([.. hasArtist.Artists.Where(e => !string.IsNullOrWhiteSpace(e))]);
+
+ dto.ArtistItems = hasArtist.Artists
+ .Where(name => !string.IsNullOrWhiteSpace(name))
+ .Distinct()
+ .Select(name => artistsLookup.TryGetValue(name, out var artists) && artists.Length > 0
+ ? new NameGuidPair { Name = name, Id = artists[0].Id }
+ : null)
+ .Where(item => item is not null)
+ .ToArray();
}
if (item is IHasAlbumArtist hasAlbumArtist)
@@ -1085,31 +1085,16 @@ namespace Emby.Server.Implementations.Dto
// })
// .ToList();
- dto.AlbumArtists = hasAlbumArtist.AlbumArtists
- // .Except(foundArtists, new DistinctNameComparer())
- .Select(i =>
- {
- // This should not be necessary but we're seeing some cases of it
- if (string.IsNullOrEmpty(i))
- {
- return null;
- }
-
- var artist = _libraryManager.GetArtist(i, new DtoOptions(false)
- {
- EnableImages = false
- });
- if (artist is not null)
- {
- return new NameGuidPair
- {
- Name = artist.Name,
- Id = artist.Id
- };
- }
+ var albumArtistsLookup = _libraryManager.GetArtists([.. hasAlbumArtist.AlbumArtists.Where(e => !string.IsNullOrWhiteSpace(e))]);
- return null;
- }).Where(i => i is not null).ToArray();
+ dto.AlbumArtists = hasAlbumArtist.AlbumArtists
+ .Where(name => !string.IsNullOrWhiteSpace(name))
+ .Distinct()
+ .Select(name => albumArtistsLookup.TryGetValue(name, out var albumArtists) && albumArtists.Length > 0
+ ? new NameGuidPair { Name = name, Id = albumArtists[0].Id }
+ : null)
+ .Where(item => item is not null)
+ .ToArray();
}
// Add video info
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
index 90aa3a22e..43a3cdf78 100644
--- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
+++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
@@ -2682,6 +2682,21 @@ public sealed class BaseItemRepository
.Where(e => artistNames.Contains(e.Name))
.ToArray();
- return artists.GroupBy(e => e.Name).ToDictionary(e => e.Key!, e => e.Select(f => DeserializeBaseItem(f)).Where(dto => dto is not null).Cast<MusicArtist>().ToArray());
+ var lookup = artists
+ .GroupBy(e => e.Name!)
+ .ToDictionary(
+ g => g.Key,
+ g => g.Select(f => DeserializeBaseItem(f)).Where(dto => dto is not null).Cast<MusicArtist>().ToArray());
+
+ var result = new Dictionary<string, MusicArtist[]>(artistNames.Count);
+ foreach (var name in artistNames)
+ {
+ if (lookup.TryGetValue(name, out var artistArray))
+ {
+ result[name] = artistArray;
+ }
+ }
+
+ return result;
}
}