コード例 #1
0
ファイル: UserLibraryService.cs プロジェクト: vvuk/Emby
        private List <BaseItemDto> GetAsync(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ?
                       user.RootFolder :
                       _libraryManager.GetItemById(request.Id);

            var series = item as Series;

            // Get them from the child tree
            if (series != null)
            {
                var dtoOptions = GetDtoOptions(_authContext, request);

                // Avoid implicitly captured closure
                var currentUser = user;

                var dtos = series
                           .GetEpisodes(user)
                           .Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
                           .OrderBy(i =>
                {
                    if (i.PremiereDate.HasValue)
                    {
                        return(i.PremiereDate.Value);
                    }

                    if (i.ProductionYear.HasValue)
                    {
                        return(new DateTime(i.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc));
                    }
                    return(DateTime.MinValue);
                })
                           .ThenBy(i => i.SortName)
                           .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, currentUser));

                return(dtos.ToList());
            }

            var movie = item as IHasSpecialFeatures;

            // Get them from the db
            if (movie != null)
            {
                var dtoOptions = GetDtoOptions(_authContext, request);

                var dtos = movie.SpecialFeatureIds
                           .Select(_libraryManager.GetItemById)
                           .OrderBy(i => i.SortName)
                           .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));

                return(dtos.ToList());
            }

            return(new List <BaseItemDto>());
        }
コード例 #2
0
        private List <BaseItemDto> GetAsync(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ?
                       user.RootFolder :
                       _libraryManager.GetItemById(request.Id);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();

            var movie = item as Movie;

            // Get them from the db
            if (movie != null)
            {
                // Avoid implicitly captured closure
                var movie1 = movie;

                var dtos = movie.SpecialFeatureIds
                           .Select(_libraryManager.GetItemById)
                           .OrderBy(i => i.SortName)
                           .Select(i => _dtoService.GetBaseItemDto(i, fields, user, movie1));

                return(dtos.ToList());
            }

            var series = item as Series;

            // Get them from the child tree
            if (series != null)
            {
                var dtos = series
                           .GetRecursiveChildren()
                           .Where(i => i is Episode && i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
                           .OrderBy(i =>
                {
                    if (i.PremiereDate.HasValue)
                    {
                        return(i.PremiereDate.Value);
                    }

                    if (i.ProductionYear.HasValue)
                    {
                        return(new DateTime(i.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc));
                    }
                    return(DateTime.MinValue);
                })
                           .ThenBy(i => i.SortName)
                           .Select(i => _dtoService.GetBaseItemDto(i, fields, user));

                return(dtos.ToList());
            }

            return(new List <BaseItemDto>());
        }
コード例 #3
0
        private Task <BaseItemDto[]> GetAsync(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _dtoService.GetItemByDtoId(request.Id, user.Id);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();

            var movie = item as Movie;

            // Get them from the db
            if (movie != null)
            {
                // Avoid implicitly captured closure
                var movie1 = movie;

                var tasks = movie.SpecialFeatureIds
                            .Select(_itemRepo.RetrieveItem)
                            .OrderBy(i => i.SortName)
                            .Select(i => _dtoService.GetBaseItemDto(i, fields, user, movie1));

                return(Task.WhenAll(tasks));
            }

            var series = item as Series;

            // Get them from the child tree
            if (series != null)
            {
                var tasks = series
                            .RecursiveChildren
                            .OfType <Episode>()
                            .Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
                            .OrderBy(i =>
                {
                    if (i.PremiereDate.HasValue)
                    {
                        return(i.PremiereDate.Value);
                    }

                    if (i.ProductionYear.HasValue)
                    {
                        return(new DateTime(i.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc));
                    }
                    return(DateTime.MinValue);
                })
                            .ThenBy(i => i.SortName)
                            .Select(i => _dtoService.GetBaseItemDto(i, fields, user));

                return(Task.WhenAll(tasks));
            }

            throw new ArgumentException("The item does not support special features");
        }
コード例 #4
0
ファイル: UserLibraryService.cs プロジェクト: zxz2020/Emby
        private BaseItemDto[] GetAsync(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ?
                       _libraryManager.GetUserRootFolder() :
                       _libraryManager.GetItemById(request.Id);

            var dtoOptions = GetDtoOptions(_authContext, request);

            var dtos = item.GetDisplayExtras()
                       .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));

            return(dtos.ToArray());
        }
コード例 #5
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();

            var movie = (Movie)item;

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);

            var items = movie.SpecialFeatureIds.Select(_itemRepo.RetrieveItem).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToList();

            return(ToOptimizedResult(items));
        }
コード例 #6
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();

            var movie = (Movie)item;

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager);

            var items = movie.SpecialFeatures.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).AsParallel().Select(t => t.Result).ToList();

            return(ToOptimizedResult(items));
        }
コード例 #7
0
        private BaseItemDto[] GetAsync(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ?
                       _libraryManager.GetUserRootFolder() :
                       _libraryManager.GetItemById(request.Id);

            var series = item as Series;

            // Get them from the child tree
            if (series != null)
            {
                var dtoOptions = GetDtoOptions(_authContext, request);

                // Avoid implicitly captured closure
                var currentUser = user;

                var dtos = series
                           .GetEpisodes(user, dtoOptions)
                           .Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
                           .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, currentUser));

                return(dtos.ToArray());
            }

            var movie = item as IHasSpecialFeatures;

            // Get them from the db
            if (movie != null)
            {
                var dtoOptions = GetDtoOptions(_authContext, request);

                var dtos = movie.SpecialFeatureIds
                           .Select(_libraryManager.GetItemById)
                           .OrderBy(i => i.SortName)
                           .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));

                return(dtos.ToArray());
            }

            return(new BaseItemDto[] { });
        }
コード例 #8
0
        private Task <BaseItemDto[]> GetAsync(GetSpecialFeatures request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();

            var movie = (Movie)item;

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);

            var tasks = movie.SpecialFeatureIds
                        .Select(_itemRepo.RetrieveItem)
                        .OrderBy(i => i.SortName)
                        .Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, movie));

            return(Task.WhenAll(tasks));
        }
コード例 #9
0
ファイル: UserLibraryService.cs プロジェクト: yannb2/jellyfin
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetSpecialFeatures request)
        {
            var result = GetAsync(request);

            return(ToOptimizedResult(result));
        }