Exemple #1
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var person = (Person)item;

            if (!person.TryGetProviderId(MetadataProvider.Tmdb, out var personTmdbId))
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var language     = item.GetPreferredMetadataLanguage();
            var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), language, cancellationToken).ConfigureAwait(false);

            if (personResult?.Images?.Profiles == null)
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var profiles     = personResult.Images.Profiles;
            var remoteImages = new List <RemoteImageInfo>(profiles.Count);

            _tmdbClientManager.ConvertProfilesToRemoteImageInfo(profiles, language, remoteImages);

            return(remoteImages);
        }