optimize dlna queries
This commit is contained in:
parent
abf9809a1d
commit
bb5a17780c
|
@ -310,14 +310,14 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetMusicGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetMusicGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Music, CollectionType.MusicVideos })
|
query.Recursive = true;
|
||||||
.Where(i => !i.IsFolder)
|
query.ParentId = queryParent.Id;
|
||||||
.Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase))
|
query.Genres = new[] { displayParent.Name };
|
||||||
.OfType<IHasAlbumArtist>();
|
query.SetUser(user);
|
||||||
|
|
||||||
var artists = _libraryManager.GetAlbumArtists(items);
|
query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name };
|
||||||
|
|
||||||
return GetResult(artists, queryParent, query);
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMusicAlbumArtists(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMusicAlbumArtists(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -365,16 +365,24 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMusicAlbums(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMusicAlbums(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }, i => i is MusicAlbum && FilterItem(i, query));
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name };
|
||||||
|
|
||||||
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMusicSongs(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMusicSongs(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }, i => i is Audio.Audio && FilterItem(i, query));
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
query.IncludeItemTypes = new[] { typeof(Audio.Audio).Name };
|
||||||
|
|
||||||
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMusicLatest(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMusicLatest(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -398,20 +406,24 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetFavoriteSongs(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetFavoriteSongs(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
query.IsFavorite = true;
|
query.IsFavorite = true;
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Audio.Audio).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music }, i => i is Audio.Audio && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetFavoriteAlbums(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetFavoriteAlbums(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
query.IsFavorite = true;
|
query.IsFavorite = true;
|
||||||
|
query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music }, i => i is MusicAlbum && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> FindPlaylists(Folder parent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> FindPlaylists(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -430,19 +442,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
if (query.Recursive)
|
if (query.Recursive)
|
||||||
{
|
{
|
||||||
var recursiveItems = GetRecursiveChildren(parent, user,
|
query.Recursive = true;
|
||||||
new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty })
|
query.ParentId = parent.Id;
|
||||||
.Where(i => i is Movie || i is BoxSet);
|
query.SetUser(user);
|
||||||
|
|
||||||
//var collections = _collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user).ToList();
|
query.IncludeItemTypes = new[] { typeof(Movie).Name, typeof(BoxSet).Name };
|
||||||
|
|
||||||
//if (collections.Count > 0)
|
return _libraryManager.GetItemsResult(query);
|
||||||
//{
|
|
||||||
// recursiveItems.AddRange(_collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user));
|
|
||||||
// recursiveItems = recursiveItems.DistinctBy(i => i.Id).ToList();
|
|
||||||
//}
|
|
||||||
|
|
||||||
return GetResult(recursiveItems, parent, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = new List<BaseItem>();
|
var list = new List<BaseItem>();
|
||||||
|
@ -459,43 +465,51 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetFavoriteMovies(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetFavoriteMovies(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
query.IsFavorite = true;
|
query.IsFavorite = true;
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetFavoriteSeries(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetFavoriteSeries(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
query.IsFavorite = true;
|
query.IsFavorite = true;
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Series).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Series && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetFavoriteEpisodes(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetFavoriteEpisodes(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
query.IsFavorite = true;
|
query.IsFavorite = true;
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Episode).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Episode && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMovieMovies(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMovieMovies(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query));
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
||||||
|
|
||||||
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMovieCollections(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMovieCollections(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is BoxSet && FilterItem(i, query));
|
return GetBoxsetView(parent, user, query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMovieLatest(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMovieLatest(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -503,9 +517,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName };
|
query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName };
|
||||||
query.SortOrder = SortOrder.Descending;
|
query.SortOrder = SortOrder.Descending;
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query));
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
query.Limit = GetSpecialItemsLimit();
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query);
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetMovieResume(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetMovieResume(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -513,10 +531,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName };
|
query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName };
|
||||||
query.SortOrder = SortOrder.Descending;
|
query.SortOrder = SortOrder.Descending;
|
||||||
query.IsResumable = true;
|
query.IsResumable = true;
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
query.Limit = GetSpecialItemsLimit();
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetMovieGenres(Folder parent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetMovieGenres(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -549,11 +570,14 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetMovieGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetMovieGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty })
|
query.Recursive = true;
|
||||||
.Where(i => i is Movie)
|
query.ParentId = queryParent.Id;
|
||||||
.Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase));
|
query.Genres = new[] { displayParent.Name };
|
||||||
|
query.SetUser(user);
|
||||||
|
|
||||||
return GetResult(items, queryParent, query);
|
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
||||||
|
|
||||||
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetPlaylistsView(Folder parent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetPlaylistsView(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -598,9 +622,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName };
|
query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName };
|
||||||
query.SortOrder = SortOrder.Descending;
|
query.SortOrder = SortOrder.Descending;
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Episode && FilterItem(i, query));
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
query.Limit = GetSpecialItemsLimit();
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Episode).Name };
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query);
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetTvNextUp(Folder parent, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetTvNextUp(Folder parent, InternalItemsQuery query)
|
||||||
|
@ -623,17 +651,24 @@ namespace MediaBrowser.Controller.Entities
|
||||||
query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName };
|
query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName };
|
||||||
query.SortOrder = SortOrder.Descending;
|
query.SortOrder = SortOrder.Descending;
|
||||||
query.IsResumable = true;
|
query.IsResumable = true;
|
||||||
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
query.Limit = GetSpecialItemsLimit();
|
||||||
|
query.IncludeItemTypes = new[] { typeof(Episode).Name };
|
||||||
|
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Episode && FilterItem(i, query));
|
return _libraryManager.GetItemsResult(query);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetTvSeries(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> GetTvSeries(Folder parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Series && FilterItem(i, query));
|
query.Recursive = true;
|
||||||
|
query.ParentId = parent.Id;
|
||||||
|
query.SetUser(user);
|
||||||
|
|
||||||
return PostFilterAndSort(items, parent, null, query);
|
query.IncludeItemTypes = new[] { typeof(Series).Name };
|
||||||
|
|
||||||
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetTvGenres(Folder parent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetTvGenres(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -666,11 +701,14 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetTvGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetTvGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.TvShows, string.Empty })
|
query.Recursive = true;
|
||||||
.Where(i => i is Series)
|
query.ParentId = queryParent.Id;
|
||||||
.Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase));
|
query.Genres = new[] { displayParent.Name };
|
||||||
|
query.SetUser(user);
|
||||||
|
|
||||||
return GetResult(items, queryParent, query);
|
query.IncludeItemTypes = new[] { typeof(Series).Name };
|
||||||
|
|
||||||
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetResult<T>(QueryResult<T> result)
|
private QueryResult<BaseItem> GetResult<T>(QueryResult<T> result)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user