Example #1
0
        /// <summary>
        /// Gets the images.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="i">The i.</param>
        /// <param name="preferredLanguage">The preferred language.</param>
        /// <param name="type">The type.</param>
        /// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
        private async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken, IImageProvider i, string preferredLanguage, ImageType? type = null)
        {
            try
            {
                if (type.HasValue)
                {
                    var result = await i.GetImages(item, type.Value, cancellationToken).ConfigureAwait(false);

                    return FilterImages(result, preferredLanguage);
                }
                else
                {
                    var result = await i.GetAllImages(item, cancellationToken).ConfigureAwait(false);
                    return FilterImages(result, preferredLanguage);
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorException("{0} failed in GetImages for type {1}", ex, i.GetType().Name, item.GetType().Name);
                return new List<RemoteImageInfo>();
            }
        }