diff options
| author | IDisposable <IDisposable@gmail.com> | 2025-03-02 11:23:02 -0500 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2025-03-02 11:23:02 -0500 |
| commit | efb901c36976c006f2b9ad8420a06181819c9016 (patch) | |
| tree | 197cd0d3fc66cc8d60ce7942ebc4870fcfc8c089 | |
| parent | aad7506e854e5118bf70a5f103e2128f765ea7f2 (diff) | |
Backport pull request #13639 from jellyfin/release-10.10.z
Support more rating formats
Original-merge: 4f94d23011c4af755e6e05cc42f47befc7e43fcb
Merged-by: Bond-009 <bond.009@outlook.com>
Backported-by: Bond_009 <bond.009@outlook.com>
| -rw-r--r-- | Emby.Server.Implementations/Localization/LocalizationManager.cs | 6 | ||||
| -rw-r--r-- | tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index c939a5e09..754a01329 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -286,8 +286,10 @@ namespace Emby.Server.Implementations.Localization } // 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); + rating = rating.Replace("Rated :", string.Empty, StringComparison.OrdinalIgnoreCase) + .Replace("Rated:", string.Empty, StringComparison.OrdinalIgnoreCase) + .Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase) + .Trim(); // Use rating system matching the language if (!string.IsNullOrEmpty(countryCode)) diff --git a/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs index 65f018ee3..cc67dbc39 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Runtime.InteropServices; using System.Threading.Tasks; using Emby.Server.Implementations.Localization; using MediaBrowser.Controller.Configuration; @@ -116,6 +115,10 @@ namespace Jellyfin.Server.Implementations.Tests.Localization [InlineData("TV-MA", "US", 17)] [InlineData("XXX", "asdf", 1000)] [InlineData("Germany: FSK-18", "DE", 18)] + [InlineData("Rated : R", "US", 17)] + [InlineData("Rated: R", "US", 17)] + [InlineData("Rated R", "US", 17)] + [InlineData(" PG-13 ", "US", 13)] public async Task GetRatingLevel_GivenValidString_Success(string value, string countryCode, int expectedLevel) { var localizationManager = Setup(new ServerConfiguration() |
