Use distinct for artists to avoid double refreshing
This commit is contained in:
parent
94db751f4b
commit
c5a870051a
|
@ -1,6 +1,8 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Library;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
|
@ -23,15 +25,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
public static IEnumerable<string> GetAllArtists<T>(this T item)
|
||||
where T : IHasArtist, IHasAlbumArtist
|
||||
{
|
||||
foreach (var i in item.AlbumArtists)
|
||||
{
|
||||
yield return i;
|
||||
}
|
||||
|
||||
foreach (var i in item.Artists)
|
||||
{
|
||||
yield return i;
|
||||
}
|
||||
return item.AlbumArtists.Concat(item.Artists).DistinctNames();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ namespace MediaBrowser.Controller.Library
|
|||
{
|
||||
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)
|
||||
{
|
||||
if (name == null)
|
||||
|
@ -19,9 +23,5 @@ namespace MediaBrowser.Controller.Library
|
|||
|
||||
return name.RemoveDiacritics();
|
||||
}
|
||||
|
||||
public static IEnumerable<string> DistinctNames(this IEnumerable<string> names)
|
||||
=> names.GroupBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(x => x.First());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user