mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 08:23:28 -03:00
Backport pull request #15793 from jellyfin/release-10.11.z
Prefer US rating on fallback
Original-merge: 156761405e
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
@@ -311,15 +311,19 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Fall back to server default language for ratings check
|
// Fall back to server default language for ratings check
|
||||||
// If it has no ratings, use the US ratings
|
var ratingsDictionary = GetParentalRatingsDictionary();
|
||||||
var ratingsDictionary = GetParentalRatingsDictionary() ?? GetParentalRatingsDictionary("us");
|
|
||||||
if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRatingScore? value))
|
if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRatingScore? value))
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't find anything, check all ratings systems
|
// If we don't find anything, check all ratings systems, starting with US
|
||||||
|
if (_allParentalRatings.TryGetValue("us", out var usRatings) && usRatings.TryGetValue(rating, out var usValue))
|
||||||
|
{
|
||||||
|
return usValue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var dictionary in _allParentalRatings.Values)
|
foreach (var dictionary in _allParentalRatings.Values)
|
||||||
{
|
{
|
||||||
if (dictionary.TryGetValue(rating, out var value))
|
if (dictionary.TryGetValue(rating, out var value))
|
||||||
|
|||||||
@@ -203,6 +203,25 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
|
|||||||
Assert.Null(localizationManager.GetRatingScore(value));
|
Assert.Null(localizationManager.GetRatingScore(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("TV-MA", "DE", 17, 1)] // US-only rating, DE country code
|
||||||
|
[InlineData("PG-13", "FR", 13, 0)] // US-only rating, FR country code
|
||||||
|
[InlineData("R", "JP", 17, 0)] // US-only rating, JP country code
|
||||||
|
public async Task GetRatingScore_FallbackPrioritizesUS_Success(string rating, string countryCode, int expectedScore, int? expectedSubScore)
|
||||||
|
{
|
||||||
|
var localizationManager = Setup(new ServerConfiguration()
|
||||||
|
{
|
||||||
|
MetadataCountryCode = countryCode
|
||||||
|
});
|
||||||
|
await localizationManager.LoadAll();
|
||||||
|
|
||||||
|
var score = localizationManager.GetRatingScore(rating);
|
||||||
|
|
||||||
|
Assert.NotNull(score);
|
||||||
|
Assert.Equal(expectedScore, score.Score);
|
||||||
|
Assert.Equal(expectedSubScore, score.SubScore);
|
||||||
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("Default", "Default")]
|
[InlineData("Default", "Default")]
|
||||||
[InlineData("HeaderLiveTV", "Live TV")]
|
[InlineData("HeaderLiveTV", "Live TV")]
|
||||||
|
|||||||
Reference in New Issue
Block a user