aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorShadowghost <Shadowghost@users.noreply.github.com>2026-09-27 16:30:33 -0400
committerCody Robibero <cody@robibe.ro>2026-09-27 16:30:33 -0400
commitaf2d33355a6dd24e4eea3fe01858df5f55902ef3 (patch)
treeb4c0b43bb949aa540b03ed12c046c77ce8f18738 /Emby.Server.Implementations
parent64befbcdaa2718468fc015cc8224c8d71ddd001c (diff)
Backport pull request #18057 from jellyfin/release-12.z
Fix more rating systems Original-merge: e9f7544fa181658d18dede0dc38276e7d21ba9b0 Merged-by: crobibero <cody@robibe.ro> Backported-by: Cody Robibero <cody@robibe.ro>
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs42
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/0-prefer.json2
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/ar.json24
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/au.json2
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/de.json10
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/fr.json8
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/id.json25
7 files changed, 83 insertions, 30 deletions
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index 3f89237ab2..7af545c550 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -398,6 +398,7 @@ namespace Emby.Server.Implementations.Localization
return null;
}
+ var hasUnknownRating = false;
foreach (var ratingValue in ratingValues)
{
// A single entry of such a list may be unrated while a later one still resolves
@@ -406,11 +407,21 @@ namespace Emby.Server.Implementations.Localization
continue;
}
- var score = GetSingleRatingScore(ratingValue, countryCode);
+ // An unknown entry is not worth a warning of its own as long as another entry still resolves
+ var score = GetSingleRatingScore(ratingValue, countryCode, logUnknownRating: false);
if (score is not null)
{
return score;
}
+
+ hasUnknownRating = true;
+ }
+
+ if (hasUnknownRating)
+ {
+ _logger.LogWarning(
+ "None of the ratings in '{Rating}' were found in a known rating system, treating as unrated",
+ rating);
}
return null;
@@ -427,7 +438,7 @@ namespace Emby.Server.Implementations.Localization
/// <summary>
/// Resolves a single rating value to a score.
/// </summary>
- private ParentalRatingScore? GetSingleRatingScore(string rating, string? countryCode)
+ private ParentalRatingScore? GetSingleRatingScore(string rating, string? countryCode, bool logUnknownRating = true)
{
// Convert ints directly
// This may override some of the locale specific age ratings (but those always map to the same age)
@@ -483,9 +494,11 @@ namespace Emby.Server.Implementations.Localization
}
}
- // Try splitting by country prefix separator to handle "US:PG-13", "Germany: FSK-18", "DE-FSK-18"
- if (TryGetRatingScoreBySeparator(rating, ':', out var result)
- || TryGetRatingScoreBySeparator(rating, '-', out result))
+ // Try splitting by country prefix separator to handle "US:PG-13", "Germany: FSK-18", "DE-FSK-18".
+ // A '/' marks a list of ratings, which this would split into the first entry's country and the last entry's rating
+ if (!rating.Contains('/', StringComparison.Ordinal)
+ && (TryGetRatingScoreBySeparator(rating, ':', logUnknownRating, out var result)
+ || TryGetRatingScoreBySeparator(rating, '-', logUnknownRating, out result)))
{
return result;
}
@@ -493,7 +506,7 @@ namespace Emby.Server.Implementations.Localization
return null;
}
- private bool TryGetRatingScoreBySeparator(string rating, char separator, out ParentalRatingScore? result)
+ private bool TryGetRatingScoreBySeparator(string rating, char separator, bool logUnknownRating, out ParentalRatingScore? result)
{
result = null;
@@ -546,10 +559,13 @@ namespace Emby.Server.Implementations.Localization
return true;
}
- _logger.LogWarning(
- "Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated",
- rating,
- resolvedCountryCode);
+ if (logUnknownRating)
+ {
+ _logger.LogWarning(
+ "Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated",
+ rating,
+ resolvedCountryCode);
+ }
return true;
}
@@ -561,14 +577,16 @@ namespace Emby.Server.Implementations.Localization
}
/// <summary>
- /// Tries to parse a rating as a number, allowing an optional trailing '+' (e.g. "16" or "18+").
+ /// Tries to parse a rating as a number, allowing an optional trailing '+' (e.g. "16" or "18+")
+ /// or a leading '-' (e.g. the French "-12").
/// </summary>
/// <param name="ratingValue">Rating value to parse.</param>
/// <param name="score">Parsed score.</param>
/// <returns>Returns true if parsing was successful.</returns>
private static bool TryParseRatingAsScore(ReadOnlySpan<char> ratingValue, out int score)
{
- var trimmed = ratingValue.TrimEnd('+');
+ // A leading '-' marks a minimum age ("-12" is French for "not for under 12s"), never a negative score
+ var trimmed = ratingValue.TrimStart('-').TrimEnd('+');
return int.TryParse(trimmed, out score);
}
diff --git a/Emby.Server.Implementations/Localization/Ratings/0-prefer.json b/Emby.Server.Implementations/Localization/Ratings/0-prefer.json
index b390151611..dd88b35363 100644
--- a/Emby.Server.Implementations/Localization/Ratings/0-prefer.json
+++ b/Emby.Server.Implementations/Localization/Ratings/0-prefer.json
@@ -24,7 +24,7 @@
}
},
{
- "ratingStrings": ["X", "XX", "XXX", "XXXX"],
+ "ratingStrings": ["X", "XX", "XXX", "XXXX", "P"],
"ratingScore": {
"score": 1000,
"subScore": null
diff --git a/Emby.Server.Implementations/Localization/Ratings/ar.json b/Emby.Server.Implementations/Localization/Ratings/ar.json
index 73dfd2c7c9..20053fe575 100644
--- a/Emby.Server.Implementations/Localization/Ratings/ar.json
+++ b/Emby.Server.Implementations/Localization/Ratings/ar.json
@@ -3,35 +3,49 @@
"supportsSubScores": false,
"ratings": [
{
- "ratingStrings": ["ATP"],
+ "ratingStrings": ["ATP", "Apta para todo público", "G"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
- "ratingStrings": ["+13"],
+ "ratingStrings": ["SP"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["+13", "SAM 13", "SAM13", "R-13"],
"ratingScore": {
"score": 13,
"subScore": null
}
},
{
- "ratingStrings": ["+16"],
+ "ratingStrings": ["+16", "SAM 16", "SAM16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
- "ratingStrings": ["+18"],
+ "ratingStrings": ["R-17"],
+ "ratingScore": {
+ "score": 17,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["+18", "SAM 18", "SAM18"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
- "ratingStrings": ["C"],
+ "ratingStrings": ["C", "+18 C", "SAM 18 C", "SAM 18C", "SAM18C"],
"ratingScore": {
"score": 1001,
"subScore": null
diff --git a/Emby.Server.Implementations/Localization/Ratings/au.json b/Emby.Server.Implementations/Localization/Ratings/au.json
index a563df899d..c5d4c97443 100644
--- a/Emby.Server.Implementations/Localization/Ratings/au.json
+++ b/Emby.Server.Implementations/Localization/Ratings/au.json
@@ -52,7 +52,7 @@
}
},
{
- "ratingStrings": ["X", "X18", "X 18"],
+ "ratingStrings": ["X", "X18", "X 18", "X18+", "X 18+"],
"ratingScore": {
"score": 1000,
"subScore": 0
diff --git a/Emby.Server.Implementations/Localization/Ratings/de.json b/Emby.Server.Implementations/Localization/Ratings/de.json
index 30c34b230c..2a925f999f 100644
--- a/Emby.Server.Implementations/Localization/Ratings/de.json
+++ b/Emby.Server.Implementations/Localization/Ratings/de.json
@@ -3,35 +3,35 @@
"supportsSubScores": false,
"ratings": [
{
- "ratingStrings": ["0", "FSK 0", "FSK-0", "Educational", "Infoprogramm"],
+ "ratingStrings": ["0", "FSK 0", "FSK-0", "FSK0", "ab 0", "Educational", "Infoprogramm"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
- "ratingStrings": ["6", "FSK 6", "FSK-6"],
+ "ratingStrings": ["6", "FSK 6", "FSK-6", "FSK6", "ab 6"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
- "ratingStrings": ["12", "FSK 12", "FSK-12"],
+ "ratingStrings": ["12", "FSK 12", "FSK-12", "FSK12", "ab 12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
- "ratingStrings": ["16", "FSK 16", "FSK-16"],
+ "ratingStrings": ["16", "FSK 16", "FSK-16", "FSK16", "ab 16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
- "ratingStrings": ["18", "FSK 18", "FSK-18"],
+ "ratingStrings": ["18", "FSK 18", "FSK-18", "FSK18", "ab 18"],
"ratingScore": {
"score": 18,
"subScore": null
diff --git a/Emby.Server.Implementations/Localization/Ratings/fr.json b/Emby.Server.Implementations/Localization/Ratings/fr.json
index e8bafd6b87..333e467a08 100644
--- a/Emby.Server.Implementations/Localization/Ratings/fr.json
+++ b/Emby.Server.Implementations/Localization/Ratings/fr.json
@@ -24,14 +24,14 @@
}
},
{
- "ratingStrings": ["10"],
+ "ratingStrings": ["10", "Interdit aux moins de 10 ans"],
"ratingScore": {
"score": 10,
"subScore": null
}
},
{
- "ratingStrings": ["12"],
+ "ratingStrings": ["12", "–12", "Interdit aux moins de 12 ans"],
"ratingScore": {
"score": 12,
"subScore": null
@@ -45,14 +45,14 @@
}
},
{
- "ratingStrings": ["16"],
+ "ratingStrings": ["16", "–16", "Interdit aux moins de 16 ans"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
- "ratingStrings": ["18"],
+ "ratingStrings": ["18", "–18", "Interdit aux moins de 18 ans"],
"ratingScore": {
"score": 18,
"subScore": null
diff --git a/Emby.Server.Implementations/Localization/Ratings/id.json b/Emby.Server.Implementations/Localization/Ratings/id.json
index 8c687c2320..f55e4e4333 100644
--- a/Emby.Server.Implementations/Localization/Ratings/id.json
+++ b/Emby.Server.Implementations/Localization/Ratings/id.json
@@ -3,14 +3,28 @@
"supportsSubScores": false,
"ratings": [
{
- "ratingStrings": ["SU"],
+ "ratingStrings": ["SU", "SU-BO", "Semua Umur"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
- "ratingStrings": ["13+"],
+ "ratingStrings": ["P", "P2+", "P-BO", "Prasekolah"],
+ "ratingScore": {
+ "score": 2,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["A", "A7+", "A-BO", "Anak"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["13+", "R", "R13+", "R-BO", "Remaja"],
"ratingScore": {
"score": 13,
"subScore": null
@@ -24,6 +38,13 @@
}
},
{
+ "ratingStrings": ["D", "D18+", "Dewasa"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
"ratingStrings": ["21+"],
"ratingScore": {
"score": 21,