mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-24 06:30:56 +02:00
Merge pull request #5457 from cvium/fix_double_artist
This commit is contained in:
commit
a037e30b41
|
@ -1,6 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities.Audio
|
namespace MediaBrowser.Controller.Entities.Audio
|
||||||
{
|
{
|
||||||
|
@ -23,15 +25,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
public static IEnumerable<string> GetAllArtists<T>(this T item)
|
public static IEnumerable<string> GetAllArtists<T>(this T item)
|
||||||
where T : IHasArtist, IHasAlbumArtist
|
where T : IHasArtist, IHasAlbumArtist
|
||||||
{
|
{
|
||||||
foreach (var i in item.AlbumArtists)
|
return item.AlbumArtists.Concat(item.Artists).DistinctNames();
|
||||||
{
|
|
||||||
yield return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var i in item.Artists)
|
|
||||||
{
|
|
||||||
yield return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@ namespace MediaBrowser.Controller.Library
|
||||||
{
|
{
|
||||||
public static class NameExtensions
|
public static class NameExtensions
|
||||||
{
|
{
|
||||||
|
public static IEnumerable<string> DistinctNames(this IEnumerable<string> names)
|
||||||
|
=> names.GroupBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase)
|
||||||
|
.Select(x => x.First());
|
||||||
|
|
||||||
private static string RemoveDiacritics(string? name)
|
private static string RemoveDiacritics(string? name)
|
||||||
{
|
{
|
||||||
if (name == null)
|
if (name == null)
|
||||||
|
@ -19,9 +23,5 @@ namespace MediaBrowser.Controller.Library
|
||||||
|
|
||||||
return name.RemoveDiacritics();
|
return name.RemoveDiacritics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> DistinctNames(this IEnumerable<string> names)
|
|
||||||
=> names.GroupBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase)
|
|
||||||
.Select(x => x.First());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue