From 8029cd3ebb022817657e870e773ac4f1225e3b24 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 12 Feb 2019 19:50:19 +0100 Subject: [PATCH] Add better language support --- MediaBrowser.Controller/Library/TVUtils.cs | 10 ++ .../People/TvdbPersonImageProvider.cs | 2 +- .../TV/MissingEpisodeProvider.cs | 2 +- .../TV/TheTVDB/TvDbClientManager.cs | 108 +++++++++++++----- .../TV/TheTVDB/TvdbEpisodeImageProvider.cs | 6 +- .../TV/TheTVDB/TvdbEpisodeProvider.cs | 8 +- .../TV/TheTVDB/TvdbSeasonImageProvider.cs | 3 +- .../TV/TheTVDB/TvdbSeriesImageProvider.cs | 3 +- .../TV/TheTVDB/TvdbSeriesProvider.cs | 34 ++---- 9 files changed, 108 insertions(+), 68 deletions(-) diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index 0089f65d0d..355e97db15 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -17,6 +17,16 @@ namespace MediaBrowser.Controller.Library /// public static readonly string BannerUrl = TvdbBaseUrl + "banners/"; + public static string NormalizeLanguage(string language) + { + if (string.IsNullOrWhiteSpace(language)) + { + return null; + } + + // pt-br is just pt to tvdb + return language.Split('-')[0].ToLowerInvariant(); + } /// /// Gets the air days. /// diff --git a/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs b/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs index b3ffa3ca9a..86719fe830 100644 --- a/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs +++ b/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs @@ -78,7 +78,7 @@ namespace MediaBrowser.Providers.People try { - var actorsResult = await _tvDbClientManager.GetActorsAsync(tvdbId, cancellationToken); + var actorsResult = await _tvDbClientManager.GetActorsAsync(tvdbId, series.GetPreferredMetadataLanguage(), cancellationToken); var actor = actorsResult.Data.FirstOrDefault(a => string.Equals(a.Name, personName, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(a.Image)); diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 561cedb03c..f05b0d6b83 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Providers.TV return false; } - var episodes = await TvDbClientManager.Instance.GetAllEpisodesAsync(Convert.ToInt32(tvdbId), cancellationToken); + var episodes = await TvDbClientManager.Instance.GetAllEpisodesAsync(Convert.ToInt32(tvdbId), series.GetPreferredMetadataLanguage(), cancellationToken); var episodeLookup = episodes .Select(i => diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs b/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs index 44491e5113..9d63b83731 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; @@ -22,6 +23,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB private static readonly object syncRoot = new object(); private static TvDbClient tvDbClient; private static DateTime tokenCreatedAt; + private const string DefaultLanguage = "en"; private TvDbClientManager() { @@ -70,32 +72,35 @@ namespace MediaBrowser.Providers.TV.TheTVDB tokenCreatedAt = DateTime.Now; } - // Default to English - tvDbClient.AcceptedLanguage = "en"; + return tvDbClient; } } - public Task> GetSeriesByNameAsync(string name, CancellationToken cancellationToken) + public Task> GetSeriesByNameAsync(string name, string language, + CancellationToken cancellationToken) { - return TryGetValue("series" + name,() => TvDbClient.Search.SearchSeriesByNameAsync(name, cancellationToken)); + return TryGetValue("series" + name, language,() => TvDbClient.Search.SearchSeriesByNameAsync(name, cancellationToken)); } - public Task> GetSeriesByIdAsync(int tvdbId, CancellationToken cancellationToken) + public Task> GetSeriesByIdAsync(int tvdbId, string language, + CancellationToken cancellationToken) { - return TryGetValue("series" + tvdbId,() => TvDbClient.Series.GetAsync(tvdbId, cancellationToken)); + return TryGetValue("series" + tvdbId, language,() => TvDbClient.Series.GetAsync(tvdbId, cancellationToken)); } - public Task> GetEpisodesAsync(int episodeTvdbId, CancellationToken cancellationToken) + public Task> GetEpisodesAsync(int episodeTvdbId, string language, + CancellationToken cancellationToken) { - return TryGetValue("episode" + episodeTvdbId,() => TvDbClient.Episodes.GetAsync(episodeTvdbId, cancellationToken)); + return TryGetValue("episode" + episodeTvdbId, language,() => TvDbClient.Episodes.GetAsync(episodeTvdbId, cancellationToken)); } - public async Task> GetAllEpisodesAsync(int tvdbId, CancellationToken cancellationToken) + public async Task> GetAllEpisodesAsync(int tvdbId, string language, + CancellationToken cancellationToken) { // Traverse all episode pages and join them together var episodes = new List(); - var episodePage = await GetEpisodesPageAsync(tvdbId, new EpisodeQuery(), cancellationToken); + var episodePage = await GetEpisodesPageAsync(tvdbId, new EpisodeQuery(), language, cancellationToken); episodes.AddRange(episodePage.Data); if (!episodePage.Links.Next.HasValue || !episodePage.Links.Last.HasValue) { @@ -107,45 +112,51 @@ namespace MediaBrowser.Providers.TV.TheTVDB for (var page = next; page <= last; ++page) { - episodePage = await GetEpisodesPageAsync(tvdbId, page, new EpisodeQuery(), cancellationToken); + episodePage = await GetEpisodesPageAsync(tvdbId, page, new EpisodeQuery(), language, cancellationToken); episodes.AddRange(episodePage.Data); } return episodes; } - public Task> GetSeriesByImdbIdAsync(string imdbId, CancellationToken cancellationToken) + public Task> GetSeriesByImdbIdAsync(string imdbId, string language, + CancellationToken cancellationToken) { - return TryGetValue("series" + imdbId,() => TvDbClient.Search.SearchSeriesByImdbIdAsync(imdbId, cancellationToken)); + return TryGetValue("series" + imdbId, language,() => TvDbClient.Search.SearchSeriesByImdbIdAsync(imdbId, cancellationToken)); } - public Task> GetSeriesByZap2ItIdAsync(string zap2ItId, CancellationToken cancellationToken) + public Task> GetSeriesByZap2ItIdAsync(string zap2ItId, string language, + CancellationToken cancellationToken) { - return TryGetValue("series" + zap2ItId,() => TvDbClient.Search.SearchSeriesByZap2ItIdAsync(zap2ItId, cancellationToken)); + return TryGetValue("series" + zap2ItId, language,() => TvDbClient.Search.SearchSeriesByZap2ItIdAsync(zap2ItId, cancellationToken)); } - public Task> GetActorsAsync(int tvdbId, CancellationToken cancellationToken) + public Task> GetActorsAsync(int tvdbId, string language, + CancellationToken cancellationToken) { - return TryGetValue("actors" + tvdbId,() => TvDbClient.Series.GetActorsAsync(tvdbId, cancellationToken)); + return TryGetValue("actors" + tvdbId, language,() => TvDbClient.Series.GetActorsAsync(tvdbId, cancellationToken)); } - public Task> GetImagesAsync(int tvdbId, ImagesQuery imageQuery, CancellationToken cancellationToken) + public Task> GetImagesAsync(int tvdbId, ImagesQuery imageQuery, string language, + CancellationToken cancellationToken) { var cacheKey = "images" + tvdbId + "keytype" + imageQuery.KeyType + "subkey" + imageQuery.SubKey; - return TryGetValue(cacheKey,() => TvDbClient.Series.GetImagesAsync(tvdbId, imageQuery, cancellationToken)); + return TryGetValue(cacheKey, language,() => TvDbClient.Series.GetImagesAsync(tvdbId, imageQuery, cancellationToken)); } public Task> GetLanguagesAsync(CancellationToken cancellationToken) { - return TryGetValue("languages",() => TvDbClient.Languages.GetAllAsync(cancellationToken)); + return TryGetValue("languages", null,() => TvDbClient.Languages.GetAllAsync(cancellationToken)); } - public Task> GetSeriesEpisodeSummaryAsync(int tvdbId, CancellationToken cancellationToken) + public Task> GetSeriesEpisodeSummaryAsync(int tvdbId, string language, + CancellationToken cancellationToken) { - return TryGetValue("seriesepisodesummary" + tvdbId, + return TryGetValue("seriesepisodesummary" + tvdbId, language, () => TvDbClient.Series.GetEpisodesSummaryAsync(tvdbId, cancellationToken)); } - public Task> GetEpisodesPageAsync(int tvdbId, int page, EpisodeQuery episodeQuery, CancellationToken cancellationToken) + public Task> GetEpisodesPageAsync(int tvdbId, int page, EpisodeQuery episodeQuery, + string language, CancellationToken cancellationToken) { // Not quite as dynamic as it could be var cacheKey = "episodespage" + tvdbId + "page" + page; @@ -157,11 +168,13 @@ namespace MediaBrowser.Providers.TV.TheTVDB { cacheKey += "airedepisode" + episodeQuery.AiredEpisode.Value; } - return TryGetValue(cacheKey, + + return TryGetValue(cacheKey, language, () => TvDbClient.Series.GetEpisodesAsync(tvdbId, page, episodeQuery, cancellationToken)); } - public Task GetEpisodeTvdbId(EpisodeInfo searchInfo, CancellationToken cancellationToken) + public Task GetEpisodeTvdbId(EpisodeInfo searchInfo, string language, + CancellationToken cancellationToken) { searchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var seriesTvdbId); @@ -180,21 +193,23 @@ namespace MediaBrowser.Providers.TV.TheTVDB episodeQuery.FirstAired = searchInfo.PremiereDate.Value.ToString("yyyy-MM-dd"); } - return GetEpisodeTvdbId(Convert.ToInt32(seriesTvdbId), episodeQuery, cancellationToken); + return GetEpisodeTvdbId(Convert.ToInt32(seriesTvdbId), episodeQuery, cancellationToken, language); } - public async Task GetEpisodeTvdbId(int seriesTvdbId, EpisodeQuery episodeQuery, CancellationToken cancellationToken) + public async Task GetEpisodeTvdbId(int seriesTvdbId, EpisodeQuery episodeQuery, + CancellationToken cancellationToken, string language) { - var episodePage = await GetEpisodesPageAsync(Convert.ToInt32(seriesTvdbId), episodeQuery, cancellationToken); + var episodePage = await GetEpisodesPageAsync(Convert.ToInt32(seriesTvdbId), episodeQuery, language, cancellationToken); return episodePage.Data.FirstOrDefault()?.Id.ToString(); } - public Task> GetEpisodesPageAsync(int tvdbId, EpisodeQuery episodeQuery, CancellationToken cancellationToken) + public Task> GetEpisodesPageAsync(int tvdbId, EpisodeQuery episodeQuery, + string language, CancellationToken cancellationToken) { - return GetEpisodesPageAsync(tvdbId, 1, episodeQuery, cancellationToken); + return GetEpisodesPageAsync(tvdbId, 1, episodeQuery, language, cancellationToken); } - private async Task TryGetValue(object key, Func> resultFactory) + private async Task TryGetValue(string key, string language, Func> resultFactory) { if (_cache.TryGetValue(key, out T cachedValue)) { @@ -209,6 +224,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB return cachedValue; } + tvDbClient.AcceptedLanguage = TVUtils.NormalizeLanguage(language) ?? DefaultLanguage; var result = await resultFactory.Invoke(); _cache.Set(key, result, TimeSpan.FromHours(1)); return result; @@ -218,5 +234,35 @@ namespace MediaBrowser.Providers.TV.TheTVDB _cacheWriteLock.Release(); } } + + private static string GenerateKey(object[] objects) + { + var key = string.Empty; + + foreach (var obj in objects) + { + key += nameof(obj); + var objType = obj.GetType(); + if (objType.IsPrimitive || objType == typeof(string)) + { + key += obj.ToString(); + } + else + { + foreach (PropertyInfo propertyInfo in objType.GetProperties()) + { + var currentValue = propertyInfo.GetValue(obj, null); + if (currentValue == null) + { + continue; + } + + key += propertyInfo.Name + currentValue; + } + } + } + + return key; + } } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs index 49468531d5..0935b584a2 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB var episode = (Episode)item; var series = episode.Series; var imageResult = new List(); - + var language = item.GetPreferredMetadataLanguage(); if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds)) { var episodeTvdbId = episode.GetProviderId(MetadataProviders.Tvdb); @@ -66,7 +66,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB ParentIndexNumber = episode.ParentIndexNumber.Value, SeriesProviderIds = series.ProviderIds }; - episodeTvdbId = await _tvDbClientManager.GetEpisodeTvdbId(episodeInfo, cancellationToken); + episodeTvdbId = await _tvDbClientManager.GetEpisodeTvdbId(episodeInfo, language, cancellationToken); if (string.IsNullOrEmpty(episodeTvdbId)) { _logger.LogError("Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}", @@ -76,7 +76,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB } var episodeResult = - await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), cancellationToken); + await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), language, cancellationToken); var image = GetImageInfo(episodeResult.Data); if (image != null) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index 2a52b76ebd..10665135fa 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB var episodeTvdbId = searchInfo.GetProviderId(MetadataProviders.Tvdb); if (string.IsNullOrEmpty(episodeTvdbId)) { - episodeTvdbId = await _tvDbClientManager.GetEpisodeTvdbId(searchInfo, cancellationToken); + episodeTvdbId = await _tvDbClientManager.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken); if (string.IsNullOrEmpty(episodeTvdbId)) { _logger.LogError("Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}", @@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB return list; } } - var episodeResult = await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), cancellationToken); + var episodeResult = await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), searchInfo.MetadataLanguage, cancellationToken); var metadataResult = MapEpisodeToResult(searchInfo, episodeResult.Data); if (metadataResult.HasMetadata) @@ -102,7 +102,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB { if (string.IsNullOrEmpty(tvdbId)) { - tvdbId = await _tvDbClientManager.GetEpisodeTvdbId(searchInfo, cancellationToken); + tvdbId = await _tvDbClientManager.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken); if (string.IsNullOrEmpty(tvdbId)) { _logger.LogError("Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}", @@ -112,7 +112,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB } var episodeResult = await _tvDbClientManager.GetEpisodesAsync( - Convert.ToInt32(tvdbId), + Convert.ToInt32(tvdbId), searchInfo.MetadataLanguage, cancellationToken); result = MapEpisodeToResult(searchInfo, episodeResult.Data); diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs index 9218e9c089..fdd7adc461 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs @@ -65,7 +65,6 @@ namespace MediaBrowser.Providers.TV.TheTVDB var tvdbId = Convert.ToInt32(series.GetProviderId(MetadataProviders.Tvdb)); var seasonNumber = season.IndexNumber.Value; var language = item.GetPreferredMetadataLanguage(); - _tvDbClientManager.TvDbClient.AcceptedLanguage = language; var remoteImages = new List(); var keyTypes = new[] {KeyType.Season, KeyType.Seasonwide, KeyType.Fanart}; @@ -78,7 +77,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB }; try { - var imageResults = await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, cancellationToken); + var imageResults = await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken); remoteImages.AddRange(GetImages(imageResults.Data, language)); } catch (TvDbServerException) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs index b4b950be1e..66596f88db 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs @@ -58,7 +58,6 @@ namespace MediaBrowser.Providers.TV.TheTVDB } var language = item.GetPreferredMetadataLanguage(); - _tvDbClientManager.TvDbClient.AcceptedLanguage = language; var remoteImages = new List(); var keyTypes = new[] {KeyType.Poster, KeyType.Series, KeyType.Fanart}; var tvdbId = Convert.ToInt32(item.GetProviderId(MetadataProviders.Tvdb)); @@ -71,7 +70,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB try { var imageResults = - await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, cancellationToken); + await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken); remoteImages.AddRange(GetImages(imageResults.Data, language)); } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 8e5616d15e..4053cc488b 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -39,17 +39,6 @@ namespace MediaBrowser.Providers.TV.TheTVDB _tvDbClientManager = TvDbClientManager.Instance; } - private string NormalizeLanguage(string language) - { - if (string.IsNullOrWhiteSpace(language)) - { - return language; - } - - // pt-br is just pt to tvdb - return language.Split('-')[0].ToLowerInvariant(); - } - public async Task> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) { if (IsValidSeries(searchInfo.ProviderIds)) @@ -103,7 +92,6 @@ namespace MediaBrowser.Providers.TV.TheTVDB private async Task FetchSeriesData(MetadataResult result, string metadataLanguage, Dictionary seriesProviderIds, CancellationToken cancellationToken) { - _tvDbClientManager.TvDbClient.AcceptedLanguage = NormalizeLanguage(metadataLanguage); var series = result.Item; if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var tvdbId) && !string.IsNullOrEmpty(tvdbId)) @@ -126,8 +114,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB try { var seriesResult = - await _tvDbClientManager.GetSeriesByIdAsync(Convert.ToInt32(tvdbId), cancellationToken); - MapSeriesToResult(result, seriesResult.Data); + await _tvDbClientManager.GetSeriesByIdAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken); + MapSeriesToResult(result, seriesResult.Data, metadataLanguage); } catch (TvDbServerException e) { @@ -141,7 +129,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB try { - var actorsResult = await _tvDbClientManager.GetActorsAsync(Convert.ToInt32(tvdbId), cancellationToken); + var actorsResult = await _tvDbClientManager.GetActorsAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken); MapActorsToResult(result, actorsResult.Data); } catch (TvDbServerException e) @@ -152,18 +140,17 @@ namespace MediaBrowser.Providers.TV.TheTVDB private async Task GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken) { - _tvDbClientManager.TvDbClient.AcceptedLanguage = NormalizeLanguage(language); TvDbResponse result = null; try { if (string.Equals(idType, MetadataProviders.Zap2It.ToString(), StringComparison.OrdinalIgnoreCase)) { - result = await _tvDbClientManager.GetSeriesByZap2ItIdAsync(id, cancellationToken); + result = await _tvDbClientManager.GetSeriesByZap2ItIdAsync(id, language, cancellationToken); } else { - result = await _tvDbClientManager.GetSeriesByImdbIdAsync(id, cancellationToken); + result = await _tvDbClientManager.GetSeriesByImdbIdAsync(id, language, cancellationToken); } } catch (TvDbServerException e) @@ -218,13 +205,12 @@ namespace MediaBrowser.Providers.TV.TheTVDB private async Task> FindSeriesInternal(string name, string language, CancellationToken cancellationToken) { - _tvDbClientManager.TvDbClient.AcceptedLanguage = NormalizeLanguage(language); var comparableName = GetComparableName(name); var list = new List, RemoteSearchResult>>(); TvDbResponse result; try { - result = await _tvDbClientManager.GetSeriesByNameAsync(comparableName, cancellationToken); + result = await _tvDbClientManager.GetSeriesByNameAsync(comparableName, language, cancellationToken); } catch (TvDbServerException e) { @@ -252,7 +238,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB try { var seriesSesult = - await _tvDbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, cancellationToken); + await _tvDbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, cancellationToken); remoteSearchResult.SetProviderId(MetadataProviders.Imdb, seriesSesult.Data.ImdbId); remoteSearchResult.SetProviderId(MetadataProviders.Zap2It, seriesSesult.Data.Zap2itId); } @@ -329,7 +315,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB return name.Trim(); } - private void MapSeriesToResult(MetadataResult result, TvDbSharper.Dto.Series tvdbSeries) + private void MapSeriesToResult(MetadataResult result, TvDbSharper.Dto.Series tvdbSeries, string metadataLanguage) { Series series = result.Item; series.SetProviderId(MetadataProviders.Tvdb, tvdbSeries.Id.ToString()); @@ -367,14 +353,14 @@ namespace MediaBrowser.Providers.TV.TheTVDB try { var episodeSummary = _tvDbClientManager - .GetSeriesEpisodeSummaryAsync(tvdbSeries.Id, CancellationToken.None).Result.Data; + .GetSeriesEpisodeSummaryAsync(tvdbSeries.Id, metadataLanguage, CancellationToken.None).Result.Data; var maxSeasonNumber = episodeSummary.AiredSeasons.Select(s => Convert.ToInt32(s)).Max(); var episodeQuery = new EpisodeQuery { AiredSeason = maxSeasonNumber }; var episodesPage = - _tvDbClientManager.GetEpisodesPageAsync(tvdbSeries.Id, episodeQuery, CancellationToken.None).Result.Data; + _tvDbClientManager.GetEpisodesPageAsync(tvdbSeries.Id, episodeQuery, metadataLanguage, CancellationToken.None).Result.Data; result.Item.EndDate = episodesPage.Select(e => { DateTime.TryParse(e.FirstAired, out var firstAired);