diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs index 821f837..6ff44fc 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs @@ -135,9 +135,9 @@ private async Task> FetchSeriesSearchResult(Seri { var seriesResult = await _tvdbClientManager - .GetSeriesExtendedByIdAsync(tvdbId.Value, seriesInfo.MetadataLanguage, cancellationToken, small: true) + .GetSeriesExtendedByIdAsync(tvdbId.Value, seriesInfo.MetadataLanguage, cancellationToken, meta: Meta4.Translations, small: true) .ConfigureAwait(false); - return new[] { MapSeriesToRemoteSearchResult(seriesResult) }; + return new[] { MapSeriesToRemoteSearchResult(seriesResult, seriesInfo.MetadataLanguage) }; } catch (Exception e) { @@ -146,12 +146,12 @@ await _tvdbClientManager } } - private RemoteSearchResult MapSeriesToRemoteSearchResult(SeriesExtendedRecord series) + private RemoteSearchResult MapSeriesToRemoteSearchResult(SeriesExtendedRecord series, string language) { var remoteResult = new RemoteSearchResult { - Name = series.Name, - Overview = series.Overview?.Trim() ?? string.Empty, + Name = series.Translations.GetTranslatedNamedOrDefault(language) ?? series.Name, + Overview = series.Translations.GetTranslatedOverviewOrDefault(language)?.Trim() ?? series.Overview?.Trim(), SearchProviderName = Name, ImageUrl = series.Image }; @@ -317,7 +317,7 @@ private async Task> FindSeriesInternal(string name, str { var tvdbTitles = new List { - seriesSearchResult.Name + seriesSearchResult.Translations.GetTranslatedNamedOrDefault(language) ?? seriesSearchResult.Name }; if (seriesSearchResult.Aliases is not null) { diff --git a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs index dd49e23..f8ccbfb 100644 --- a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs +++ b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs @@ -158,7 +158,7 @@ public async Task GetSeriesExtendedByIdAsync( Meta4? meta = null, bool? small = null) { - var key = $"TvdbSeriesExtended_{tvdbId.ToString(CultureInfo.InvariantCulture)}"; + var key = $"TvdbSeriesExtended_{tvdbId.ToString(CultureInfo.InvariantCulture)}_{meta}_{small}"; if (_memoryCache.TryGetValue(key, out SeriesExtendedRecord series)) { return series; @@ -186,7 +186,7 @@ public async Task GetSeriesEpisodesAsync( string seasonType, CancellationToken cancellationToken) { - var key = $"TvdbSeriesEpisodes_{tvdbId.ToString(CultureInfo.InvariantCulture)}"; + var key = $"TvdbSeriesEpisodes_{tvdbId.ToString(CultureInfo.InvariantCulture)}_{seasonType}"; if (_memoryCache.TryGetValue(key, out Data2 series)) { return series; diff --git a/Jellyfin.Plugin.Tvdb/TvdbSdkExtensions.cs b/Jellyfin.Plugin.Tvdb/TvdbSdkExtensions.cs index 5d32e00..e6e2a09 100644 --- a/Jellyfin.Plugin.Tvdb/TvdbSdkExtensions.cs +++ b/Jellyfin.Plugin.Tvdb/TvdbSdkExtensions.cs @@ -27,10 +27,23 @@ public static class TvdbSdkExtensions { return translations? .NameTranslations? - .FirstOrDefault(translation => IsMatch(translation, language))? + .FirstOrDefault(translation => IsMatch(translation.Language, language))? .Name; } + /// + /// Get the translated Name, or . + /// + /// Available translations. + /// Requested language. + /// Translated Name, or . + public static string? GetTranslatedNamedOrDefault(this TranslationSimple? translations, string? language) + { + return translations? + .FirstOrDefault(translation => IsMatch(translation.Key, language)) + .Value; + } + /// /// Get the translated Overview, or . /// @@ -41,11 +54,11 @@ public static class TvdbSdkExtensions { return translations? .OverviewTranslations? - .FirstOrDefault(translation => IsMatch(translation, language))? + .FirstOrDefault(translation => IsMatch(translation.Language, language))? .Overview; } - private static bool IsMatch(this Translation translation, string? language) + private static bool IsMatch(this string translation, string? language) { if (string.IsNullOrWhiteSpace(language)) { @@ -62,7 +75,7 @@ private static bool IsMatch(this Translation translation, string? language) // try to find a match (ISO 639-2) return TvdbCultureInfo.GetCultureInfo(language!)? .ThreeLetterISOLanguageNames? - .Contains(translation.Language, StringComparer.OrdinalIgnoreCase) + .Contains(translation, StringComparer.OrdinalIgnoreCase) ?? false; }