mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
commit
c65589784c
4 changed files with 151 additions and 89 deletions
|
@ -181,6 +181,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public InternalItemsQuery(User user)
|
public InternalItemsQuery(User user)
|
||||||
: this()
|
: this()
|
||||||
|
{
|
||||||
|
SetUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetUser(User user)
|
||||||
{
|
{
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,13 +125,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
case CollectionType.HomeVideos:
|
case CollectionType.HomeVideos:
|
||||||
case CollectionType.Games:
|
case CollectionType.Games:
|
||||||
case CollectionType.MusicVideos:
|
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:
|
case CollectionType.Folders:
|
||||||
return GetResult(user.RootFolder.GetChildren(user, true), queryParent, query);
|
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);
|
return await GetPlaylistsView(queryParent, user, query).ConfigureAwait(false);
|
||||||
|
|
||||||
case CollectionType.BoxSets:
|
case CollectionType.BoxSets:
|
||||||
return await GetBoxsetView(queryParent, user, query).ConfigureAwait(false);
|
return GetBoxsetView(queryParent, user, query);
|
||||||
|
|
||||||
case CollectionType.TvShows:
|
case CollectionType.TvShows:
|
||||||
return await GetTvView(queryParent, user, query).ConfigureAwait(false);
|
return await GetTvView(queryParent, user, query).ConfigureAwait(false);
|
||||||
|
@ -206,7 +206,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return GetMusicLatest(queryParent, user, query);
|
return GetMusicLatest(queryParent, user, query);
|
||||||
|
|
||||||
case SpecialFolder.MusicPlaylists:
|
case SpecialFolder.MusicPlaylists:
|
||||||
return await GetMusicPlaylists(queryParent, user, query).ConfigureAwait(false);
|
return GetMusicPlaylists(queryParent, user, query);
|
||||||
|
|
||||||
case SpecialFolder.MusicAlbums:
|
case SpecialFolder.MusicAlbums:
|
||||||
return GetMusicAlbums(queryParent, user, query);
|
return GetMusicAlbums(queryParent, user, query);
|
||||||
|
@ -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)
|
||||||
|
@ -353,26 +353,36 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return GetResult(artists, parent, query);
|
return GetResult(artists, parent, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<QueryResult<BaseItem>> GetMusicPlaylists(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> 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;
|
query.Recursive = true;
|
||||||
|
|
||||||
return parent.GetItems(query);
|
return _libraryManager.GetItemsResult(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -396,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)
|
||||||
|
@ -428,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>();
|
||||||
|
@ -457,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)
|
||||||
|
@ -501,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)
|
||||||
|
@ -511,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)
|
||||||
|
@ -547,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)
|
||||||
|
@ -559,11 +585,14 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return GetResult(_playlistManager.GetPlaylists(user.Id.ToString("N")), parent, query);
|
return GetResult(_playlistManager.GetPlaylists(user.Id.ToString("N")), parent, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetBoxsetView(Folder parent, User user, InternalItemsQuery query)
|
private QueryResult<BaseItem> 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<QueryResult<BaseItem>> GetTvView(Folder parent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetTvView(Folder parent, User user, InternalItemsQuery query)
|
||||||
|
@ -593,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)
|
||||||
|
@ -618,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)
|
||||||
|
@ -661,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)
|
||||||
|
|
|
@ -1643,9 +1643,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||||
{
|
{
|
||||||
//Logger.Debug("GetItemList query time: {0}ms. Query: {1}",
|
LogQueryTime("GetItemList", cmd, now);
|
||||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
|
||||||
// cmd.CommandText);
|
|
||||||
|
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
|
@ -1659,6 +1657,26 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate)
|
||||||
|
{
|
||||||
|
var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds;
|
||||||
|
|
||||||
|
if (elapsed >= 500)
|
||||||
|
{
|
||||||
|
Logger.Debug("{2} query time (slow): {0}ms. Query: {1}",
|
||||||
|
Convert.ToInt32(elapsed),
|
||||||
|
cmd.CommandText,
|
||||||
|
methodName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Logger.Debug("{2} query time: {0}ms. Query: {1}",
|
||||||
|
// Convert.ToInt32(elapsed),
|
||||||
|
// cmd.CommandText,
|
||||||
|
// methodName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public QueryResult<BaseItem> GetItems(InternalItemsQuery query)
|
public QueryResult<BaseItem> GetItems(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (query == null)
|
if (query == null)
|
||||||
|
@ -1728,9 +1746,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
|
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||||
{
|
{
|
||||||
//Logger.Debug("GetItems query time: {0}ms. Query: {1}",
|
LogQueryTime("GetItems", cmd, now);
|
||||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
|
||||||
// cmd.CommandText);
|
|
||||||
|
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
|
@ -1878,9 +1894,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||||
{
|
{
|
||||||
//Logger.Debug("GetItemIdsList query time: {0}ms. Query: {1}",
|
LogQueryTime("GetItemIdsList", cmd, now);
|
||||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
|
||||||
// cmd.CommandText);
|
|
||||||
|
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
|
@ -2036,9 +2050,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
|
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||||
{
|
{
|
||||||
//Logger.Debug("GetItemIds query time: {0}ms. Query: {1}",
|
LogQueryTime("GetItemIds", cmd, now);
|
||||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
|
||||||
// cmd.CommandText);
|
|
||||||
|
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
|
@ -2562,8 +2574,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
clause += " OR ";
|
clause += " OR ";
|
||||||
}
|
}
|
||||||
clause += "Album=@AlbumName" + index;
|
clause += "Album=@AlbumName" + index;
|
||||||
index++;
|
|
||||||
cmd.Parameters.Add(cmd, "@AlbumName" + index, DbType.String).Value = name;
|
cmd.Parameters.Add(cmd, "@AlbumName" + index, DbType.String).Value = name;
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
clause += ")";
|
clause += ")";
|
||||||
|
|
|
@ -49,9 +49,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
|
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
|
||||||
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
|
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
|
||||||
|
"create index if not exists idx_SyncJobs1 on SyncJobs(TargetId)",
|
||||||
|
|
||||||
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT, ItemDateModifiedTicks BIGINT)",
|
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT, ItemDateModifiedTicks BIGINT)",
|
||||||
"create index if not exists idx_SyncJobItems on SyncJobs(Id)",
|
"create index if not exists idx_SyncJobItems1 on SyncJobItems(Id)",
|
||||||
|
"create index if not exists idx_SyncJobItems2 on SyncJobItems(TargetId)",
|
||||||
|
|
||||||
//pragmas
|
//pragmas
|
||||||
"pragma temp_store = memory",
|
"pragma temp_store = memory",
|
||||||
|
|
Loading…
Reference in a new issue