2015-01-24 12:03:55 -07:00
|
|
|
|
using MediaBrowser.Controller.Channels;
|
|
|
|
|
using MediaBrowser.Controller.Collections;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-06-07 12:46:24 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.LiveTv;
|
|
|
|
|
using MediaBrowser.Controller.Localization;
|
2014-08-01 19:34:45 -07:00
|
|
|
|
using MediaBrowser.Controller.Playlists;
|
2014-06-07 12:46:24 -07:00
|
|
|
|
using MediaBrowser.Model.Channels;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.Library;
|
2014-07-13 14:03:57 -07:00
|
|
|
|
using MediaBrowser.Model.Querying;
|
2015-02-19 17:34:05 -07:00
|
|
|
|
using MoreLinq;
|
2014-06-07 12:46:24 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Library
|
|
|
|
|
{
|
|
|
|
|
public class UserViewManager : IUserViewManager
|
|
|
|
|
{
|
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
private readonly ILocalizationManager _localizationManager;
|
|
|
|
|
private readonly IUserManager _userManager;
|
|
|
|
|
|
|
|
|
|
private readonly IChannelManager _channelManager;
|
|
|
|
|
private readonly ILiveTvManager _liveTvManager;
|
2014-08-01 19:34:45 -07:00
|
|
|
|
private readonly IPlaylistManager _playlists;
|
2015-01-24 12:03:55 -07:00
|
|
|
|
private readonly ICollectionManager _collectionManager;
|
|
|
|
|
private readonly IServerConfigurationManager _config;
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2015-01-24 12:03:55 -07:00
|
|
|
|
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IPlaylistManager playlists, ICollectionManager collectionManager, IServerConfigurationManager config)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
|
_localizationManager = localizationManager;
|
|
|
|
|
_userManager = userManager;
|
|
|
|
|
_channelManager = channelManager;
|
|
|
|
|
_liveTvManager = liveTvManager;
|
2014-08-01 19:34:45 -07:00
|
|
|
|
_playlists = playlists;
|
2015-01-24 12:03:55 -07:00
|
|
|
|
_collectionManager = collectionManager;
|
|
|
|
|
_config = config;
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken)
|
|
|
|
|
{
|
2014-09-14 08:10:51 -07:00
|
|
|
|
var user = _userManager.GetUserById(query.UserId);
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
|
|
|
|
var folders = user.RootFolder
|
|
|
|
|
.GetChildren(user, true)
|
|
|
|
|
.OfType<Folder>()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
var excludeFolderIds = user.Configuration.ExcludeFoldersFromGrouping.Select(i => new Guid(i)).ToList();
|
2015-04-15 14:59:20 -07:00
|
|
|
|
var plainFolderIds = user.Configuration.PlainFolderViews.Select(i => new Guid(i)).ToList();
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2015-01-26 09:47:15 -07:00
|
|
|
|
var standaloneFolders = folders
|
|
|
|
|
.Where(i => UserView.IsExcludedFromGrouping(i) || excludeFolderIds.Contains(i.Id))
|
|
|
|
|
.ToList();
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2014-10-11 13:38:13 -07:00
|
|
|
|
var foldersWithViewTypes = folders
|
2014-06-07 12:46:24 -07:00
|
|
|
|
.Except(standaloneFolders)
|
2014-10-11 13:38:13 -07:00
|
|
|
|
.OfType<ICollectionFolder>()
|
2014-06-07 12:46:24 -07:00
|
|
|
|
.ToList();
|
|
|
|
|
|
2015-03-15 12:22:04 -07:00
|
|
|
|
var list = new List<Folder>();
|
|
|
|
|
|
|
|
|
|
if (_config.Configuration.EnableUserSpecificUserViews)
|
|
|
|
|
{
|
|
|
|
|
foreach (var folder in standaloneFolders)
|
|
|
|
|
{
|
|
|
|
|
var collectionFolder = folder as ICollectionFolder;
|
|
|
|
|
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
|
2015-03-18 09:40:16 -07:00
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
if (plainFolderIds.Contains(folder.Id))
|
2015-03-18 09:40:16 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrWhiteSpace(folderViewType))
|
|
|
|
|
{
|
|
|
|
|
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2015-03-18 09:40:16 -07:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(folder);
|
2015-03-18 09:40:16 -07:00
|
|
|
|
}
|
2015-03-15 12:22:04 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.AddRange(standaloneFolders);
|
|
|
|
|
}
|
2014-10-11 13:38:13 -07:00
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
var parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (parents.Count > 0)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(parents, CollectionType.TvShows, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) || string.Equals(i.CollectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (parents.Count > 0)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(parents, CollectionType.Music, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (parents.Count > 0)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(parents, CollectionType.Movies, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (parents.Count > 0)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(parents, CollectionType.Games, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (parents.Count > 0)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(parents, CollectionType.BoxSets, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (parents.Count > 0)
|
2014-08-01 19:34:45 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(parents, CollectionType.Playlists, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-08-01 19:34:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
if (user.Configuration.DisplayFoldersView)
|
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(new List<ICollectionFolder>(), CollectionType.Folders, "zz_" + CollectionType.Folders, user, cancellationToken).ConfigureAwait(false));
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 12:46:24 -07:00
|
|
|
|
if (query.IncludeExternalContent)
|
|
|
|
|
{
|
2014-06-10 10:36:06 -07:00
|
|
|
|
var channelResult = await _channelManager.GetChannels(new ChannelQuery
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
|
|
|
|
UserId = query.UserId
|
|
|
|
|
|
2014-06-10 10:36:06 -07:00
|
|
|
|
}, cancellationToken).ConfigureAwait(false);
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2014-06-30 12:24:35 -07:00
|
|
|
|
var channels = channelResult.Items;
|
|
|
|
|
|
|
|
|
|
var embeddedChannels = channels
|
|
|
|
|
.Where(i => user.Configuration.DisplayChannelsWithinViews.Contains(i.Id))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
list.AddRange(embeddedChannels.Select(i => _channelManager.GetChannel(i.Id)));
|
|
|
|
|
|
|
|
|
|
if (channels.Length > embeddedChannels.Count)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
|
|
|
|
list.Add(await _channelManager.GetInternalChannelFolder(query.UserId, cancellationToken).ConfigureAwait(false));
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 10:36:06 -07:00
|
|
|
|
if (_liveTvManager.GetEnabledUsers().Select(i => i.Id.ToString("N")).Contains(query.UserId))
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
2015-03-14 08:38:16 -07:00
|
|
|
|
//list.Add(await _liveTvManager.GetInternalLiveTvFolder(query.UserId, cancellationToken).ConfigureAwait(false));
|
2015-04-15 14:59:20 -07:00
|
|
|
|
list.Add(await GetUserView(new List<ICollectionFolder>(), CollectionType.LiveTv, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-18 18:42:53 -07:00
|
|
|
|
var sorted = _libraryManager.Sort(list, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList();
|
|
|
|
|
|
|
|
|
|
var orders = user.Configuration.OrderedViews.ToList();
|
|
|
|
|
|
|
|
|
|
return list
|
|
|
|
|
.OrderBy(i =>
|
|
|
|
|
{
|
|
|
|
|
var index = orders.IndexOf(i.Id.ToString("N"));
|
|
|
|
|
|
|
|
|
|
return index == -1 ? int.MaxValue : index;
|
|
|
|
|
})
|
|
|
|
|
.ThenBy(sorted.IndexOf)
|
|
|
|
|
.ThenBy(i => i.SortName);
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 21:50:23 -07:00
|
|
|
|
public Task<UserView> GetUserSubView(string name, string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
|
2014-11-10 20:41:55 -07:00
|
|
|
|
{
|
2015-03-13 21:50:23 -07:00
|
|
|
|
return _libraryManager.GetNamedView(user, name, parentId, type, sortName, cancellationToken);
|
2014-11-10 20:41:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 21:50:23 -07:00
|
|
|
|
public Task<UserView> GetUserSubView(string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
|
2014-06-07 12:46:24 -07:00
|
|
|
|
{
|
|
|
|
|
var name = _localizationManager.GetLocalizedString("ViewType" + type);
|
|
|
|
|
|
2015-03-13 21:50:23 -07:00
|
|
|
|
return GetUserSubView(name, parentId, type, user, sortName, cancellationToken);
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
2014-07-29 20:31:35 -07:00
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
public async Task<UserView> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, CancellationToken cancellationToken)
|
2014-07-29 20:31:35 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase)))
|
|
|
|
|
{
|
|
|
|
|
var name = parents[0].Name;
|
|
|
|
|
var parentId = parents[0].Id;
|
|
|
|
|
|
|
|
|
|
var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase);
|
2014-10-29 15:01:02 -07:00
|
|
|
|
|
2015-04-16 20:31:19 -07:00
|
|
|
|
if (_config.Configuration.EnableUserSpecificUserViews || !enableRichView)
|
2015-04-15 14:59:20 -07:00
|
|
|
|
{
|
|
|
|
|
viewType = enableRichView ? viewType : null;
|
|
|
|
|
var view = await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
if (view.ParentId != parentId)
|
|
|
|
|
{
|
|
|
|
|
view.ParentId = parentId;
|
|
|
|
|
await view.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var name = _localizationManager.GetLocalizedString("ViewType" + viewType);
|
|
|
|
|
|
|
|
|
|
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
2014-07-29 20:31:35 -07:00
|
|
|
|
}
|
2015-01-26 09:47:15 -07:00
|
|
|
|
|
2015-04-15 14:59:20 -07:00
|
|
|
|
public Task<UserView> GetUserView(Guid parentId, string name, string viewType, bool enableRichView, string sortName, User user, CancellationToken cancellationToken)
|
2015-03-15 12:22:04 -07:00
|
|
|
|
{
|
2015-04-15 14:59:20 -07:00
|
|
|
|
return _libraryManager.GetNamedView(user, name, parentId.ToString("N"), viewType, sortName, cancellationToken);
|
2015-03-15 12:22:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-26 09:47:15 -07:00
|
|
|
|
public List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request)
|
|
|
|
|
{
|
|
|
|
|
var user = _userManager.GetUserById(request.UserId);
|
|
|
|
|
|
|
|
|
|
var includeTypes = request.IncludeItemTypes;
|
|
|
|
|
|
|
|
|
|
var currentUser = user;
|
|
|
|
|
|
|
|
|
|
Func<BaseItem, bool> filter = i =>
|
|
|
|
|
{
|
|
|
|
|
if (includeTypes.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
if (!includeTypes.Contains(i.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (request.IsPlayed.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var val = request.IsPlayed.Value;
|
2015-03-31 09:24:16 -07:00
|
|
|
|
if (i is Video && i.IsPlayed(currentUser) != val)
|
2015-01-26 09:47:15 -07:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return i.LocationType != LocationType.Virtual && !i.IsFolder;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Avoid implicitly captured closure
|
|
|
|
|
var libraryItems = string.IsNullOrEmpty(request.ParentId) && user != null ?
|
|
|
|
|
GetItemsConfiguredForLatest(user, filter) :
|
|
|
|
|
GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId, filter);
|
|
|
|
|
|
|
|
|
|
libraryItems = libraryItems.OrderByDescending(i => i.DateCreated);
|
|
|
|
|
|
|
|
|
|
if (request.IsPlayed.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var takeLimit = (request.Limit ?? 20) * 20;
|
|
|
|
|
libraryItems = libraryItems.Take(takeLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Avoid implicitly captured closure
|
|
|
|
|
var items = libraryItems
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
var list = new List<Tuple<BaseItem, List<BaseItem>>>();
|
|
|
|
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
// Only grab the index container for media
|
|
|
|
|
var container = item.IsFolder || !request.GroupItems ? null : item.LatestItemsIndexContainer;
|
|
|
|
|
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new Tuple<BaseItem, List<BaseItem>>(null, new List<BaseItem> { item }));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id == container.Id);
|
|
|
|
|
|
|
|
|
|
if (current != null)
|
|
|
|
|
{
|
|
|
|
|
current.Item2.Add(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.Add(new Tuple<BaseItem, List<BaseItem>>(container, new List<BaseItem> { item }));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (list.Count >= request.Limit)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected IList<BaseItem> GetAllLibraryItems(string userId, IUserManager userManager, ILibraryManager libraryManager, string parentId, Func<BaseItem, bool> filter)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(parentId))
|
|
|
|
|
{
|
|
|
|
|
var folder = (Folder)libraryManager.GetItemById(new Guid(parentId));
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(userId))
|
|
|
|
|
{
|
|
|
|
|
var user = userManager.GetUserById(userId);
|
|
|
|
|
|
|
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("User not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return folder
|
|
|
|
|
.GetRecursiveChildren(user, filter)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return folder
|
|
|
|
|
.GetRecursiveChildren(filter);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(userId))
|
|
|
|
|
{
|
|
|
|
|
var user = userManager.GetUserById(userId);
|
|
|
|
|
|
|
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("User not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return user
|
|
|
|
|
.RootFolder
|
|
|
|
|
.GetRecursiveChildren(user, filter)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return libraryManager
|
|
|
|
|
.RootFolder
|
|
|
|
|
.GetRecursiveChildren(filter);
|
|
|
|
|
}
|
2015-04-15 14:59:20 -07:00
|
|
|
|
|
2015-01-26 09:47:15 -07:00
|
|
|
|
private IEnumerable<BaseItem> GetItemsConfiguredForLatest(User user, Func<BaseItem, bool> filter)
|
|
|
|
|
{
|
|
|
|
|
// Avoid implicitly captured closure
|
|
|
|
|
var currentUser = user;
|
|
|
|
|
|
|
|
|
|
return user.RootFolder.GetChildren(user, true)
|
|
|
|
|
.OfType<Folder>()
|
|
|
|
|
.Where(i => !user.Configuration.LatestItemsExcludes.Contains(i.Id.ToString("N")))
|
|
|
|
|
.SelectMany(i => i.GetRecursiveChildren(currentUser, filter))
|
|
|
|
|
.DistinctBy(i => i.Id);
|
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
}
|