From 270e423accc15a4be28c2c6f809035dbc60e21f4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 May 2016 13:11:49 -0400 Subject: [PATCH 1/2] update dialogs --- MediaBrowser.Controller/Entities/UserViewBuilder.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index a4fe2e178..5ddd9d722 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -444,7 +444,10 @@ namespace MediaBrowser.Controller.Entities query.ParentId = parent.Id; query.SetUser(user); - query.IncludeItemTypes = new[] { typeof(Movie).Name, typeof(BoxSet).Name }; + if (query.IncludeItemTypes.Length == 0) + { + query.IncludeItemTypes = new[] { typeof(Movie).Name, typeof(BoxSet).Name }; + } return _libraryManager.GetItemsResult(query); } @@ -601,7 +604,10 @@ namespace MediaBrowser.Controller.Entities query.ParentId = parent.Id; query.SetUser(user); - query.IncludeItemTypes = new[] { typeof(Series).Name, typeof(Season).Name, typeof(Episode).Name }; + if (query.IncludeItemTypes.Length == 0) + { + query.IncludeItemTypes = new[] { typeof(Series).Name, typeof(Season).Name, typeof(Episode).Name }; + } return _libraryManager.GetItemsResult(query); } From e1718a5fa6b8f1dc30c60f7b2d649c320679a1b7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 May 2016 14:20:08 -0400 Subject: [PATCH 2/2] optimize dlna views --- .../Entities/UserViewBuilder.cs | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 5ddd9d722..b88e8493d 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -250,9 +250,16 @@ namespace MediaBrowser.Controller.Entities { if (query.Recursive) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }, i => FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - return PostFilterAndSort(items, parent, null, query); + if (query.IncludeItemTypes.Length == 0) + { + query.IncludeItemTypes = new[] { typeof(MusicArtist).Name, typeof(MusicAlbum).Name, typeof(Audio.Audio).Name, typeof(MusicVideo).Name }; + } + + return _libraryManager.GetItemsResult(query); } var list = new List(); @@ -543,8 +550,13 @@ namespace MediaBrowser.Controller.Entities private async Task> GetMovieGenres(Folder parent, User user, InternalItemsQuery query) { - var tasks = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }) - .Where(i => i is Movie) + var tasks = parent.QueryRecursive(new InternalItemsQuery(user) + { + IncludeItemTypes = new[] { typeof(Movie).Name }, + Recursive = true, + EnableTotalRecordCount = false + + }).Items .SelectMany(i => i.Genres) .DistinctNames() .Select(i => @@ -681,8 +693,13 @@ namespace MediaBrowser.Controller.Entities private async Task> GetTvGenres(Folder parent, User user, InternalItemsQuery query) { - var tasks = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }) - .OfType() + var tasks = parent.QueryRecursive(new InternalItemsQuery(user) + { + IncludeItemTypes = new[] { typeof(Series).Name }, + Recursive = true, + EnableTotalRecordCount = false + + }).Items .SelectMany(i => i.Genres) .DistinctNames() .Select(i => @@ -1935,26 +1952,6 @@ namespace MediaBrowser.Controller.Entities return parent.GetRecursiveChildren(user); } - private IEnumerable GetRecursiveChildren(Folder parent, User user, IEnumerable viewTypes, Func filter) - { - if (parent == null || parent is UserView) - { - if (user == null) - { - return GetMediaFolders(null, viewTypes).SelectMany(i => i.GetRecursiveChildren(filter)); - } - - return GetMediaFolders(user, viewTypes).SelectMany(i => i.GetRecursiveChildren(user, filter)); - } - - if (user == null) - { - return parent.GetRecursiveChildren(filter); - } - - return parent.GetRecursiveChildren(user, filter); - } - private async Task> GetLiveTvView(Folder queryParent, User user, InternalItemsQuery query) { if (query.Recursive)