From 994cc020f8cc3ff2fa566dce5a9df096bcaabd31 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 19 Oct 2015 22:06:05 -0400 Subject: [PATCH] restore video grouping feature --- MediaBrowser.Controller/Entities/User.cs | 1 + .../Channels/ChannelManager.cs | 17 +++++++++++------ .../Library/UserManager.cs | 3 ++- .../Library/UserViewManager.cs | 16 ++++++++-------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index bf0f7a2a8e..a9e314ede1 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -20,6 +20,7 @@ namespace MediaBrowser.Controller.Entities { public static IUserManager UserManager { get; set; } public static IXmlSerializer XmlSerializer { get; set; } + public bool EnableUserViews { get; set; } /// /// From now on all user paths will be Id-based. diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index 70005725fd..99d2a03f9b 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -433,6 +433,7 @@ namespace MediaBrowser.Server.Implementations.Channels } var item = _libraryManager.GetItemById(id) as Channel; + var channelId = channelInfo.Name.GetMD5().ToString("N"); if (item == null) { @@ -443,13 +444,12 @@ namespace MediaBrowser.Server.Implementations.Channels DateCreated = _fileSystem.GetCreationTimeUtc(path), DateModified = _fileSystem.GetLastWriteTimeUtc(path), Path = path, - ChannelId = channelInfo.Name.GetMD5().ToString("N") + ChannelId = channelId }; isNew = true; } - var channelId = channelInfo.Name.GetMD5().ToString("N"); if (!string.Equals(item.ChannelId, channelId, StringComparison.OrdinalIgnoreCase)) { isNew = true; @@ -459,7 +459,7 @@ namespace MediaBrowser.Server.Implementations.Channels item.Overview = channelInfo.Description; item.HomePageUrl = channelInfo.HomePageUrl; - if (string.IsNullOrEmpty(item.Name)) + if (string.IsNullOrWhiteSpace(item.Name)) { item.Name = channelInfo.Name; } @@ -497,9 +497,14 @@ namespace MediaBrowser.Server.Implementations.Channels public IEnumerable GetAllChannelFeatures() { - return GetAllChannels() - .Select(GetChannelEntity) - .OrderBy(i => i.SortName) + var inputItems = _libraryManager.GetItems(new InternalItemsQuery + { + IncludeItemTypes = new[] { typeof(Channel).Name }, + SortBy = new[] { ItemSortBy.SortName } + + }).Items; + + return inputItems .Select(i => GetChannelFeatures(i.Id.ToString("N"))); } diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 3ef625db67..3c29cf15d5 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -707,7 +707,8 @@ namespace MediaBrowser.Server.Implementations.Library Id = Guid.NewGuid(), DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow, - UsesIdForConfigurationPath = true + UsesIdForConfigurationPath = true, + EnableUserViews = true }; } diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index ffbc89c940..c2938475c6 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -61,7 +61,9 @@ namespace MediaBrowser.Server.Implementations.Library var list = new List(); - if (_config.Configuration.EnableUserViews) + var enableUserViews = _config.Configuration.EnableUserViews || user.EnableUserViews; + + if (enableUserViews) { foreach (var folder in standaloneFolders) { @@ -118,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.Library if (parents.Count > 0) { - list.Add(await GetUserView(parents, list, CollectionType.TvShows, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, list, CollectionType.TvShows, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false)); } parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Music, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user))) @@ -126,7 +128,7 @@ namespace MediaBrowser.Server.Implementations.Library if (parents.Count > 0) { - list.Add(await GetUserView(parents, list, CollectionType.Music, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, list, CollectionType.Music, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false)); } parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user))) @@ -134,7 +136,7 @@ namespace MediaBrowser.Server.Implementations.Library if (parents.Count > 0) { - list.Add(await GetUserView(parents, list, CollectionType.Movies, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, list, CollectionType.Movies, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false)); } parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Games, StringComparison.OrdinalIgnoreCase)) @@ -142,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Library if (parents.Count > 0) { - list.Add(await GetUserView(parents, list, CollectionType.Games, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, list, CollectionType.Games, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false)); } if (user.Configuration.DisplayFoldersView) @@ -207,10 +209,8 @@ namespace MediaBrowser.Server.Implementations.Library return GetUserSubView(name, parentId, type, sortName, cancellationToken); } - public async Task GetUserView(List parents, List currentViews, string viewType, string sortName, User user, CancellationToken cancellationToken) + private async Task GetUserView(List parents, List currentViews, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken) { - var enableUserViews = _config.Configuration.EnableUserViews; - if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase))) { var parentId = parents[0].Id;