Use TMDb parental rating building from movies for shows

This commit is contained in:
David Ullmer 2021-05-10 20:51:41 +02:00
parent b9163ff2aa
commit cb01dd8684
3 changed files with 17 additions and 7 deletions

View File

@ -206,12 +206,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
if (ourRelease != null)
{
var ratingPrefix = string.Equals(info.MetadataCountryCode, "us", StringComparison.OrdinalIgnoreCase) ? string.Empty : info.MetadataCountryCode + "-";
var newRating = ratingPrefix + ourRelease.Certification;
newRating = newRating.Replace("de-", "FSK-", StringComparison.OrdinalIgnoreCase);
movie.OfficialRating = newRating;
movie.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Certification);
}
else if (usRelease != null)
{

View File

@ -300,7 +300,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
if (ourRelease != null)
{
series.OfficialRating = ourRelease.Rating;
series.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Rating);
}
else if (usRelease != null)
{

View File

@ -173,5 +173,20 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
return imageLanguage;
}
/// <summary>
/// Combines the metadata country code and the parental rating from the Api into the value we store in our database.
/// </summary>
/// <param name="countryCode">The Iso 3166-1 country code of the rating country.</param>
/// <param name="ratingValue">The rating value returned by the Tmdb Api.</param>
/// <returns>The combined parental rating of country code+rating value.</returns>
public static string BuildParentalRating(string countryCode, string ratingValue)
{
// exclude US because we store us values as TV-14 without the country code.
var ratingPrefix = string.Equals(countryCode, "US", StringComparison.OrdinalIgnoreCase) ? string.Empty : countryCode + "-";
var newRating = ratingPrefix + ratingValue;
return newRating.Replace("DE-", "FSK-", StringComparison.OrdinalIgnoreCase);
}
}
}