Пример #1
0
        private RemoteImageResult GetRemoteImageResult(BaseItem item, BaseRemoteImageRequest request)
        {
            var images = _providerManager.GetAvailableRemoteImages(item, CancellationToken.None, request.ProviderName, request.Type).Result;

            var imagesList = images.ToList();

            var result = new RemoteImageResult
            {
                TotalRecordCount = imagesList.Count,
                Providers        = _providerManager.GetImageProviders(item).Select(i => i.Name).ToList()
            };

            if (request.StartIndex.HasValue)
            {
                imagesList = imagesList.Skip(request.StartIndex.Value)
                             .ToList();
            }

            if (request.Limit.HasValue)
            {
                imagesList = imagesList.Take(request.Limit.Value)
                             .ToList();
            }

            result.Images = imagesList;

            return(result);
        }
Пример #2
0
        private async Task <RemoteImageResult> GetRemoteImageResult(BaseItem item, BaseRemoteImageRequest request)
        {
            var images = await _providerManager.GetAvailableRemoteImages(item, new RemoteImageQuery
            {
                ProviderName             = request.ProviderName,
                IncludeAllLanguages      = request.IncludeAllLanguages,
                IncludeDisabledProviders = true,
                ImageType = request.Type
            }, CancellationToken.None).ConfigureAwait(false);

            var imagesList = images.ToList();

            var allProviders = _providerManager.GetRemoteImageProviderInfo(item);

            if (request.Type.HasValue)
            {
                allProviders = allProviders.Where(i => i.SupportedImages.Contains(request.Type.Value));
            }

            var result = new RemoteImageResult
            {
                TotalRecordCount = imagesList.Count,
                Providers        = allProviders.Select(i => i.Name)
                                   .Distinct(StringComparer.OrdinalIgnoreCase)
                                   .ToList()
            };

            if (request.StartIndex.HasValue)
            {
                imagesList = imagesList.Skip(request.StartIndex.Value)
                             .ToList();
            }

            if (request.Limit.HasValue)
            {
                imagesList = imagesList.Take(request.Limit.Value)
                             .ToList();
            }

            result.Images = imagesList;

            return(result);
        }