using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Threading.Tasks; using System.Linq; namespace MediaBrowser.Controller.Entities { public class UserView : Folder { public string ViewType { get; set; } public Guid ParentId { get; set; } public Guid DisplayParentId { get; set; } public Guid? UserId { get; set; } public static ITVSeriesManager TVSeriesManager; public static IPlaylistManager PlaylistManager; public bool ContainsDynamicCategories(User user) { return true; } public override IEnumerable GetIdsForAncestorQuery() { var list = new List(); if (DisplayParentId != Guid.Empty) { list.Add(DisplayParentId); } else if (ParentId != Guid.Empty) { list.Add(ParentId); } return list; } public override Task> GetItems(InternalItemsQuery query) { var parent = this as Folder; if (DisplayParentId != Guid.Empty) { parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent; } else if (ParentId != Guid.Empty) { parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent; } return new UserViewBuilder(UserViewManager, LiveTvManager, ChannelManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, CollectionManager, PlaylistManager) .GetUserItems(parent, this, ViewType, query); } public override IEnumerable GetChildren(User user, bool includeLinkedChildren) { var result = GetItems(new InternalItemsQuery { User = user }).Result; return result.Items; } public override bool CanDelete() { return false; } public override bool IsSaveLocalMetadataEnabled() { return true; } public override IEnumerable GetRecursiveChildren(User user, Func filter) { var result = GetItems(new InternalItemsQuery { User = user, Recursive = true, Filter = filter }).Result; return result.Items; } protected override IEnumerable GetEligibleChildrenForRecursiveChildren(User user) { return GetChildren(user, false); } public static bool IsExcludedFromGrouping(Folder folder) { var standaloneTypes = new List { CollectionType.Books, CollectionType.HomeVideos, CollectionType.Photos, CollectionType.Playlists, CollectionType.BoxSets, CollectionType.MusicVideos, CollectionType.Games, CollectionType.Music }; var collectionFolder = folder as ICollectionFolder; if (collectionFolder == null) { return false; } return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty); } public static bool IsUserSpecific(Folder folder) { var standaloneTypes = new List { CollectionType.Playlists, CollectionType.BoxSets }; var collectionFolder = folder as ICollectionFolder; if (collectionFolder == null) { return false; } return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty); } public static bool IsEligibleForEnhancedView(string viewType) { var types = new[] { CollectionType.Movies, CollectionType.TvShows }; return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase); } [IgnoreDataMember] public override bool SupportsPeople { get { return false; } } } }