diff options
Diffstat (limited to 'MediaBrowser.Controller')
5 files changed, 72 insertions, 15 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index b7322494d6..10fa4adad4 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1894,12 +1894,12 @@ namespace MediaBrowser.Controller.Entities return video.RefreshMetadata(newOptions, cancellationToken); } - public string GetEtag() + public string GetEtag(User user) { - return string.Join("|", GetEtagValues().ToArray()).GetMD5().ToString("N"); + return string.Join("|", GetEtagValues(user).ToArray()).GetMD5().ToString("N"); } - protected virtual List<string> GetEtagValues() + protected virtual List<string> GetEtagValues(User user) { return new List<string> { diff --git a/MediaBrowser.Controller/Entities/ICollectionFolder.cs b/MediaBrowser.Controller/Entities/ICollectionFolder.cs index 656aa37ce6..f46d7ed6f3 100644 --- a/MediaBrowser.Controller/Entities/ICollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/ICollectionFolder.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace MediaBrowser.Controller.Entities { @@ -9,6 +10,8 @@ namespace MediaBrowser.Controller.Entities { string CollectionType { get; } string Path { get; } + string Name { get; } + Guid Id { get; } IEnumerable<string> PhysicalLocations { get; } } } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 63ce223afe..a6d123fe86 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -247,7 +247,16 @@ namespace MediaBrowser.Controller.Entities return GetFavoriteSongs(queryParent, user, query); default: - return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), queryParent, query); + { + if (queryParent is UserView) + { + return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), queryParent, query); + } + else + { + return GetResult(queryParent.GetChildren(user, true), queryParent, query); + } + } } } diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index b2acdc7ea5..6973dce64f 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -2,40 +2,78 @@ using MoreLinq; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; namespace MediaBrowser.Controller.Library { public static class NameExtensions { - public static bool AreEqual(string name1, string name2) + public static bool AreEqual(string x, string y) { - name1 = NormalizeForComparison(name1); - name2 = NormalizeForComparison(name2); + if (string.IsNullOrWhiteSpace(x) && string.IsNullOrWhiteSpace(y)) + { + return true; + } - return string.Equals(name1, name2, StringComparison.OrdinalIgnoreCase); + return string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) == 0; } - public static bool EqualsAny(IEnumerable<string> names, string name) + public static bool EqualsAny(IEnumerable<string> names, string x) { - name = NormalizeForComparison(name); + x = NormalizeForComparison(x); - return names.Any(i => string.Equals(NormalizeForComparison(i), name, StringComparison.OrdinalIgnoreCase)); + return names.Any(y => string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) == 0); } private static string NormalizeForComparison(string name) { - if (string.IsNullOrWhiteSpace(name)) + if (name == null) + { + return string.Empty; + } + + return name; + //return name.RemoveDiacritics(); + } + + private static string RemoveDiacritics(string name) + { + if (name == null) { return string.Empty; } + //return name; return name.RemoveDiacritics(); } public static IEnumerable<string> DistinctNames(this IEnumerable<string> names) { - return names.DistinctBy(NormalizeForComparison, StringComparer.OrdinalIgnoreCase); + return names.DistinctBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase); + } + } + + class TextComparer : IComparer<string>, IEqualityComparer<string> + { + public int Compare(string x, string y) + { + if (string.IsNullOrWhiteSpace(x) && string.IsNullOrWhiteSpace(y)) + { + return 0; + } + + return string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace); + } + + public bool Equals(string x, string y) + { + return Compare(x, y) == 0; + } + + public int GetHashCode(string obj) + { + return (obj ?? string.Empty).GetHashCode(); } } } diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index f306518df4..aa5376ec3f 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -107,7 +107,7 @@ namespace MediaBrowser.Controller.Persistence /// </summary> /// <param name="type">The type.</param> /// <returns>IEnumerable{Guid}.</returns> - IEnumerable<Guid> GetItemsOfType(Type type); + IEnumerable<Guid> GetItemIdsOfType(Type type); /// <summary> /// Saves the children. @@ -133,6 +133,13 @@ namespace MediaBrowser.Controller.Persistence /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> Task SaveMediaStreams(Guid id, IEnumerable<MediaStream> streams, CancellationToken cancellationToken); + + /// <summary> + /// Gets the type of the items of. + /// </summary> + /// <param name="type">The type.</param> + /// <returns>IEnumerable<BaseItem>.</returns> + IEnumerable<BaseItem> GetItemsOfType(Type type); } } |
