From 8bf1710e0771eaebfa2933d0f7849484566f2bd5 Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Wed, 8 Jul 2026 20:09:49 -0400 Subject: [PATCH 1/2] Check numeric rating value after splitting country code --- .../Localization/LocalizationManager.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 98f629d31c..c3e77bb87f 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -385,7 +385,7 @@ namespace Emby.Server.Implementations.Localization // Convert ints directly // 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); } @@ -487,6 +487,13 @@ namespace Emby.Server.Implementations.Localization 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( "Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated", rating, @@ -501,6 +508,18 @@ namespace Emby.Server.Implementations.Localization return true; } + /// + /// Tries to parse a rating as a number, allowing an optional trailing '+' (e.g. "16" or "18+"). + /// + /// Rating value to parse. + /// Parsed score. + /// Returns true if parsing was successful. + private static bool TryParseRatingAsScore(string ratingValue, out int score) + { + var trimmed = ratingValue.TrimEnd('+'); + return int.TryParse(trimmed, out score); + } + /// public string GetLocalizedString(string phrase) { From 2aae53bc152682ddf845d6ba17e4cb109d39bca8 Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Sun, 12 Jul 2026 11:54:56 -0400 Subject: [PATCH 2/2] Apply review feedback --- Emby.Server.Implementations/Localization/LocalizationManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index c3e77bb87f..e7dd984ec4 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -514,7 +514,7 @@ namespace Emby.Server.Implementations.Localization /// Rating value to parse. /// Parsed score. /// Returns true if parsing was successful. - private static bool TryParseRatingAsScore(string ratingValue, out int score) + private static bool TryParseRatingAsScore(ReadOnlySpan ratingValue, out int score) { var trimmed = ratingValue.TrimEnd('+'); return int.TryParse(trimmed, out score);