From abf9809a1d1b18cda1b1455a51b57689ee254f0d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 15:25:54 -0400 Subject: [PATCH] fix playlists empty with dlna --- .../Entities/InternalItemsQuery.cs | 5 +++ .../Entities/UserViewBuilder.cs | 33 +++++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 5236b0a27..ae38f6143 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -181,6 +181,11 @@ namespace MediaBrowser.Controller.Entities public InternalItemsQuery(User user) : this() + { + SetUser(user); + } + + public void SetUser(User user) { if (user != null) { diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index ba496fa5c..caf160f02 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -125,13 +125,13 @@ namespace MediaBrowser.Controller.Entities case CollectionType.HomeVideos: case CollectionType.Games: case CollectionType.MusicVideos: - { - if (query.Recursive) { - return GetResult(queryParent.GetRecursiveChildren(user, true), queryParent, query); + if (query.Recursive) + { + return GetResult(queryParent.GetRecursiveChildren(user, true), queryParent, query); + } + return GetResult(queryParent.GetChildren(user, true), queryParent, query); } - return GetResult(queryParent.GetChildren(user, true), queryParent, query); - } case CollectionType.Folders: return GetResult(user.RootFolder.GetChildren(user, true), queryParent, query); @@ -140,7 +140,7 @@ namespace MediaBrowser.Controller.Entities return await GetPlaylistsView(queryParent, user, query).ConfigureAwait(false); case CollectionType.BoxSets: - return await GetBoxsetView(queryParent, user, query).ConfigureAwait(false); + return GetBoxsetView(queryParent, user, query); case CollectionType.TvShows: return await GetTvView(queryParent, user, query).ConfigureAwait(false); @@ -206,7 +206,7 @@ namespace MediaBrowser.Controller.Entities return GetMusicLatest(queryParent, user, query); case SpecialFolder.MusicPlaylists: - return await GetMusicPlaylists(queryParent, user, query).ConfigureAwait(false); + return GetMusicPlaylists(queryParent, user, query); case SpecialFolder.MusicAlbums: return GetMusicAlbums(queryParent, user, query); @@ -353,12 +353,14 @@ namespace MediaBrowser.Controller.Entities return GetResult(artists, parent, query); } - private Task> GetMusicPlaylists(Folder parent, User user, InternalItemsQuery query) + private QueryResult GetMusicPlaylists(Folder parent, User user, InternalItemsQuery query) { - query.IncludeItemTypes = new[] { "Playlist" }; + query.ParentId = null; + query.IncludeItemTypes = new[] { typeof(Playlist).Name }; + query.SetUser(user); query.Recursive = true; - return parent.GetItems(query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetMusicAlbums(Folder parent, User user, InternalItemsQuery query) @@ -559,11 +561,14 @@ namespace MediaBrowser.Controller.Entities return GetResult(_playlistManager.GetPlaylists(user.Id.ToString("N")), parent, query); } - private async Task> GetBoxsetView(Folder parent, User user, InternalItemsQuery query) + private QueryResult GetBoxsetView(Folder parent, User user, InternalItemsQuery query) { - var collections = _collectionManager.GetCollections(user); + query.ParentId = null; + query.IncludeItemTypes = new[] { typeof(BoxSet).Name }; + query.SetUser(user); + query.Recursive = true; - return GetResult(collections, parent, query); + return _libraryManager.GetItemsResult(query); } private async Task> GetTvView(Folder parent, User user, InternalItemsQuery query) @@ -1735,7 +1740,7 @@ namespace MediaBrowser.Controller.Entities if (query.SeriesStatuses.Length > 0) { - var ok = new[] { item }.OfType().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); + var ok = new[] { item }.OfType().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); if (!ok) { return false;