jellyfin/MediaBrowser.Controller/Library/NameExtensions.cs

28 lines
692 B
C#
Raw Normal View History

2020-09-20 12:02:41 +00:00
#nullable enable
#pragma warning disable CS1591
using System;
2018-12-27 23:27:57 +00:00
using System.Collections.Generic;
2020-03-24 15:12:06 +00:00
using System.Linq;
2018-12-27 23:27:57 +00:00
using MediaBrowser.Controller.Extensions;
namespace MediaBrowser.Controller.Library
{
public static class NameExtensions
{
2020-09-20 12:02:41 +00:00
private static string RemoveDiacritics(string? name)
2018-12-27 23:27:57 +00:00
{
if (name == null)
{
return string.Empty;
}
return name.RemoveDiacritics();
}
public static IEnumerable<string> DistinctNames(this IEnumerable<string> names)
2019-02-02 11:27:06 +00:00
=> names.GroupBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase)
.Select(x => x.First());
2018-12-27 23:27:57 +00:00
}
}