/// <inheritdoc />
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var season = (Season)item;
            var series = season.Series;

            if (series == null || !season.IndexNumber.HasValue || !TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var tvdbId       = Convert.ToInt32(series.GetProviderId(TvdbPlugin.ProviderId), CultureInfo.InvariantCulture);
            var seasonNumber = season.IndexNumber.Value;
            var language     = item.GetPreferredMetadataLanguage();
            var remoteImages = new List <RemoteImageInfo>();

            var keyTypes = _tvdbClientManager.GetImageKeyTypesForSeasonAsync(tvdbId, language, cancellationToken).ConfigureAwait(false);

            await foreach (var keyType in keyTypes)
            {
                var imageQuery = new ImagesQuery
                {
                    KeyType = keyType,
                    SubKey  = seasonNumber.ToString(CultureInfo.InvariantCulture)
                };
                try
                {
                    var imageResults = await _tvdbClientManager
                                       .GetImagesAsync(tvdbId, imageQuery, language, cancellationToken).ConfigureAwait(false);

                    remoteImages.AddRange(GetImages(imageResults.Data, imageQuery.SubKey, language));
                }
                catch (TvDbServerException)
                {
                    _logger.LogDebug("No images of type {KeyType} found for series {TvdbId}", keyType, tvdbId);
                }
            }

            return(remoteImages);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            if (!TvdbSeriesProvider.IsValidSeries(item.ProviderIds))
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var language        = item.GetPreferredMetadataLanguage();
            var remoteImages    = new List <RemoteImageInfo>();
            var tvdbId          = Convert.ToInt32(item.GetProviderId(TvdbPlugin.ProviderId), CultureInfo.InvariantCulture);
            var allowedKeyTypes = _tvdbClientManager.GetImageKeyTypesForSeriesAsync(tvdbId, language, cancellationToken)
                                  .ConfigureAwait(false);

            await foreach (KeyType keyType in allowedKeyTypes)
            {
                var imageQuery = new ImagesQuery
                {
                    KeyType = keyType
                };
                try
                {
                    var imageResults =
                        await _tvdbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken)
                        .ConfigureAwait(false);

                    remoteImages.AddRange(GetImages(imageResults.Data, language));
                }
                catch (TvDbServerException)
                {
                    _logger.LogDebug(
                        "No images of type {KeyType} exist for series {TvDbId}",
                        keyType,
                        tvdbId);
                }
            }

            return(remoteImages);
        }