Merge pull request #6026 from Ullmie02/tv-parental-rating-fix

Use TMDb parental rating building from movies for shows
This commit is contained in:
Bond-009 2021-05-11 11:56:34 +00:00 committed by GitHub
commit c10f86960d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

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

View File

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

View File

@ -173,5 +173,20 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
return imageLanguage; 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);
}
} }
} }