mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-15 18:53:27 +01:00
Check numeric rating value after splitting country code
This commit is contained in:
@@ -385,7 +385,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
|
|
||||||
// Convert ints directly
|
// Convert ints directly
|
||||||
// This may override some of the locale specific age ratings (but those always map to the same age)
|
// This may override some of the locale specific age ratings (but those always map to the same age)
|
||||||
if (int.TryParse(rating, out var ratingAge))
|
if (TryParseRatingAsScore(rating, out var ratingAge))
|
||||||
{
|
{
|
||||||
return new(ratingAge, null);
|
return new(ratingAge, null);
|
||||||
}
|
}
|
||||||
@@ -487,6 +487,13 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it's not a recognized rating string, fall back to using the number as the score
|
||||||
|
if (TryParseRatingAsScore(ratingPart, out var numericScore))
|
||||||
|
{
|
||||||
|
result = new ParentalRatingScore(numericScore, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogWarning(
|
_logger.LogWarning(
|
||||||
"Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated",
|
"Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated",
|
||||||
rating,
|
rating,
|
||||||
@@ -501,6 +508,18 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to parse a rating as a number, allowing an optional trailing '+' (e.g. "16" or "18+").
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ratingValue">Rating value to parse.</param>
|
||||||
|
/// <param name="score">Parsed score.</param>
|
||||||
|
/// <returns>Returns true if parsing was successful.</returns>
|
||||||
|
private static bool TryParseRatingAsScore(string ratingValue, out int score)
|
||||||
|
{
|
||||||
|
var trimmed = ratingValue.TrimEnd('+');
|
||||||
|
return int.TryParse(trimmed, out score);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GetLocalizedString(string phrase)
|
public string GetLocalizedString(string phrase)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user