mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-06 14:22:55 +01:00
Merge pull request #17239 from theguymadmax/ratings-separator
Fix parental rating lookup for multi-rating entries
This commit is contained in:
@@ -356,6 +356,27 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
{
|
{
|
||||||
ArgumentException.ThrowIfNullOrEmpty(rating);
|
ArgumentException.ThrowIfNullOrEmpty(rating);
|
||||||
|
|
||||||
|
// Some providers may list multiple ratings separated by '/' (e.g. "SE:15 / SE:15+ / SE:Från 15 år").
|
||||||
|
// Try each one in order and use the first that resolves.
|
||||||
|
var ratingValues = rating.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
|
||||||
|
foreach (var ratingValue in ratingValues)
|
||||||
|
{
|
||||||
|
var score = GetSingleRatingScore(ratingValue, countryCode);
|
||||||
|
if (score is not null)
|
||||||
|
{
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves a single rating value to a score.
|
||||||
|
/// </summary>
|
||||||
|
private ParentalRatingScore? GetSingleRatingScore(string rating, string? countryCode)
|
||||||
|
{
|
||||||
// Handle unrated content
|
// Handle unrated content
|
||||||
if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
|
if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user