Example #1
0
        private async Task <IEnumerable <BaseItem> > GetUserViewChildren(UserView folder, User user, SortCriteria sort)
        {
            if (string.Equals(folder.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
            {
                return(new List <BaseItem>());
            }
            if (string.Equals(folder.ViewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase))
            {
                var result = await _channelManager.GetChannelsInternal(new ChannelQuery()
                {
                    UserId = user.Id.ToString("N")
                }, CancellationToken.None).ConfigureAwait(false);

                return(result.Items);
            }
            if (string.Equals(folder.ViewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
            {
                return(SortItems(folder.GetChildren(user, true).OfType <Series>(), user, sort));
            }
            if (string.Equals(folder.ViewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
            {
                return(SortItems(folder.GetRecursiveChildren(user, true).OfType <Movie>(), user, sort));
            }
            if (string.Equals(folder.ViewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
            {
                return(SortItems(folder.GetChildren(user, true).OfType <MusicArtist>(), user, sort));
            }

            return(GetPlainFolderChildrenSorted(folder, user, sort));
        }