/// <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); }
/// <inheritdoc /> public async Task <IEnumerable <RemoteImageInfo?> > GetImages(BaseItem item, CancellationToken cancellationToken) { var seriesWithPerson = _libraryManager.GetItemList(new InternalItemsQuery { IncludeItemTypes = new[] { nameof(Series) }, PersonIds = new[] { item.Id }, DtoOptions = new DtoOptions(false) { EnableImages = false } }).Cast <Series>() .Where(i => TvdbSeriesProvider.IsValidSeries(i.ProviderIds)) .ToList(); var infos = (await Task.WhenAll(seriesWithPerson.Select(async i => await GetImageFromSeriesData(i, item.Name, cancellationToken).ConfigureAwait(false))) .ConfigureAwait(false)) .Where(i => i != null) .Take(1); return(infos); }
/// <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); }