Fix Tmdb person language
This commit is contained in:
parent
138c564e8f
commit
c584d36fd4
|
@ -1,6 +1,5 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
@ -48,6 +47,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var language = item.GetPreferredMetadataLanguage();
|
||||
var person = (Person)item;
|
||||
|
||||
if (!person.TryGetProviderId(MetadataProvider.Tmdb, out var personTmdbId))
|
||||
|
@ -55,14 +55,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), cancellationToken).ConfigureAwait(false);
|
||||
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), language, cancellationToken).ConfigureAwait(false);
|
||||
if (personResult?.Images?.Profiles == null)
|
||||
{
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var remoteImages = new RemoteImageInfo[personResult.Images.Profiles.Count];
|
||||
var language = item.GetPreferredMetadataLanguage();
|
||||
|
||||
for (var i = 0; i < personResult.Images.Profiles.Count; i++)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -32,7 +31,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
{
|
||||
if (searchInfo.TryGetProviderId(MetadataProvider.Tmdb, out var personTmdbId))
|
||||
{
|
||||
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), cancellationToken).ConfigureAwait(false);
|
||||
var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (personResult != null)
|
||||
{
|
||||
|
@ -96,7 +95,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
|
||||
if (personTmdbId > 0)
|
||||
{
|
||||
var person = await _tmdbClientManager.GetPersonAsync(personTmdbId, cancellationToken).ConfigureAwait(false);
|
||||
var person = await _tmdbClientManager.GetPersonAsync(personTmdbId, id.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
result.HasMetadata = true;
|
||||
|
||||
|
|
|
@ -276,9 +276,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
/// Gets a person eg. cast or crew member from the TMDb API based on its TMDb id.
|
||||
/// </summary>
|
||||
/// <param name="personTmdbId">The person's TMDb id.</param>
|
||||
/// <param name="language">The episode's language.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb person information or null if not found.</returns>
|
||||
public async Task<Person> GetPersonAsync(int personTmdbId, CancellationToken cancellationToken)
|
||||
public async Task<Person> GetPersonAsync(int personTmdbId, string language, CancellationToken cancellationToken)
|
||||
{
|
||||
var key = $"person-{personTmdbId.ToString(CultureInfo.InvariantCulture)}";
|
||||
if (_memoryCache.TryGetValue(key, out Person person))
|
||||
|
@ -290,6 +291,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
|
||||
person = await _tmDbClient.GetPersonAsync(
|
||||
personTmdbId,
|
||||
TmdbUtils.NormalizeLanguage(language),
|
||||
PersonMethods.TvCredits | PersonMethods.MovieCredits | PersonMethods.Images | PersonMethods.ExternalIds,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -148,6 +148,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
// TMDB doesn't support Switzerland (de-CH, it-CH or fr-CH) so use the language (de, it or fr) without country code
|
||||
if (string.Equals(parts[1], "ch", StringComparison.Ordinal))
|
||||
{
|
||||
return parts[0];
|
||||
}
|
||||
|
||||
language = parts[0] + "-" + parts[1].ToUpperInvariant();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user