aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs7
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs16
2 files changed, 23 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index 16776b6bd..bae201c70 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -278,6 +278,13 @@ namespace Emby.Server.Implementations.Localization
return null;
}
+ // Convert integers 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))
+ {
+ return ratingAge;
+ }
+
// Fairly common for some users to have "Rated R" in their rating field
rating = rating.Replace("Rated :", string.Empty, StringComparison.OrdinalIgnoreCase);
rating = rating.Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase);
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs
index 09e4709da..0f7f5c194 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs
@@ -127,6 +127,22 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
Assert.Equal(expectedLevel, level!);
}
+ [Theory]
+ [InlineData("0", 0)]
+ [InlineData("1", 1)]
+ [InlineData("6", 6)]
+ [InlineData("12", 12)]
+ [InlineData("42", 42)]
+ [InlineData("9999", 9999)]
+ public async Task GetRatingLevel_GivenValidAge_Success(string value, int expectedLevel)
+ {
+ var localizationManager = Setup(new ServerConfiguration { MetadataCountryCode = "nl" });
+ await localizationManager.LoadAll();
+ var level = localizationManager.GetRatingLevel(value);
+ Assert.NotNull(level);
+ Assert.Equal(expectedLevel, level);
+ }
+
[Fact]
public async Task GetRatingLevel_GivenUnratedString_Success()
{