コード例 #1
0
        public object Get(GetPlaylistItems request)
        {
            var playlist = (Playlist)_libraryManager.GetItemById(request.Id);
            var user     = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
            var items    = playlist.GetManageableItems().ToArray();

            var count = items.Length;

            if (request.StartIndex.HasValue)
            {
                items = items.Skip(request.StartIndex.Value).ToArray();
            }

            if (request.Limit.HasValue)
            {
                items = items.Take(request.Limit.Value).ToArray();
            }

            var dtos = items
                       .Select(i => _dtoService.GetBaseItemDto(i, request.GetItemFields().ToList(), user))
                       .ToArray();

            var result = new ItemsResult
            {
                Items            = dtos,
                TotalRecordCount = count
            };

            return(ToOptimizedResult(result));
        }
コード例 #2
0
ファイル: PlaylistService.cs プロジェクト: sytone/Emby
        public async Task <object> Get(GetPlaylistItems request)
        {
            var playlist = (Playlist)_libraryManager.GetItemById(request.Id);
            var user     = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;

            var items = playlist.GetManageableItems().ToArray();

            var count = items.Length;

            if (request.StartIndex.HasValue)
            {
                items = items.Skip(request.StartIndex.Value).ToArray();
            }

            if (request.Limit.HasValue)
            {
                items = items.Take(request.Limit.Value).ToArray();
            }

            var dtoOptions = GetDtoOptions(_authContext, request);

            var returnList = (await _dtoService.GetBaseItemDtos(items.Select(i => i.Item2), dtoOptions, user)
                              .ConfigureAwait(false));
            var dtos = returnList
                       .ToArray(returnList.Count);

            var index = 0;

            foreach (var item in dtos)
            {
                item.PlaylistItemId = items[index].Item1.Id;
                index++;
            }

            var result = new ItemsResult
            {
                Items            = dtos,
                TotalRecordCount = count
            };

            return(ToOptimizedResult(result));
        }
コード例 #3
0
        public object Get(GetPlaylistItems request)
        {
            var playlist = (Playlist)_libraryManager.GetItemById(request.Id);
            var user     = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;

            var items = playlist.GetManageableItems().ToArray();

            var count = items.Length;

            if (request.StartIndex.HasValue)
            {
                items = items.Skip(request.StartIndex.Value).ToArray();
            }

            if (request.Limit.HasValue)
            {
                items = items.Take(request.Limit.Value).ToArray();
            }

            var dtos = items
                       .Select(i => _dtoService.GetBaseItemDto(i.Item2, request.GetItemFields().ToList(), user))
                       .ToArray();

            var index = 0;

            foreach (var item in dtos)
            {
                item.PlaylistItemId = items[index].Item1.Id;
                index++;
            }

            var result = new ItemsResult
            {
                Items            = dtos,
                TotalRecordCount = count
            };

            return(ToOptimizedResult(result));
        }
コード例 #4
0
ファイル: PlaylistService.cs プロジェクト: zxz2020/Emby
        public object Get(GetPlaylistItems request)
        {
            var playlist = (Playlist)_libraryManager.GetItemById(request.Id);
            var user     = !request.UserId.Equals(Guid.Empty) ? _userManager.GetUserById(request.UserId) : null;

            var items = playlist.GetManageableItems().ToArray();

            var count = items.Length;

            if (request.StartIndex.HasValue)
            {
                items = items.Skip(request.StartIndex.Value).ToArray();
            }

            if (request.Limit.HasValue)
            {
                items = items.Take(request.Limit.Value).ToArray();
            }

            var dtoOptions = GetDtoOptions(_authContext, request);

            var dtos = _dtoService.GetBaseItemDtos(items.Select(i => i.Item2).ToList(), dtoOptions, user);

            var index = 0;

            foreach (var item in dtos)
            {
                item.PlaylistItemId = items[index].Item1.Id;
                index++;
            }

            var result = new QueryResult <BaseItemDto>
            {
                Items            = dtos,
                TotalRecordCount = count
            };

            return(ToOptimizedResult(result));
        }