예제 #1
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var episode = (Controller.Entities.TV.Episode)item;
            var series  = episode.Series;

            var seriesTmdbId = Convert.ToInt32(series?.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);

            if (seriesTmdbId <= 0)
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var seasonNumber  = episode.ParentIndexNumber;
            var episodeNumber = episode.IndexNumber;

            if (!seasonNumber.HasValue || !episodeNumber.HasValue)
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var language = item.GetPreferredMetadataLanguage();

            // TODO use image languages if All Languages isn't toggled, but there's currently no way to get that value in here
            var episodeResult = await _tmdbClientManager
                                .GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, series.EpisodeGroupId, null, null, cancellationToken)
                                .ConfigureAwait(false);

            var stills = episodeResult?.Images?.Stills;

            if (stills == null)
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var remoteImages = new List <RemoteImageInfo>(stills.Count);

            _tmdbClientManager.ConvertStillsToRemoteImageInfo(stills, language, remoteImages);

            return(remoteImages);
        }