|
|
@ -49,23 +49,25 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|
|
|
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
|
|
|
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var person = (Person)item;
|
|
|
|
var person = (Person)item;
|
|
|
|
var personTmdbId = Convert.ToInt32(person.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (personTmdbId > 0)
|
|
|
|
if (!person.TryGetProviderId(MetadataProvider.Tmdb, out var personTmdbId))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var personResult = await _tmdbClientManager.GetPersonAsync(personTmdbId, cancellationToken).ConfigureAwait(false);
|
|
|
|
return Enumerable.Empty<RemoteImageInfo>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), cancellationToken).ConfigureAwait(false);
|
|
|
|
if (personResult?.Images?.Profiles == null)
|
|
|
|
if (personResult?.Images?.Profiles == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Enumerable.Empty<RemoteImageInfo>();
|
|
|
|
return Enumerable.Empty<RemoteImageInfo>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var remoteImages = new List<RemoteImageInfo>();
|
|
|
|
var remoteImages = new RemoteImageInfo[personResult.Images.Profiles.Count];
|
|
|
|
var language = item.GetPreferredMetadataLanguage();
|
|
|
|
var language = item.GetPreferredMetadataLanguage();
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < personResult.Images.Profiles.Count; i++)
|
|
|
|
for (var i = 0; i < personResult.Images.Profiles.Count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var image = personResult.Images.Profiles[i];
|
|
|
|
var image = personResult.Images.Profiles[i];
|
|
|
|
remoteImages.Add(new RemoteImageInfo
|
|
|
|
remoteImages[i] = new RemoteImageInfo
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ProviderName = Name,
|
|
|
|
ProviderName = Name,
|
|
|
|
Type = ImageType.Primary,
|
|
|
|
Type = ImageType.Primary,
|
|
|
@ -73,15 +75,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|
|
|
Height = image.Height,
|
|
|
|
Height = image.Height,
|
|
|
|
Language = TmdbUtils.AdjustImageLanguage(image.Iso_639_1, language),
|
|
|
|
Language = TmdbUtils.AdjustImageLanguage(image.Iso_639_1, language),
|
|
|
|
Url = _tmdbClientManager.GetProfileUrl(image.FilePath)
|
|
|
|
Url = _tmdbClientManager.GetProfileUrl(image.FilePath)
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return remoteImages.OrderByLanguageDescending(language);
|
|
|
|
return remoteImages.OrderByLanguageDescending(language);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Enumerable.Empty<RemoteImageInfo>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
|
|
|
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
|
|
|
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
|
|
|