Rework parental ratings (#12615)

This commit is contained in:
Tim Eisele 2025-03-31 05:51:54 +02:00 committed by GitHub
parent 2ace880345
commit 3fc3b04daf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
80 changed files with 3995 additions and 805 deletions

View File

@ -68,6 +68,6 @@
<EmbeddedResource Include="Localization\iso6392.txt" />
<EmbeddedResource Include="Localization\countries.json" />
<EmbeddedResource Include="Localization\Core\*.json" />
<EmbeddedResource Include="Localization\Ratings\*.csv" />
<EmbeddedResource Include="Localization\Ratings\*.json" />
</ItemGroup>
</Project>

View File

@ -11,7 +11,6 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Library;
@ -78,15 +77,15 @@ public class SplashscreenPostScanTask : ILibraryPostScanTask
CollapseBoxSetItems = false,
Recursive = true,
DtoOptions = new DtoOptions(false),
ImageTypes = new[] { imageType },
ImageTypes = [imageType],
Limit = 30,
// TODO max parental rating configurable
MaxParentalRating = 10,
OrderBy = new[]
{
MaxParentalRating = new(10, null),
OrderBy =
[
(ItemSortBy.Random, SortOrder.Ascending)
},
IncludeItemTypes = new[] { BaseItemKind.Movie, BaseItemKind.Series }
],
IncludeItemTypes = [BaseItemKind.Movie, BaseItemKind.Series]
});
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@ -26,20 +25,18 @@ namespace Emby.Server.Implementations.Localization
private const string CulturesPath = "Emby.Server.Implementations.Localization.iso6392.txt";
private const string CountriesPath = "Emby.Server.Implementations.Localization.countries.json";
private static readonly Assembly _assembly = typeof(LocalizationManager).Assembly;
private static readonly string[] _unratedValues = { "n/a", "unrated", "not rated", "nr" };
private static readonly string[] _unratedValues = ["n/a", "unrated", "not rated", "nr"];
private readonly IServerConfigurationManager _configurationManager;
private readonly ILogger<LocalizationManager> _logger;
private readonly Dictionary<string, Dictionary<string, ParentalRating>> _allParentalRatings =
new Dictionary<string, Dictionary<string, ParentalRating>>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, Dictionary<string, ParentalRatingScore?>> _allParentalRatings = new(StringComparer.OrdinalIgnoreCase);
private readonly ConcurrentDictionary<string, Dictionary<string, string>> _dictionaries =
new ConcurrentDictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
private readonly ConcurrentDictionary<string, Dictionary<string, string>> _dictionaries = new(StringComparer.OrdinalIgnoreCase);
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
private List<CultureDto> _cultures = new List<CultureDto>();
private List<CultureDto> _cultures = [];
/// <summary>
/// Initializes a new instance of the <see cref="LocalizationManager" /> class.
@ -68,35 +65,26 @@ namespace Emby.Server.Implementations.Localization
continue;
}
string countryCode = resource.Substring(RatingsPath.Length, 2);
var dict = new Dictionary<string, ParentalRating>(StringComparer.OrdinalIgnoreCase);
var stream = _assembly.GetManifestResourceStream(resource);
await using (stream!.ConfigureAwait(false)) // shouldn't be null here, we just got the resource path from Assembly.GetManifestResourceNames()
using var stream = _assembly.GetManifestResourceStream(resource);
if (stream is not null)
{
using var reader = new StreamReader(stream!);
await foreach (var line in reader.ReadAllLinesAsync().ConfigureAwait(false))
var ratingSystem = await JsonSerializer.DeserializeAsync<ParentalRatingSystem>(stream, _jsonOptions).ConfigureAwait(false)
?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'");
var dict = new Dictionary<string, ParentalRatingScore?>();
if (ratingSystem.Ratings is not null)
{
if (string.IsNullOrWhiteSpace(line))
foreach (var ratingEntry in ratingSystem.Ratings)
{
continue;
foreach (var ratingString in ratingEntry.RatingStrings)
{
dict[ratingString] = ratingEntry.RatingScore;
}
}
string[] parts = line.Split(',');
if (parts.Length == 2
&& int.TryParse(parts[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
{
var name = parts[0];
dict.Add(name, new ParentalRating(name, value));
}
else
{
_logger.LogWarning("Malformed line in ratings file for country {CountryCode}", countryCode);
}
_allParentalRatings[ratingSystem.CountryCode] = dict;
}
}
_allParentalRatings[countryCode] = dict;
}
await LoadCultures().ConfigureAwait(false);
@ -111,22 +99,29 @@ namespace Emby.Server.Implementations.Localization
private async Task LoadCultures()
{
List<CultureDto> list = new List<CultureDto>();
List<CultureDto> list = [];
await using var stream = _assembly.GetManifestResourceStream(CulturesPath)
?? throw new InvalidOperationException($"Invalid resource path: '{CulturesPath}'");
using var reader = new StreamReader(stream);
await foreach (var line in reader.ReadAllLinesAsync().ConfigureAwait(false))
using var stream = _assembly.GetManifestResourceStream(CulturesPath);
if (stream is null)
{
if (string.IsNullOrWhiteSpace(line))
throw new InvalidOperationException($"Invalid resource path: '{CulturesPath}'");
}
else
{
using var reader = new StreamReader(stream);
await foreach (var line in reader.ReadAllLinesAsync().ConfigureAwait(false))
{
continue;
}
if (string.IsNullOrWhiteSpace(line))
{
continue;
}
var parts = line.Split('|');
var parts = line.Split('|');
if (parts.Length != 5)
{
throw new InvalidDataException($"Invalid culture data found at: '{line}'");
}
if (parts.Length == 5)
{
string name = parts[3];
if (string.IsNullOrWhiteSpace(name))
{
@ -139,21 +134,21 @@ namespace Emby.Server.Implementations.Localization
continue;
}
string[] threeletterNames;
string[] threeLetterNames;
if (string.IsNullOrWhiteSpace(parts[1]))
{
threeletterNames = new[] { parts[0] };
threeLetterNames = [parts[0]];
}
else
{
threeletterNames = new[] { parts[0], parts[1] };
threeLetterNames = [parts[0], parts[1]];
}
list.Add(new CultureDto(name, name, twoCharName, threeletterNames));
list.Add(new CultureDto(name, name, twoCharName, threeLetterNames));
}
}
_cultures = list;
_cultures = list;
}
}
/// <inheritdoc />
@ -176,82 +171,80 @@ namespace Emby.Server.Implementations.Localization
}
/// <inheritdoc />
public IEnumerable<CountryInfo> GetCountries()
public IReadOnlyList<CountryInfo> GetCountries()
{
using StreamReader reader = new StreamReader(
_assembly.GetManifestResourceStream(CountriesPath) ?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'"));
return JsonSerializer.Deserialize<IEnumerable<CountryInfo>>(reader.ReadToEnd(), _jsonOptions)
?? throw new InvalidOperationException($"Resource contains invalid data: '{CountriesPath}'");
using var stream = _assembly.GetManifestResourceStream(CountriesPath) ?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'");
return JsonSerializer.Deserialize<IReadOnlyList<CountryInfo>>(stream, _jsonOptions) ?? [];
}
/// <inheritdoc />
public IEnumerable<ParentalRating> GetParentalRatings()
public IReadOnlyList<ParentalRating> GetParentalRatings()
{
// Use server default language for ratings
// Fall back to empty list if there are no parental ratings for that language
var ratings = GetParentalRatingsDictionary()?.Values.ToList()
?? new List<ParentalRating>();
var ratings = GetParentalRatingsDictionary()?.Select(x => new ParentalRating(x.Key, x.Value)).ToList() ?? [];
// Add common ratings to ensure them being available for selection
// Based on the US rating system due to it being the main source of rating in the metadata providers
// Unrated
if (!ratings.Any(x => x.Value is null))
if (!ratings.Any(x => x is null))
{
ratings.Add(new ParentalRating("Unrated", null));
ratings.Add(new("Unrated", null));
}
// Minimum rating possible
if (ratings.All(x => x.Value != 0))
if (ratings.All(x => x.RatingScore?.Score != 0))
{
ratings.Add(new ParentalRating("Approved", 0));
ratings.Add(new("Approved", new(0, null)));
}
// Matches PG (this has different age restrictions depending on country)
if (ratings.All(x => x.Value != 10))
if (ratings.All(x => x.RatingScore?.Score != 10))
{
ratings.Add(new ParentalRating("10", 10));
ratings.Add(new("10", new(10, null)));
}
// Matches PG-13
if (ratings.All(x => x.Value != 13))
if (ratings.All(x => x.RatingScore?.Score != 13))
{
ratings.Add(new ParentalRating("13", 13));
ratings.Add(new("13", new(13, null)));
}
// Matches TV-14
if (ratings.All(x => x.Value != 14))
if (ratings.All(x => x.RatingScore?.Score != 14))
{
ratings.Add(new ParentalRating("14", 14));
ratings.Add(new("14", new(14, null)));
}
// Catchall if max rating of country is less than 21
// Using 21 instead of 18 to be sure to allow access to all rated content except adult and banned
if (!ratings.Any(x => x.Value >= 21))
if (!ratings.Any(x => x.RatingScore?.Score >= 21))
{
ratings.Add(new ParentalRating("21", 21));
ratings.Add(new ParentalRating("21", new(21, null)));
}
// A lot of countries don't explicitly have a separate rating for adult content
if (ratings.All(x => x.Value != 1000))
if (ratings.All(x => x.RatingScore?.Score != 1000))
{
ratings.Add(new ParentalRating("XXX", 1000));
ratings.Add(new ParentalRating("XXX", new(1000, null)));
}
// A lot of countries don't explicitly have a separate rating for banned content
if (ratings.All(x => x.Value != 1001))
if (ratings.All(x => x.RatingScore?.Score != 1001))
{
ratings.Add(new ParentalRating("Banned", 1001));
ratings.Add(new ParentalRating("Banned", new(1001, null)));
}
return ratings.OrderBy(r => r.Value);
return [.. ratings.OrderBy(r => r.RatingScore?.Score).ThenBy(r => r.RatingScore?.SubScore)];
}
/// <summary>
/// Gets the parental ratings dictionary.
/// </summary>
/// <param name="countryCode">The optional two letter ISO language string.</param>
/// <returns><see cref="Dictionary{String, ParentalRating}" />.</returns>
private Dictionary<string, ParentalRating>? GetParentalRatingsDictionary(string? countryCode = null)
/// <returns><see cref="Dictionary{String, ParentalRatingScore}" />.</returns>
private Dictionary<string, ParentalRatingScore?>? GetParentalRatingsDictionary(string? countryCode = null)
{
// Fallback to server default if no country code is specified.
if (string.IsNullOrEmpty(countryCode))
@ -268,7 +261,7 @@ namespace Emby.Server.Implementations.Localization
}
/// <inheritdoc />
public int? GetRatingLevel(string rating, string? countryCode = null)
public ParentalRatingScore? GetRatingScore(string rating, string? countryCode = null)
{
ArgumentException.ThrowIfNullOrEmpty(rating);
@ -278,11 +271,11 @@ namespace Emby.Server.Implementations.Localization
return null;
}
// Convert integers directly
// Convert ints 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;
return new(ratingAge, null);
}
// Fairly common for some users to have "Rated R" in their rating field
@ -295,9 +288,9 @@ namespace Emby.Server.Implementations.Localization
if (!string.IsNullOrEmpty(countryCode))
{
var ratingsDictionary = GetParentalRatingsDictionary(countryCode);
if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRating? value))
if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRatingScore? value))
{
return value.Value;
return value;
}
}
else
@ -305,9 +298,9 @@ namespace Emby.Server.Implementations.Localization
// Fall back to server default language for ratings check
// If it has no ratings, use the US ratings
var ratingsDictionary = GetParentalRatingsDictionary() ?? GetParentalRatingsDictionary("us");
if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRating? value))
if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRatingScore? value))
{
return value.Value;
return value;
}
}
@ -316,7 +309,7 @@ namespace Emby.Server.Implementations.Localization
{
if (dictionary.TryGetValue(rating, out var value))
{
return value.Value;
return value;
}
}
@ -326,7 +319,7 @@ namespace Emby.Server.Implementations.Localization
var ratingLevelRightPart = rating.AsSpan().RightPart(':');
if (ratingLevelRightPart.Length != 0)
{
return GetRatingLevel(ratingLevelRightPart.ToString());
return GetRatingScore(ratingLevelRightPart.ToString());
}
}
@ -342,7 +335,7 @@ namespace Emby.Server.Implementations.Localization
if (ratingLevelRightPart.Length != 0)
{
// Check rating system of culture
return GetRatingLevel(ratingLevelRightPart.ToString(), culture?.TwoLetterISOLanguageName);
return GetRatingScore(ratingLevelRightPart.ToString(), culture?.TwoLetterISOLanguageName);
}
}
@ -406,7 +399,7 @@ namespace Emby.Server.Implementations.Localization
private async Task CopyInto(IDictionary<string, string> dictionary, string resourcePath)
{
await using var stream = _assembly.GetManifestResourceStream(resourcePath);
using var stream = _assembly.GetManifestResourceStream(resourcePath);
// If a Culture doesn't have a translation the stream will be null and it defaults to en-us further up the chain
if (stream is null)
{
@ -414,12 +407,7 @@ namespace Emby.Server.Implementations.Localization
return;
}
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(stream, _jsonOptions).ConfigureAwait(false);
if (dict is null)
{
throw new InvalidOperationException($"Resource contains invalid data: '{stream}'");
}
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(stream, _jsonOptions).ConfigureAwait(false) ?? throw new InvalidOperationException($"Resource contains invalid data: '{stream}'");
foreach (var key in dict.Keys)
{
dictionary[key] = dict[key];

View File

@ -1,11 +0,0 @@
E,0
EC,0
T,7
M,18
AO,18
UR,18
RP,18
X,1000
XX,1000
XXX,1000
XXXX,1000
1 E 0
2 EC 0
3 T 7
4 M 18
5 AO 18
6 UR 18
7 RP 18
8 X 1000
9 XX 1000
10 XXX 1000
11 XXXX 1000

View File

@ -0,0 +1,34 @@
{
"countryCode": "0-prefer",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["E", "EC"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["T"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["M", "AO", "UR", "RP"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["X", "XX", "XXX", "XXXX"],
"ratingScore": {
"score": 1000,
"subScore": null
}
}
]
}

View File

@ -1,17 +0,0 @@
Exempt,0
G,0
7+,7
PG,15
M,15
MA,15
MA15+,15
MA 15+,15
16+,16
R,18
R18+,18
R 18+,18
18+,18
X18+,1000
X 18+,1000
X,1000
RC,1001
1 Exempt 0
2 G 0
3 7+ 7
4 PG 15
5 M 15
6 MA 15
7 MA15+ 15
8 MA 15+ 15
9 16+ 16
10 R 18
11 R18+ 18
12 R 18+ 18
13 18+ 18
14 X18+ 1000
15 X 18+ 1000
16 X 1000
17 RC 1001

View File

@ -0,0 +1,69 @@
{
"countryCode": "au",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["Exempt", "G"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["7+"],
"ratingScore": {
"score": 7,
"subScore": 0
}
},
{
"ratingStrings": ["PG"],
"ratingScore": {
"score": 15,
"subScore": 1
}
},
{
"ratingStrings": ["M"],
"ratingScore": {
"score": 15,
"subScore": 2
}
},
{
"ratingStrings": ["MA", "MA 15+", "MA15+"],
"ratingScore": {
"score": 15,
"subScore": 3
}
},
{
"ratingStrings": ["16+"],
"ratingScore": {
"score": 16,
"subScore": 0
}
},
{
"ratingStrings": ["18+", "R", "R18+", "R 18+"],
"ratingScore": {
"score": 18,
"subScore": 1
}
},
{
"ratingStrings": ["X", "X18", "X 18"],
"ratingScore": {
"score": 1000,
"subScore": 0
}
},
{
"ratingStrings": ["RC"],
"ratingScore": {
"score": 1001,
"subScore": 0
}
}
]
}

View File

@ -1,11 +0,0 @@
AL,0
KT,0
TOUS,0
MG6,6
6,6
9,9
KNT,12
12,12
14,14
16,16
18,18
1 AL 0
2 KT 0
3 TOUS 0
4 MG6 6
5 6 6
6 9 9
7 KNT 12
8 12 12
9 14 14
10 16 16
11 18 18

View File

@ -0,0 +1,55 @@
{
"countryCode": "be",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["AL", "KT", "TOUS"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6", "MG6"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["9"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["12", "KNT"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,14 +0,0 @@
Livre,0
L,0
AL,0
ER,10
10,10
A10,10
12,12
A12,12
14,14
A14,14
16,16
A16,16
18,18
A18,18
1 Livre 0
2 L 0
3 AL 0
4 ER 10
5 10 10
6 A10 10
7 12 12
8 A12 12
9 14 14
10 A14 14
11 16 16
12 A16 16
13 18 18
14 A18 18

View File

@ -0,0 +1,55 @@
{
"countryCode": "br",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["L", "AL", "Livre"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["9"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["10", "A10", "ER"],
"ratingScore": {
"score": 10,
"subScore": null
}
},
{
"ratingStrings": ["12", "A12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["14", "A14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["16", "A16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18", "A18"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,18 +0,0 @@
E,0
G,0
TV-Y,0
TV-G,0
TV-Y7,7
TV-Y7-FV,7
PG,9
TV-PG,9
TV-14,14
14A,14
16+,16
NC-17,17
R,18
TV-MA,18
18A,18
18+,18
A,1000
Prohibited,1001
1 E 0
2 G 0
3 TV-Y 0
4 TV-G 0
5 TV-Y7 7
6 TV-Y7-FV 7
7 PG 9
8 TV-PG 9
9 TV-14 14
10 14A 14
11 16+ 16
12 NC-17 17
13 R 18
14 TV-MA 18
15 18A 18
16 18+ 18
17 A 1000
18 Prohibited 1001

View File

@ -0,0 +1,90 @@
{
"countryCode": "ca",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["E", "G", "TV-Y", "TV-G"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["TV-Y7"],
"ratingScore": {
"score": 7,
"subScore": 0
}
},
{
"ratingStrings": ["TV-Y7-FV"],
"ratingScore": {
"score": 7,
"subScore": 1
}
},
{
"ratingStrings": ["PG", "TV-PG"],
"ratingScore": {
"score": 9,
"subScore": 0
}
},
{
"ratingStrings": ["14A"],
"ratingScore": {
"score": 14,
"subScore": 0
}
},
{
"ratingStrings": ["TV-14"],
"ratingScore": {
"score": 14,
"subScore": 1
}
},
{
"ratingStrings": ["16+"],
"ratingScore": {
"score": 16,
"subScore": 0
}
},
{
"ratingStrings": ["NC-17"],
"ratingScore": {
"score": 17,
"subScore": 0
}
},
{
"ratingStrings": ["18A"],
"ratingScore": {
"score": 18,
"subScore": 0
}
},
{
"ratingStrings": ["18+", "TV-MA", "R"],
"ratingScore": {
"score": 18,
"subScore": 1
}
},
{
"ratingStrings": ["A"],
"ratingScore": {
"score": 1000,
"subScore": 0
}
},
{
"ratingStrings": ["Prohibited"],
"ratingScore": {
"score": 1001,
"subScore": 0
}
}
]
}

View File

@ -0,0 +1,41 @@
{
"countryCode": "cl",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["TE"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["TE+7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["18", "18V", "18S"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,7 +0,0 @@
T,0
7,7
12,12
15,15
18,18
X,1000
Prohibited,1001
1 T 0
2 7 7
3 12 12
4 15 15
5 18 18
6 X 1000
7 Prohibited 1001

View File

@ -0,0 +1,55 @@
{
"countryCode": "co",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["T"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": null
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["X"],
"ratingScore": {
"score": 1000,
"subScore": null
}
},
{
"ratingStrings": ["Prohibited"],
"ratingScore": {
"score": 1001,
"subScore": null
}
}
]
}

View File

@ -1,17 +0,0 @@
Educational,0
Infoprogramm,0
FSK-0,0
FSK 0,0
0,0
FSK-6,6
FSK 6,6
6,6
FSK-12,12
FSK 12,12
12,12
FSK-16,16
FSK 16,16
16,16
FSK-18,18
FSK 18,18
18,18
1 Educational 0
2 Infoprogramm 0
3 FSK-0 0
4 FSK 0 0
5 0 0
6 FSK-6 6
7 FSK 6 6
8 6 6
9 FSK-12 12
10 FSK 12 12
11 12 12
12 FSK-16 16
13 FSK 16 16
14 16 16
15 FSK-18 18
16 FSK 18 18
17 18 18

View File

@ -0,0 +1,41 @@
{
"countryCode": "de",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["0", "FSK 0", "FSK-0", "Educational", "Infoprogramm"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6", "FSK 6", "FSK-6"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["12", "FSK 12", "FSK-12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["16", "FSK 16", "FSK-16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18", "FSK 18", "FSK-18"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,7 +0,0 @@
F,0
A,0
7,7
11,11
12,12
15,15
16,16
1 F 0
2 A 0
3 7 7
4 11 11
5 12 12
6 15 15
7 16 16

View File

@ -0,0 +1,48 @@
{
"countryCode": "dk",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["F", "A"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["11"],
"ratingScore": {
"score": 11,
"subScore": null
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": null
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": null
}
}
]
}

View File

@ -1,25 +0,0 @@
A,0
A/fig,0
A/i,0
A/i/fig,0
APTA,0
ERI,0
TP,0
0+,0
6+,6
7/fig,7
7/i,7
7/i/fig,7
7,7
9+,9
10,10
12,12
12/fig,12
13,13
14,14
16,16
16/fig,16
18,18
18/fig,18
X,1000
Banned,1001
1 A 0
2 A/fig 0
3 A/i 0
4 A/i/fig 0
5 APTA 0
6 ERI 0
7 TP 0
8 0+ 0
9 6+ 6
10 7/fig 7
11 7/i 7
12 7/i/fig 7
13 7 7
14 9+ 9
15 10 10
16 12 12
17 12/fig 12
18 13 13
19 14 14
20 16 16
21 16/fig 16
22 18 18
23 18/fig 18
24 X 1000
25 Banned 1001

View File

@ -0,0 +1,90 @@
{
"countryCode": "es",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["0+", "A", "A/i", "A/fig", "A/i/fig", "APTA", "ERI", "TP"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6+"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["7", "7/i", "7/fig", "7/i/fig"],
"ratingScore": {
"score": 11,
"subScore": null
}
},
{
"ratingStrings": ["9+"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["10"],
"ratingScore": {
"score": 10,
"subScore": null
}
},
{
"ratingStrings": ["12", "12/fig"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["13"],
"ratingScore": {
"score": 13,
"subScore": null
}
},
{
"ratingStrings": ["14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["16", "16/fig"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18", "18/fig"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["X"],
"ratingScore": {
"score": 1000,
"subScore": null
}
},
{
"ratingStrings": ["Banned"],
"ratingScore": {
"score": 1001,
"subScore": null
}
}
]
}

View File

@ -1,10 +0,0 @@
S,0
T,0
K7,7
7,7
K12,12
12,12
K16,16
16,16
K18,18
18,18
1 S 0
2 T 0
3 K7 7
4 7 7
5 K12 12
6 12 12
7 K16 16
8 16 16
9 K18 18
10 18 18

View File

@ -0,0 +1,41 @@
{
"countryCode": "fi",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["S", "T"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["7", "K7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["12", "K12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["16", "K16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18", "K18"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,13 +0,0 @@
Public Averti,0
Tous Publics,0
TP,0
U,0
0+,0
6+,6
9+,9
10,10
12,12
14+,14
16,16
18,18
X,1000
1 Public Averti 0
2 Tous Publics 0
3 TP 0
4 U 0
5 0+ 0
6 6+ 6
7 9+ 9
8 10 10
9 12 12
10 14+ 14
11 16 16
12 18 18
13 X 1000

View File

@ -0,0 +1,69 @@
{
"countryCode": "fr",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["0+", "Public Averti", "Tous Publics", "TP", "U"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6+"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["9+"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["10"],
"ratingScore": {
"score": 10,
"subScore": null
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["14+"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["X"],
"ratingScore": {
"score": 1000,
"subScore": null
}
}
]
}

View File

@ -1,23 +0,0 @@
All,0
E,0
G,0
U,0
0+,0
6+,6
7+,7
PG,8
9,9
12,12
12+,12
12A,12
12PG,12
Teen,13
13+,13
14+,14
15,15
16,16
Caution,18
18,18
Mature,1000
Adult,1000
R18,1000
1 All 0
2 E 0
3 G 0
4 U 0
5 0+ 0
6 6+ 6
7 7+ 7
8 PG 8
9 9 9
10 12 12
11 12+ 12
12 12A 12
13 12PG 12
14 Teen 13
15 13+ 13
16 14+ 14
17 15 15
18 16 16
19 Caution 18
20 18 18
21 Mature 1000
22 Adult 1000
23 R18 1000

View File

@ -0,0 +1,97 @@
{
"countryCode": "gb",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["0+", "All", "E", "G", "U"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["6+"],
"ratingScore": {
"score": 6,
"subScore": 0
}
},
{
"ratingStrings": ["7+"],
"ratingScore": {
"score": 7,
"subScore": 0
}
},
{
"ratingStrings": ["PG"],
"ratingScore": {
"score": 8,
"subScore": 0
}
},
{
"ratingStrings": ["9"],
"ratingScore": {
"score": 9,
"subScore": 0
}
},
{
"ratingStrings": ["12A", "12PG"],
"ratingScore": {
"score": 12,
"subScore": 0
}
},
{
"ratingStrings": ["12", "12+"],
"ratingScore": {
"score": 12,
"subScore": 1
}
},
{
"ratingStrings": ["13+", "Teen"],
"ratingScore": {
"score": 13,
"subScore": 0
}
},
{
"ratingStrings": ["14+"],
"ratingScore": {
"score": 14,
"subScore": 0
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": 3
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": 0
}
},
{
"ratingStrings": ["18", "Caution"],
"ratingScore": {
"score": 18,
"subScore": 1
}
},
{
"ratingStrings": ["Mature", "Adult", "R18"],
"ratingScore": {
"score": 1000,
"subScore": 0
}
}
]
}

View File

@ -1,10 +0,0 @@
G,4
PG,12
12,12
12A,12
12PG,12
15,15
15PG,15
15A,15
16,16
18,18
1 G 4
2 PG 12
3 12 12
4 12A 12
5 12PG 12
6 15 15
7 15PG 15
8 15A 15
9 16 16
10 18 18

View File

@ -0,0 +1,55 @@
{
"countryCode": "ie",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["G"],
"ratingScore": {
"score": 4,
"subScore": 0
}
},
{
"ratingStrings": ["12A", "12PG", "PG"],
"ratingScore": {
"score": 12,
"subScore": 0
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": 1
}
},
{
"ratingStrings": ["15A", "15PG"],
"ratingScore": {
"score": 15,
"subScore": 0
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": 3
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": 0
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": 1
}
}
]
}

View File

@ -1,11 +0,0 @@
A,0
G,0
B,12
PG12,12
C,15
15+,15
R15+,15
16+,16
D,17
Z,18
18+,18
1 A 0
2 G 0
3 B 12
4 PG12 12
5 C 15
6 15+ 15
7 R15+ 15
8 16+ 16
9 D 17
10 Z 18
11 18+ 18

View File

@ -0,0 +1,62 @@
{
"countryCode": "jp",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["A", "G"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["PG12"],
"ratingScore": {
"score": 12,
"subScore": 0
}
},
{
"ratingStrings": ["B"],
"ratingScore": {
"score": 12,
"subScore": 1
}
},
{
"ratingStrings": ["15A", "15PG"],
"ratingScore": {
"score": 15,
"subScore": 0
}
},
{
"ratingStrings": ["C", "15+", "R15+"],
"ratingScore": {
"score": 15,
"subScore": 1
}
},
{
"ratingStrings": ["16+"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["D"],
"ratingScore": {
"score": 17,
"subScore": null
}
},
{
"ratingStrings": ["18+", "Z"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,6 +0,0 @@
K,0
БА,12
Б14,14
E16,16
E18,18
HA,18
1 K 0
2 БА 12
3 Б14 14
4 E16 16
5 E18 18
6 HA 18

View File

@ -0,0 +1,41 @@
{
"countryCode": "kz",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["K"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["БА"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["Б14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["E16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["E18", "HA"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,6 +0,0 @@
A,0
AA,0
B,12
B-15,15
C,18
D,1000
1 A 0
2 AA 0
3 B 12
4 B-15 15
5 C 18
6 D 1000

View File

@ -0,0 +1,41 @@
{
"countryCode": "mx",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["A", "AA"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["B"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["B-15"],
"ratingScore": {
"score": 15,
"subScore": null
}
},
{
"ratingStrings": ["C"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["D"],
"ratingScore": {
"score": 1000,
"subScore": null
}
}
]
}

View File

@ -1,8 +0,0 @@
AL,0
MG6,6
6,6
9,9
12,12
14,14
16,16
18,18
1 AL 0
2 MG6 6
3 6 6
4 9 9
5 12 12
6 14 14
7 16 16
8 18 18

View File

@ -0,0 +1,55 @@
{
"countryCode": "nl",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["AL"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6", "MG6"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["9"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,10 +0,0 @@
A,0
6,6
7,7
9,9
11,11
12,12
15,15
18,18
C,18
Not approved,1001
1 A 0
2 6 6
3 7 7
4 9 9
5 11 11
6 12 12
7 15 15
8 18 18
9 C 18
10 Not approved 1001

View File

@ -0,0 +1,69 @@
{
"countryCode": "no",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["A"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["9"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["11"],
"ratingScore": {
"score": 11,
"subScore": null
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": null
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["Not approved"],
"ratingScore": {
"score": 1001,
"subScore": null
}
}
]
}

View File

@ -1,16 +0,0 @@
Exempt,0
G,0
GY,13
PG,13
R13,13
RP13,13
R15,15
M,16
R16,16
RP16,16
GA,18
R18,18
RP18,18
MA,1000
R,1001
Objectionable,1001
1 Exempt 0
2 G 0
3 GY 13
4 PG 13
5 R13 13
6 RP13 13
7 R15 15
8 M 16
9 R16 16
10 RP16 16
11 GA 18
12 R18 18
13 RP18 18
14 MA 1000
15 R 1001
16 Objectionable 1001

View File

@ -0,0 +1,69 @@
{
"countryCode": "nz",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["Exempt", "G"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["RP13", "PG"],
"ratingScore": {
"score": 13,
"subScore": 0
}
},
{
"ratingStrings": ["GY", "R13"],
"ratingScore": {
"score": 13,
"subScore": 1
}
},
{
"ratingStrings": ["RP16", "M"],
"ratingScore": {
"score": 16,
"subScore": 0
}
},
{
"ratingStrings": ["R16"],
"ratingScore": {
"score": 16,
"subScore": 1
}
},
{
"ratingStrings": ["RP18"],
"ratingScore": {
"score": 18,
"subScore": 0
}
},
{
"ratingStrings": ["R18", "GA"],
"ratingScore": {
"score": 18,
"subScore": 1
}
},
{
"ratingStrings": ["MA"],
"ratingScore": {
"score": 1000,
"subScore": 0
}
},
{
"ratingStrings": ["Objectionable", "R"],
"ratingScore": {
"score": 1001,
"subScore": 0
}
}
]
}

View File

@ -1,6 +0,0 @@
AG,0
AP-12,12
N-15,15
IM-18,18
IM-18-XXX,1000
IC,1001
1 AG 0
2 AP-12 12
3 N-15 15
4 IM-18 18
5 IM-18-XXX 1000
6 IC 1001

View File

@ -0,0 +1,48 @@
{
"countryCode": "ro",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["AG"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["AP-12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["N-15"],
"ratingScore": {
"score": 15,
"subScore": null
}
},
{
"ratingStrings": ["IM-18"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["IM-18-XXX"],
"ratingScore": {
"score": 1000,
"subScore": null
}
},
{
"ratingStrings": ["IC"],
"ratingScore": {
"score": 1001,
"subScore": null
}
}
]
}

View File

@ -1,6 +0,0 @@
0+,0
6+,6
12+,12
16+,16
18+,18
Refused classification,1001
1 0+ 0
2 6+ 6
3 12+ 12
4 16+ 16
5 18+ 18
6 Refused classification 1001

View File

@ -0,0 +1,48 @@
{
"countryCode": "ru",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["0+"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["6+"],
"ratingScore": {
"score": 6,
"subScore": null
}
},
{
"ratingStrings": ["12+"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["16+"],
"ratingScore": {
"score": 16,
"subScore": null
}
},
{
"ratingStrings": ["18+"],
"ratingScore": {
"score": 18,
"subScore": null
}
},
{
"ratingStrings": ["Refused classification"],
"ratingScore": {
"score": 1001,
"subScore": null
}
}
]
}

View File

@ -1,10 +0,0 @@
Alla,0
Barntillåten,0
Btl,0
0+,0
7,7
9+,9
10+,10
11,11
14,14
15,15
1 Alla 0
2 Barntillåten 0
3 Btl 0
4 0+ 0
5 7 7
6 9+ 9
7 10+ 10
8 11 11
9 14 14
10 15 15

View File

@ -0,0 +1,55 @@
{
"countryCode": "se",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["0+", "Alla", "Barntillåten", "Btl"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["9+"],
"ratingScore": {
"score": 9,
"subScore": null
}
},
{
"ratingStrings": ["10+"],
"ratingScore": {
"score": 10,
"subScore": null
}
},
{
"ratingStrings": ["11"],
"ratingScore": {
"score": 11,
"subScore": null
}
},
{
"ratingStrings": ["14"],
"ratingScore": {
"score": 14,
"subScore": null
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": null
}
}
]
}

View File

@ -1,6 +0,0 @@
NR,0
U,0
7,7
12,12
15,15
18,18
1 NR 0
2 U 0
3 7 7
4 12 12
5 15 15
6 18 18

View File

@ -0,0 +1,41 @@
{
"countryCode": "sk",
"supportsSubScores": false,
"ratings": [
{
"ratingStrings": ["U", "NR"],
"ratingScore": {
"score": 0,
"subScore": null
}
},
{
"ratingStrings": ["7"],
"ratingScore": {
"score": 7,
"subScore": null
}
},
{
"ratingStrings": ["12"],
"ratingScore": {
"score": 12,
"subScore": null
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": null
}
},
{
"ratingStrings": ["18"],
"ratingScore": {
"score": 18,
"subScore": null
}
}
]
}

View File

@ -1,22 +0,0 @@
All,0
E,0
G,0
U,0
0+,0
6+,6
7+,7
PG,8
9+,9
12,12
12+,12
12A,12
Teen,13
13+,13
14+,14
15,15
16,16
Caution,18
18,18
Mature,1000
Adult,1000
R18,1000
1 All 0
2 E 0
3 G 0
4 U 0
5 0+ 0
6 6+ 6
7 7+ 7
8 PG 8
9 9+ 9
10 12 12
11 12+ 12
12 12A 12
13 Teen 13
14 13+ 13
15 14+ 14
16 15 15
17 16 16
18 Caution 18
19 18 18
20 Mature 1000
21 Adult 1000
22 R18 1000

View File

@ -0,0 +1,97 @@
{
"countryCode": "gb",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["0+", "All", "E", "G", "U"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["6+"],
"ratingScore": {
"score": 6,
"subScore": 0
}
},
{
"ratingStrings": ["7+"],
"ratingScore": {
"score": 7,
"subScore": 0
}
},
{
"ratingStrings": ["PG"],
"ratingScore": {
"score": 8,
"subScore": 0
}
},
{
"ratingStrings": ["9"],
"ratingScore": {
"score": 9,
"subScore": 0
}
},
{
"ratingStrings": ["12A", "12PG"],
"ratingScore": {
"score": 12,
"subScore": 0
}
},
{
"ratingStrings": ["12", "12+"],
"ratingScore": {
"score": 12,
"subScore": 1
}
},
{
"ratingStrings": ["13+", "Teen"],
"ratingScore": {
"score": 13,
"subScore": 0
}
},
{
"ratingStrings": ["14+"],
"ratingScore": {
"score": 14,
"subScore": 0
}
},
{
"ratingStrings": ["15"],
"ratingScore": {
"score": 15,
"subScore": 3
}
},
{
"ratingStrings": ["16"],
"ratingScore": {
"score": 16,
"subScore": 0
}
},
{
"ratingStrings": ["18", "Caution"],
"ratingScore": {
"score": 18,
"subScore": 1
}
},
{
"ratingStrings": ["Mature", "Adult", "R18"],
"ratingScore": {
"score": 1000,
"subScore": 0
}
}
]
}

View File

@ -1,52 +0,0 @@
Approved,0
G,0
TV-G,0
TV-Y,0
TV-Y7,7
TV-Y7-FV,7
PG,10
TV-PG,10
TV-PG-D,10
TV-PG-L,10
TV-PG-S,10
TV-PG-V,10
TV-PG-DL,10
TV-PG-DS,10
TV-PG-DV,10
TV-PG-LS,10
TV-PG-LV,10
TV-PG-SV,10
TV-PG-DLS,10
TV-PG-DLV,10
TV-PG-DSV,10
TV-PG-LSV,10
TV-PG-DLSV,10
PG-13,13
TV-14,14
TV-14-D,14
TV-14-L,14
TV-14-S,14
TV-14-V,14
TV-14-DL,14
TV-14-DS,14
TV-14-DV,14
TV-14-LS,14
TV-14-LV,14
TV-14-SV,14
TV-14-DLS,14
TV-14-DLV,14
TV-14-DSV,14
TV-14-LSV,14
TV-14-DLSV,14
NC-17,17
R,17
TV-MA,17
TV-MA-L,17
TV-MA-S,17
TV-MA-V,17
TV-MA-LS,17
TV-MA-LV,17
TV-MA-SV,17
TV-MA-LSV,17
TV-X,18
TV-AO,18
1 Approved 0
2 G 0
3 TV-G 0
4 TV-Y 0
5 TV-Y7 7
6 TV-Y7-FV 7
7 PG 10
8 TV-PG 10
9 TV-PG-D 10
10 TV-PG-L 10
11 TV-PG-S 10
12 TV-PG-V 10
13 TV-PG-DL 10
14 TV-PG-DS 10
15 TV-PG-DV 10
16 TV-PG-LS 10
17 TV-PG-LV 10
18 TV-PG-SV 10
19 TV-PG-DLS 10
20 TV-PG-DLV 10
21 TV-PG-DSV 10
22 TV-PG-LSV 10
23 TV-PG-DLSV 10
24 PG-13 13
25 TV-14 14
26 TV-14-D 14
27 TV-14-L 14
28 TV-14-S 14
29 TV-14-V 14
30 TV-14-DL 14
31 TV-14-DS 14
32 TV-14-DV 14
33 TV-14-LS 14
34 TV-14-LV 14
35 TV-14-SV 14
36 TV-14-DLS 14
37 TV-14-DLV 14
38 TV-14-DSV 14
39 TV-14-LSV 14
40 TV-14-DLSV 14
41 NC-17 17
42 R 17
43 TV-MA 17
44 TV-MA-L 17
45 TV-MA-S 17
46 TV-MA-V 17
47 TV-MA-LS 17
48 TV-MA-LV 17
49 TV-MA-SV 17
50 TV-MA-LSV 17
51 TV-X 18
52 TV-AO 18

View File

@ -0,0 +1,83 @@
{
"countryCode": "us",
"supportsSubScores": true,
"ratings": [
{
"ratingStrings": ["Approved", "G", "TV-G", "TV-Y"],
"ratingScore": {
"score": 0,
"subScore": 0
}
},
{
"ratingStrings": ["TV-Y7"],
"ratingScore": {
"score": 7,
"subScore": 0
}
},
{
"ratingStrings": ["TV-Y7-FV"],
"ratingScore": {
"score": 7,
"subScore": 1
}
},
{
"ratingStrings": ["PG", "TV-PG"],
"ratingScore": {
"score": 10,
"subScore": 0
}
},
{
"ratingStrings": ["TV-PG-D", "TV-PG-L", "TV-PG-S", "TV-PG-V", "TV-PG-DL", "TV-PG-DS", "TV-PG-DV", "TV-PG-LS", "TV-PG-LV", "TV-PG-SV", "TV-PG-DLS", "TV-PG-DLV", "TV-PG-DSV", "TV-PG-LSV", "TV-PG-DLSV"],
"ratingScore": {
"score": 10,
"subScore": 1
}
},
{
"ratingStrings": ["PG-13"],
"ratingScore": {
"score": 13,
"subScore": 0
}
},
{
"ratingStrings": ["TV-14"],
"ratingScore": {
"score": 14,
"subScore": 0
}
},
{
"ratingStrings": ["TV-14-D", "TV-14-L", "TV-14-S", "TV-14-V", "TV-14-DL", "TV-14-DS", "TV-14-DV", "TV-14-LS", "TV-14-LV", "TV-14-SV", "TV-14-DLS", "TV-14-DLV", "TV-14-DSV", "TV-14-LSV", "TV-14-DLSV"],
"ratingScore": {
"score": 14,
"subScore": 1
}
},
{
"ratingStrings": ["R"],
"ratingScore": {
"score": 17,
"subScore": 0
}
},
{
"ratingStrings": ["NC-17", "TV-MA", "TV-MA-L", "TV-MA-S", "TV-MA-V", "TV-MA-LS", "TV-MA-LV", "TV-MA-SV", "TV-MA-LSV"],
"ratingScore": {
"score": 17,
"subScore": 1
}
},
{
"ratingStrings": ["TV-X", "TV-AO"],
"ratingScore": {
"score": 18,
"subScore": 0
}
}
]
}

View File

@ -1,45 +1,54 @@
#pragma warning disable CS1591
using System;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Sorting
namespace Emby.Server.Implementations.Sorting;
/// <summary>
/// Class providing comparison for official ratings.
/// </summary>
public class OfficialRatingComparer : IBaseItemComparer
{
public class OfficialRatingComparer : IBaseItemComparer
private readonly ILocalizationManager _localizationManager;
/// <summary>
/// Initializes a new instance of the <see cref="OfficialRatingComparer"/> class.
/// </summary>
/// <param name="localizationManager">Instance of the <see cref="ILocalizationManager"/> interface.</param>
public OfficialRatingComparer(ILocalizationManager localizationManager)
{
private readonly ILocalizationManager _localization;
_localizationManager = localizationManager;
}
public OfficialRatingComparer(ILocalizationManager localization)
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public ItemSortBy Type => ItemSortBy.OfficialRating;
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y)
{
ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y);
var zeroRating = new ParentalRatingScore(0, 0);
var ratingX = string.IsNullOrEmpty(x.OfficialRating) ? zeroRating : _localizationManager.GetRatingScore(x.OfficialRating) ?? zeroRating;
var ratingY = string.IsNullOrEmpty(y.OfficialRating) ? zeroRating : _localizationManager.GetRatingScore(y.OfficialRating) ?? zeroRating;
var scoreCompare = ratingX.Score.CompareTo(ratingY.Score);
if (scoreCompare is 0)
{
_localization = localization;
return (ratingX.SubScore ?? 0).CompareTo(ratingY.SubScore ?? 0);
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public ItemSortBy Type => ItemSortBy.OfficialRating;
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y)
{
ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y);
var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;
return levelX.CompareTo(levelY);
}
return scoreCompare;
}
}

View File

@ -448,13 +448,13 @@ public class ItemsController : BaseJellyfinApiController
// Min official rating
if (!string.IsNullOrWhiteSpace(minOfficialRating))
{
query.MinParentalRating = _localization.GetRatingLevel(minOfficialRating);
query.MinParentalRating = _localization.GetRatingScore(minOfficialRating);
}
// Max official rating
if (!string.IsNullOrWhiteSpace(maxOfficialRating))
{
query.MaxParentalRating = _localization.GetRatingLevel(maxOfficialRating);
query.MaxParentalRating = _localization.GetRatingScore(maxOfficialRating);
}
// Artists

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using Jellyfin.Api.Constants;
using MediaBrowser.Common.Api;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
@ -45,7 +44,7 @@ public class LocalizationController : BaseJellyfinApiController
/// <returns>An <see cref="OkResult"/> containing the list of countries.</returns>
[HttpGet("Countries")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult<IEnumerable<CountryInfo>> GetCountries()
public ActionResult<IReadOnlyList<CountryInfo>> GetCountries()
{
return Ok(_localization.GetCountries());
}
@ -57,7 +56,7 @@ public class LocalizationController : BaseJellyfinApiController
/// <returns>An <see cref="OkResult"/> containing the list of parental ratings.</returns>
[HttpGet("ParentalRatings")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult<IEnumerable<ParentalRating>> GetParentalRatings()
public ActionResult<IReadOnlyList<ParentalRating>> GetParentalRatings()
{
return Ok(_localization.GetParentalRatings());
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace Jellyfin.Server.Implementations.Extensions;
/// <summary>
/// Provides <see cref="Expression"/> extension methods.
/// </summary>
public static class ExpressionExtensions
{
/// <summary>
/// Combines two predicates into a single predicate using a logical OR operation.
/// </summary>
/// <typeparam name="T">The predicate parameter type.</typeparam>
/// <param name="firstPredicate">The first predicate expression to combine.</param>
/// <param name="secondPredicate">The second predicate expression to combine.</param>
/// <returns>A new expression representing the OR combination of the input predicates.</returns>
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> firstPredicate, Expression<Func<T, bool>> secondPredicate)
{
ArgumentNullException.ThrowIfNull(firstPredicate);
ArgumentNullException.ThrowIfNull(secondPredicate);
var invokedExpression = Expression.Invoke(secondPredicate, firstPredicate.Parameters);
return Expression.Lambda<Func<T, bool>>(Expression.OrElse(firstPredicate.Body, invokedExpression), firstPredicate.Parameters);
}
/// <summary>
/// Combines multiple predicates into a single predicate using a logical OR operation.
/// </summary>
/// <typeparam name="T">The predicate parameter type.</typeparam>
/// <param name="predicates">A collection of predicate expressions to combine.</param>
/// <returns>A new expression representing the OR combination of all input predicates.</returns>
public static Expression<Func<T, bool>> Or<T>(this IEnumerable<Expression<Func<T, bool>>> predicates)
{
ArgumentNullException.ThrowIfNull(predicates);
return predicates.Aggregate((aggregatePredicate, nextPredicate) => aggregatePredicate.Or(nextPredicate));
}
/// <summary>
/// Combines two predicates into a single predicate using a logical AND operation.
/// </summary>
/// <typeparam name="T">The predicate parameter type.</typeparam>
/// <param name="firstPredicate">The first predicate expression to combine.</param>
/// <param name="secondPredicate">The second predicate expression to combine.</param>
/// <returns>A new expression representing the AND combination of the input predicates.</returns>
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> firstPredicate, Expression<Func<T, bool>> secondPredicate)
{
ArgumentNullException.ThrowIfNull(firstPredicate);
ArgumentNullException.ThrowIfNull(secondPredicate);
var invokedExpression = Expression.Invoke(secondPredicate, firstPredicate.Parameters);
return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(firstPredicate.Body, invokedExpression), firstPredicate.Parameters);
}
/// <summary>
/// Combines multiple predicates into a single predicate using a logical AND operation.
/// </summary>
/// <typeparam name="T">The predicate parameter type.</typeparam>
/// <param name="predicates">A collection of predicate expressions to combine.</param>
/// <returns>A new expression representing the AND combination of all input predicates.</returns>
public static Expression<Func<T, bool>> And<T>(this IEnumerable<Expression<Func<T, bool>>> predicates)
{
ArgumentNullException.ThrowIfNull(predicates);
return predicates.Aggregate((aggregatePredicate, nextPredicate) => aggregatePredicate.And(nextPredicate));
}
}

View File

@ -9,6 +9,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Text.Json;
@ -19,6 +20,7 @@ using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using Jellyfin.Extensions.Json;
using Jellyfin.Server.Implementations.Extensions;
using MediaBrowser.Common;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Channels;
@ -781,6 +783,7 @@ public sealed class BaseItemRepository
entity.PreferredMetadataCountryCode = dto.PreferredMetadataCountryCode;
entity.IsInMixedFolder = dto.IsInMixedFolder;
entity.InheritedParentalRatingValue = dto.InheritedParentalRatingValue;
entity.InheritedParentalRatingSubValue = dto.InheritedParentalRatingSubValue;
entity.CriticRating = dto.CriticRating;
entity.PresentationUniqueKey = dto.PresentationUniqueKey;
entity.OriginalTitle = dto.OriginalTitle;
@ -1796,62 +1799,74 @@ public sealed class BaseItemRepository
.Where(e => filter.OfficialRatings.Contains(e.OfficialRating));
}
Expression<Func<BaseItemEntity, bool>>? minParentalRatingFilter = null;
if (filter.MinParentalRating != null)
{
var min = filter.MinParentalRating;
minParentalRatingFilter = e => e.InheritedParentalRatingValue >= min.Score || e.InheritedParentalRatingValue == null;
if (min.SubScore != null)
{
minParentalRatingFilter = minParentalRatingFilter.And(e => e.InheritedParentalRatingValue >= min.SubScore || e.InheritedParentalRatingValue == null);
}
}
Expression<Func<BaseItemEntity, bool>>? maxParentalRatingFilter = null;
if (filter.MaxParentalRating != null)
{
var max = filter.MaxParentalRating;
maxParentalRatingFilter = e => e.InheritedParentalRatingValue <= max.Score || e.InheritedParentalRatingValue == null;
if (max.SubScore != null)
{
maxParentalRatingFilter = maxParentalRatingFilter.And(e => e.InheritedParentalRatingValue <= max.SubScore || e.InheritedParentalRatingValue == null);
}
}
if (filter.HasParentalRating ?? false)
{
if (filter.MinParentalRating.HasValue)
if (minParentalRatingFilter != null)
{
baseQuery = baseQuery
.Where(e => e.InheritedParentalRatingValue >= filter.MinParentalRating.Value);
baseQuery = baseQuery.Where(minParentalRatingFilter);
}
if (filter.MaxParentalRating.HasValue)
if (maxParentalRatingFilter != null)
{
baseQuery = baseQuery
.Where(e => e.InheritedParentalRatingValue < filter.MaxParentalRating.Value);
baseQuery = baseQuery.Where(maxParentalRatingFilter);
}
}
else if (filter.BlockUnratedItems.Length > 0)
{
var unratedItems = filter.BlockUnratedItems.Select(f => f.ToString()).ToArray();
if (filter.MinParentalRating.HasValue)
var unratedItemTypes = filter.BlockUnratedItems.Select(f => f.ToString()).ToArray();
Expression<Func<BaseItemEntity, bool>> unratedItemFilter = e => e.InheritedParentalRatingValue != null || !unratedItemTypes.Contains(e.UnratedType);
if (minParentalRatingFilter != null && maxParentalRatingFilter != null)
{
if (filter.MaxParentalRating.HasValue)
{
baseQuery = baseQuery
.Where(e => (e.InheritedParentalRatingValue == null && !unratedItems.Contains(e.UnratedType))
|| (e.InheritedParentalRatingValue >= filter.MinParentalRating && e.InheritedParentalRatingValue <= filter.MaxParentalRating));
}
else
{
baseQuery = baseQuery
.Where(e => (e.InheritedParentalRatingValue == null && !unratedItems.Contains(e.UnratedType))
|| e.InheritedParentalRatingValue >= filter.MinParentalRating);
}
baseQuery = baseQuery.Where(unratedItemFilter.And(minParentalRatingFilter.And(maxParentalRatingFilter)));
}
else if (minParentalRatingFilter != null)
{
baseQuery = baseQuery.Where(unratedItemFilter.And(minParentalRatingFilter));
}
else if (maxParentalRatingFilter != null)
{
baseQuery = baseQuery.Where(unratedItemFilter.And(maxParentalRatingFilter));
}
else
{
baseQuery = baseQuery
.Where(e => e.InheritedParentalRatingValue != null && !unratedItems.Contains(e.UnratedType));
baseQuery = baseQuery.Where(unratedItemFilter);
}
}
else if (filter.MinParentalRating.HasValue)
else if (minParentalRatingFilter != null || maxParentalRatingFilter != null)
{
if (filter.MaxParentalRating.HasValue)
if (minParentalRatingFilter != null)
{
baseQuery = baseQuery
.Where(e => e.InheritedParentalRatingValue != null && e.InheritedParentalRatingValue >= filter.MinParentalRating.Value && e.InheritedParentalRatingValue <= filter.MaxParentalRating.Value);
baseQuery = baseQuery.Where(minParentalRatingFilter);
}
else
if (maxParentalRatingFilter != null)
{
baseQuery = baseQuery
.Where(e => e.InheritedParentalRatingValue != null && e.InheritedParentalRatingValue >= filter.MinParentalRating.Value);
baseQuery = baseQuery.Where(maxParentalRatingFilter);
}
}
else if (filter.MaxParentalRating.HasValue)
{
baseQuery = baseQuery
.Where(e => e.InheritedParentalRatingValue != null && e.InheritedParentalRatingValue >= filter.MaxParentalRating.Value);
}
else if (!filter.HasParentalRating ?? false)
{
baseQuery = baseQuery

View File

@ -342,7 +342,8 @@ namespace Jellyfin.Server.Implementations.Users
},
Policy = new UserPolicy
{
MaxParentalRating = user.MaxParentalAgeRating,
MaxParentalRating = user.MaxParentalRatingScore,
MaxParentalSubRating = user.MaxParentalRatingSubScore,
EnableUserPreferenceAccess = user.EnableUserPreferenceAccess,
RemoteClientBitrateLimit = user.RemoteClientBitrateLimit ?? 0,
AuthenticationProviderId = user.AuthenticationProviderId,
@ -668,7 +669,8 @@ namespace Jellyfin.Server.Implementations.Users
_ => policy.LoginAttemptsBeforeLockout
};
user.MaxParentalAgeRating = policy.MaxParentalRating;
user.MaxParentalRatingScore = policy.MaxParentalRating;
user.MaxParentalRatingSubScore = policy.MaxParentalSubRating;
user.EnableUserPreferenceAccess = policy.EnableUserPreferenceAccess;
user.RemoteClientBitrateLimit = policy.RemoteClientBitrateLimit;
user.AuthenticationProviderId = policy.AuthenticationProviderId;

View File

@ -49,12 +49,12 @@ namespace Jellyfin.Server.Migrations
typeof(Routines.RemoveDownloadImagesInAdvance),
typeof(Routines.MigrateAuthenticationDb),
typeof(Routines.FixPlaylistOwner),
typeof(Routines.MigrateRatingLevels),
typeof(Routines.AddDefaultCastReceivers),
typeof(Routines.UpdateDefaultPluginRepository),
typeof(Routines.FixAudioData),
typeof(Routines.RemoveDuplicatePlaylistChildren),
typeof(Routines.MigrateLibraryDb),
typeof(Routines.MigrateRatingLevels),
typeof(Routines.MoveTrickplayFiles),
};

View File

@ -1,36 +1,33 @@
using System;
using System.Globalization;
using System.IO;
using Emby.Server.Implementations.Data;
using MediaBrowser.Controller;
using System.Linq;
using Jellyfin.Database.Implementations;
using MediaBrowser.Model.Globalization;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Server.Migrations.Routines
{
/// <summary>
/// Migrate rating levels to new rating level system.
/// Migrate rating levels.
/// </summary>
internal class MigrateRatingLevels : IMigrationRoutine
internal class MigrateRatingLevels : IDatabaseMigrationRoutine
{
private const string DbFilename = "library.db";
private readonly ILogger<MigrateRatingLevels> _logger;
private readonly IServerApplicationPaths _applicationPaths;
private readonly IDbContextFactory<JellyfinDbContext> _provider;
private readonly ILocalizationManager _localizationManager;
public MigrateRatingLevels(
IServerApplicationPaths applicationPaths,
IDbContextFactory<JellyfinDbContext> provider,
ILoggerFactory loggerFactory,
ILocalizationManager localizationManager)
{
_applicationPaths = applicationPaths;
_provider = provider;
_localizationManager = localizationManager;
_logger = loggerFactory.CreateLogger<MigrateRatingLevels>();
}
/// <inheritdoc/>
public Guid Id => Guid.Parse("{73DAB92A-178B-48CD-B05B-FE18733ACDC8}");
public Guid Id => Guid.Parse("{98724538-EB11-40E3-931A-252C55BDDE7A}");
/// <inheritdoc/>
public string Name => "MigrateRatingLevels";
@ -41,54 +38,37 @@ namespace Jellyfin.Server.Migrations.Routines
/// <inheritdoc/>
public void Perform()
{
var dbPath = Path.Combine(_applicationPaths.DataPath, DbFilename);
// Back up the database before modifying any entries
for (int i = 1; ; i++)
{
var bakPath = string.Format(CultureInfo.InvariantCulture, "{0}.bak{1}", dbPath, i);
if (!File.Exists(bakPath))
{
try
{
File.Copy(dbPath, bakPath);
_logger.LogInformation("Library database backed up to {BackupPath}", bakPath);
break;
}
catch (Exception ex)
{
_logger.LogError(ex, "Cannot make a backup of {Library} at path {BackupPath}", DbFilename, bakPath);
throw;
}
}
}
// Migrate parental rating strings to new levels
_logger.LogInformation("Recalculating parental rating levels based on rating string.");
using var connection = new SqliteConnection($"Filename={dbPath}");
connection.Open();
using (var transaction = connection.BeginTransaction())
using var context = _provider.CreateDbContext();
using var transaction = context.Database.BeginTransaction();
var ratings = context.BaseItems.AsNoTracking().Select(e => e.OfficialRating).Distinct();
foreach (var rating in ratings)
{
var queryResult = connection.Query("SELECT DISTINCT OfficialRating FROM TypedBaseItems");
foreach (var entry in queryResult)
if (string.IsNullOrEmpty(rating))
{
if (!entry.TryGetString(0, out var ratingString) || string.IsNullOrEmpty(ratingString))
{
connection.Execute("UPDATE TypedBaseItems SET InheritedParentalRatingValue = NULL WHERE OfficialRating IS NULL OR OfficialRating='';");
}
else
{
var ratingValue = _localizationManager.GetRatingLevel(ratingString)?.ToString(CultureInfo.InvariantCulture) ?? "NULL";
using var statement = connection.PrepareStatement("UPDATE TypedBaseItems SET InheritedParentalRatingValue = @Value WHERE OfficialRating = @Rating;");
statement.TryBind("@Value", ratingValue);
statement.TryBind("@Rating", ratingString);
statement.ExecuteNonQuery();
}
int? value = null;
context.BaseItems
.Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingValue, value));
context.BaseItems
.Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingSubValue, value));
}
else
{
var ratingValue = _localizationManager.GetRatingScore(rating);
var score = ratingValue?.Score;
var subScore = ratingValue?.SubScore;
context.BaseItems
.Where(e => e.OfficialRating == rating)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingValue, score));
context.BaseItems
.Where(e => e.OfficialRating == rating)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingSubValue, subScore));
}
transaction.Commit();
}
transaction.Commit();
}
}
}

View File

@ -112,7 +112,8 @@ namespace Jellyfin.Server.Migrations.Routines
{
Id = entry.GetGuid(1),
InternalId = entry.GetInt64(0),
MaxParentalAgeRating = policy.MaxParentalRating,
MaxParentalRatingScore = policy.MaxParentalRating,
MaxParentalRatingSubScore = null,
EnableUserPreferenceAccess = policy.EnableUserPreferenceAccess,
RemoteClientBitrateLimit = policy.RemoteClientBitrateLimit,
InvalidLoginAttemptCount = policy.InvalidLoginAttemptCount,

View File

@ -581,6 +581,9 @@ namespace MediaBrowser.Controller.Entities
[JsonIgnore]
public int? InheritedParentalRatingValue { get; set; }
[JsonIgnore]
public int? InheritedParentalRatingSubValue { get; set; }
/// <summary>
/// Gets or sets the critic rating.
/// </summary>
@ -1540,7 +1543,8 @@ namespace MediaBrowser.Controller.Entities
return false;
}
var maxAllowedRating = user.MaxParentalAgeRating;
var maxAllowedRating = user.MaxParentalRatingScore;
var maxAllowedSubRating = user.MaxParentalRatingSubScore;
var rating = CustomRatingForComparison;
if (string.IsNullOrEmpty(rating))
@ -1554,10 +1558,10 @@ namespace MediaBrowser.Controller.Entities
return !GetBlockUnratedValue(user);
}
var value = LocalizationManager.GetRatingLevel(rating);
var ratingScore = LocalizationManager.GetRatingScore(rating);
// Could not determine rating level
if (!value.HasValue)
if (ratingScore is null)
{
var isAllowed = !GetBlockUnratedValue(user);
@ -1569,10 +1573,15 @@ namespace MediaBrowser.Controller.Entities
return isAllowed;
}
return !maxAllowedRating.HasValue || value.Value <= maxAllowedRating.Value;
if (maxAllowedSubRating is not null)
{
return (ratingScore.SubScore ?? 0) <= maxAllowedSubRating && ratingScore.Score <= maxAllowedRating.Value;
}
return !maxAllowedRating.HasValue || ratingScore.Score <= maxAllowedRating.Value;
}
public int? GetInheritedParentalRatingValue()
public ParentalRatingScore GetParentalRatingScore()
{
var rating = CustomRatingForComparison;
@ -1586,7 +1595,7 @@ namespace MediaBrowser.Controller.Entities
return null;
}
return LocalizationManager.GetRatingLevel(rating);
return LocalizationManager.GetRatingScore(rating);
}
public List<string> GetInheritedTags()
@ -2518,11 +2527,29 @@ namespace MediaBrowser.Controller.Entities
var item = this;
var inheritedParentalRatingValue = item.GetInheritedParentalRatingValue() ?? null;
if (inheritedParentalRatingValue != item.InheritedParentalRatingValue)
var rating = item.GetParentalRatingScore();
if (rating is not null)
{
item.InheritedParentalRatingValue = inheritedParentalRatingValue;
updateType |= ItemUpdateType.MetadataImport;
if (rating.Score != item.InheritedParentalRatingValue)
{
item.InheritedParentalRatingValue = rating.Score;
updateType |= ItemUpdateType.MetadataImport;
}
if (rating.SubScore != item.InheritedParentalRatingSubValue)
{
item.InheritedParentalRatingSubValue = rating.SubScore;
updateType |= ItemUpdateType.MetadataImport;
}
}
else
{
if (item.InheritedParentalRatingValue is not null)
{
item.InheritedParentalRatingValue = null;
item.InheritedParentalRatingSubValue = null;
updateType |= ItemUpdateType.MetadataImport;
}
}
return updateType;
@ -2542,8 +2569,9 @@ namespace MediaBrowser.Controller.Entities
.Select(i => i.OfficialRating)
.Where(i => !string.IsNullOrEmpty(i))
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(rating => (rating, LocalizationManager.GetRatingLevel(rating)))
.OrderBy(i => i.Item2 ?? 1000)
.Select(rating => (rating, LocalizationManager.GetRatingScore(rating)))
.OrderBy(i => i.Item2 is null ? 1001 : i.Item2.Score)
.ThenBy(i => i.Item2 is null ? 1001 : i.Item2.SubScore)
.Select(i => i.rating);
OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating;

View File

@ -232,9 +232,9 @@ namespace MediaBrowser.Controller.Entities
public int? IndexNumber { get; set; }
public int? MinParentalRating { get; set; }
public ParentalRatingScore? MinParentalRating { get; set; }
public int? MaxParentalRating { get; set; }
public ParentalRatingScore? MaxParentalRating { get; set; }
public bool? HasDeadParentId { get; set; }
@ -360,16 +360,17 @@ namespace MediaBrowser.Controller.Entities
public void SetUser(User user)
{
MaxParentalRating = user.MaxParentalAgeRating;
if (MaxParentalRating.HasValue)
var maxRating = user.MaxParentalRatingScore;
if (maxRating.HasValue)
{
string other = UnratedItem.Other.ToString();
BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
.Where(i => i != other)
.Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
MaxParentalRating = new(maxRating.Value, user.MaxParentalRatingSubScore);
}
var other = UnratedItem.Other.ToString();
BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
.Where(i => i != other)
.Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags);

View File

@ -1,35 +1,55 @@
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Providers;
namespace MediaBrowser.Model.Dto
namespace MediaBrowser.Model.Dto;
/// <summary>
/// A class representing metadata editor information.
/// </summary>
public class MetadataEditorInfo
{
public class MetadataEditorInfo
/// <summary>
/// Initializes a new instance of the <see cref="MetadataEditorInfo"/> class.
/// </summary>
public MetadataEditorInfo()
{
public MetadataEditorInfo()
{
ParentalRatingOptions = Array.Empty<ParentalRating>();
Countries = Array.Empty<CountryInfo>();
Cultures = Array.Empty<CultureDto>();
ExternalIdInfos = Array.Empty<ExternalIdInfo>();
ContentTypeOptions = Array.Empty<NameValuePair>();
}
public IReadOnlyList<ParentalRating> ParentalRatingOptions { get; set; }
public IReadOnlyList<CountryInfo> Countries { get; set; }
public IReadOnlyList<CultureDto> Cultures { get; set; }
public IReadOnlyList<ExternalIdInfo> ExternalIdInfos { get; set; }
public CollectionType? ContentType { get; set; }
public IReadOnlyList<NameValuePair> ContentTypeOptions { get; set; }
ParentalRatingOptions = [];
Countries = [];
Cultures = [];
ExternalIdInfos = [];
ContentTypeOptions = [];
}
/// <summary>
/// Gets or sets the parental rating options.
/// </summary>
public IReadOnlyList<ParentalRating> ParentalRatingOptions { get; set; }
/// <summary>
/// Gets or sets the countries.
/// </summary>
public IReadOnlyList<CountryInfo> Countries { get; set; }
/// <summary>
/// Gets or sets the cultures.
/// </summary>
public IReadOnlyList<CultureDto> Cultures { get; set; }
/// <summary>
/// Gets or sets the external id infos.
/// </summary>
public IReadOnlyList<ExternalIdInfo> ExternalIdInfos { get; set; }
/// <summary>
/// Gets or sets the content type.
/// </summary>
public CollectionType? ContentType { get; set; }
/// <summary>
/// Gets or sets the content type options.
/// </summary>
public IReadOnlyList<NameValuePair> ContentTypeOptions { get; set; }
}

View File

@ -1,33 +1,40 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Entities
/// <summary>
/// Class ParentalRating.
/// </summary>
public class ParentalRating
{
/// <summary>
/// Class ParentalRating.
/// Initializes a new instance of the <see cref="ParentalRating"/> class.
/// </summary>
public class ParentalRating
/// <param name="name">The name.</param>
/// <param name="score">The score.</param>
public ParentalRating(string name, ParentalRatingScore? score)
{
public ParentalRating()
{
}
public ParentalRating(string name, int? value)
{
Name = name;
Value = value;
}
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>The value.</value>
public int? Value { get; set; }
Name = name;
Value = score?.Score;
RatingScore = score;
}
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>The value.</value>
/// <remarks>
/// Deprecated.
/// </remarks>
public int? Value { get; set; }
/// <summary>
/// Gets or sets the rating score.
/// </summary>
/// <value>The rating score.</value>
public ParentalRatingScore? RatingScore { get; set; }
}

View File

@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace MediaBrowser.Model.Entities;
/// <summary>
/// A class representing an parental rating entry.
/// </summary>
public class ParentalRatingEntry
{
/// <summary>
/// Gets or sets the rating strings.
/// </summary>
[JsonPropertyName("ratingStrings")]
public required IReadOnlyList<string> RatingStrings { get; set; }
/// <summary>
/// Gets or sets the score.
/// </summary>
[JsonPropertyName("ratingScore")]
public required ParentalRatingScore RatingScore { get; set; }
}

View File

@ -0,0 +1,32 @@
using System.Text.Json.Serialization;
namespace MediaBrowser.Model.Entities;
/// <summary>
/// A class representing an parental rating score.
/// </summary>
public class ParentalRatingScore
{
/// <summary>
/// Initializes a new instance of the <see cref="ParentalRatingScore"/> class.
/// </summary>
/// <param name="score">The score.</param>
/// <param name="subScore">The sub score.</param>
public ParentalRatingScore(int score, int? subScore)
{
Score = score;
SubScore = subScore;
}
/// <summary>
/// Gets or sets the score.
/// </summary>
[JsonPropertyName("score")]
public int Score { get; set; }
/// <summary>
/// Gets or sets the sub score.
/// </summary>
[JsonPropertyName("subScore")]
public int? SubScore { get; set; }
}

View File

@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace MediaBrowser.Model.Entities;
/// <summary>
/// A class representing a parental rating system.
/// </summary>
public class ParentalRatingSystem
{
/// <summary>
/// Gets or sets the country code.
/// </summary>
[JsonPropertyName("countryCode")]
public required string CountryCode { get; set; }
/// <summary>
/// Gets or sets a value indicating whether sub scores are supported.
/// </summary>
[JsonPropertyName("supportsSubScores")]
public bool SupportsSubScores { get; set; }
/// <summary>
/// Gets or sets the ratings.
/// </summary>
[JsonPropertyName("ratings")]
public IReadOnlyList<ParentalRatingEntry>? Ratings { get; set; }
}

View File

@ -1,65 +1,64 @@
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Globalization
namespace MediaBrowser.Model.Globalization;
/// <summary>
/// Interface ILocalizationManager.
/// </summary>
public interface ILocalizationManager
{
/// <summary>
/// Interface ILocalizationManager.
/// Gets the cultures.
/// </summary>
public interface ILocalizationManager
{
/// <summary>
/// Gets the cultures.
/// </summary>
/// <returns><see cref="IEnumerable{CultureDto}" />.</returns>
IEnumerable<CultureDto> GetCultures();
/// <returns><see cref="IEnumerable{CultureDto}" />.</returns>
IEnumerable<CultureDto> GetCultures();
/// <summary>
/// Gets the countries.
/// </summary>
/// <returns><see cref="IEnumerable{CountryInfo}" />.</returns>
IEnumerable<CountryInfo> GetCountries();
/// <summary>
/// Gets the countries.
/// </summary>
/// <returns><see cref="IReadOnlyList{CountryInfo}" />.</returns>
IReadOnlyList<CountryInfo> GetCountries();
/// <summary>
/// Gets the parental ratings.
/// </summary>
/// <returns><see cref="IEnumerable{ParentalRating}" />.</returns>
IEnumerable<ParentalRating> GetParentalRatings();
/// <summary>
/// Gets the parental ratings.
/// </summary>
/// <returns><see cref="IReadOnlyList{ParentalRating}" />.</returns>
IReadOnlyList<ParentalRating> GetParentalRatings();
/// <summary>
/// Gets the rating level.
/// </summary>
/// <param name="rating">The rating.</param>
/// <param name="countryCode">The optional two letter ISO language string.</param>
/// <returns><see cref="int" /> or <c>null</c>.</returns>
int? GetRatingLevel(string rating, string? countryCode = null);
/// <summary>
/// Gets the rating level.
/// </summary>
/// <param name="rating">The rating.</param>
/// <param name="countryCode">The optional two letter ISO language string.</param>
/// <returns><see cref="ParentalRatingScore" /> or <c>null</c>.</returns>
ParentalRatingScore? GetRatingScore(string rating, string? countryCode = null);
/// <summary>
/// Gets the localized string.
/// </summary>
/// <param name="phrase">The phrase.</param>
/// <param name="culture">The culture.</param>
/// <returns><see cref="string" />.</returns>
string GetLocalizedString(string phrase, string culture);
/// <summary>
/// Gets the localized string.
/// </summary>
/// <param name="phrase">The phrase.</param>
/// <param name="culture">The culture.</param>
/// <returns><see cref="string" />.</returns>
string GetLocalizedString(string phrase, string culture);
/// <summary>
/// Gets the localized string.
/// </summary>
/// <param name="phrase">The phrase.</param>
/// <returns>System.String.</returns>
string GetLocalizedString(string phrase);
/// <summary>
/// Gets the localized string.
/// </summary>
/// <param name="phrase">The phrase.</param>
/// <returns>System.String.</returns>
string GetLocalizedString(string phrase);
/// <summary>
/// Gets the localization options.
/// </summary>
/// <returns><see cref="IEnumerable{LocalizationOption}" />.</returns>
IEnumerable<LocalizationOption> GetLocalizationOptions();
/// <summary>
/// Gets the localization options.
/// </summary>
/// <returns><see cref="IEnumerable{LocalizationOption}" />.</returns>
IEnumerable<LocalizationOption> GetLocalizationOptions();
/// <summary>
/// Returns the correct <see cref="CultureDto" /> for the given language.
/// </summary>
/// <param name="language">The language.</param>
/// <returns>The correct <see cref="CultureDto" /> for the given language.</returns>
CultureDto? FindLanguageInfo(string language);
}
/// <summary>
/// Returns the correct <see cref="CultureDto" /> for the given language.
/// </summary>
/// <param name="language">The language.</param>
/// <returns>The correct <see cref="CultureDto" /> for the given language.</returns>
CultureDto? FindLanguageInfo(string language);
}

View File

@ -209,6 +209,7 @@ namespace MediaBrowser.Model.Querying
ExternalEtag,
PresentationUniqueKey,
InheritedParentalRatingValue,
InheritedParentalRatingSubValue,
ExternalSeriesId,
SeriesPresentationUniqueKey,
DateLastRefreshed,

View File

@ -111,6 +111,8 @@ namespace MediaBrowser.Model.Users
/// <value>The max parental rating.</value>
public int? MaxParentalRating { get; set; }
public int? MaxParentalSubRating { get; set; }
public string[] BlockedTags { get; set; }
public string[] AllowedTags { get; set; }

View File

@ -193,6 +193,7 @@ namespace MediaBrowser.Providers.Manager
if (hasRefreshedMetadata && hasRefreshedImages)
{
item.DateLastRefreshed = DateTime.UtcNow;
updateType |= item.OnMetadataChanged();
}
updateType = await SaveInternal(item, refreshOptions, updateType, isFirstRefresh, requiresRefresh, metadataResult, cancellationToken).ConfigureAwait(false);

View File

@ -84,6 +84,8 @@ public class BaseItemEntity
public int? InheritedParentalRatingValue { get; set; }
public int? InheritedParentalRatingSubValue { get; set; }
public string? UnratedType { get; set; }
public float? CriticRating { get; set; }

View File

@ -249,9 +249,14 @@ namespace Jellyfin.Database.Implementations.Entities
public bool EnableUserPreferenceAccess { get; set; }
/// <summary>
/// Gets or sets the maximum parental age rating.
/// Gets or sets the maximum parental rating score.
/// </summary>
public int? MaxParentalAgeRating { get; set; }
public int? MaxParentalRatingScore { get; set; }
/// <summary>
/// Gets or sets the maximum parental rating sub score.
/// </summary>
public int? MaxParentalRatingSubScore { get; set; }
/// <summary>
/// Gets or sets the remote client bitrate limit.

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Server.Implementations.Migrations
{
/// <inheritdoc />
public partial class AddInheritedParentalRatingSubValue : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "MaxParentalAgeRating",
table: "Users",
newName: "MaxParentalRatingScore");
migrationBuilder.AddColumn<int>(
name: "MaxParentalRatingSubScore",
table: "Users",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "InheritedParentalRatingSubValue",
table: "BaseItems",
type: "INTEGER",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MaxParentalRatingSubScore",
table: "Users");
migrationBuilder.DropColumn(
name: "InheritedParentalRatingValue",
table: "BaseItems");
migrationBuilder.RenameColumn(
name: "MaxParentalRatingScore",
table: "Users",
newName: "MaxParentalAgeRating");
}
}
}

View File

@ -15,9 +15,9 @@ namespace Jellyfin.Server.Implementations.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.2");
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.AccessSchedule", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -40,9 +40,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("UserId");
b.ToTable("AccessSchedules");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.ActivityLog", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ActivityLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -88,9 +90,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("DateCreated");
b.ToTable("ActivityLogs");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.AncestorId", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.AncestorId", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -103,9 +107,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ParentItemId");
b.ToTable("AncestorIds");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.AttachmentStreamInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.AttachmentStreamInfo", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -132,9 +138,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("ItemId", "Index");
b.ToTable("AttachmentStreamInfos");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemEntity", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -218,6 +226,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Property<int?>("IndexNumber")
.HasColumnType("INTEGER");
b.Property<int?>("InheritedParentalRatingSubValue")
.HasColumnType("INTEGER");
b.Property<int?>("InheritedParentalRatingValue")
.HasColumnType("INTEGER");
@ -380,9 +391,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("Type", "TopParentId", "IsVirtualItem", "PresentationUniqueKey", "DateCreated");
b.ToTable("BaseItems");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemImageInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemImageInfo", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -415,9 +428,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ItemId");
b.ToTable("BaseItemImageInfos");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemMetadataField", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemMetadataField", b =>
{
b.Property<int>("Id")
.HasColumnType("INTEGER");
@ -430,9 +445,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ItemId");
b.ToTable("BaseItemMetadataFields");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemProvider", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemProvider", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -449,9 +466,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ProviderId", "ProviderValue", "ItemId");
b.ToTable("BaseItemProviders");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemTrailerType", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemTrailerType", b =>
{
b.Property<int>("Id")
.HasColumnType("INTEGER");
@ -464,9 +483,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ItemId");
b.ToTable("BaseItemTrailerTypes");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Chapter", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Chapter", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -489,9 +510,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("ItemId", "ChapterIndex");
b.ToTable("Chapters");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.CustomItemDisplayPreferences", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.CustomItemDisplayPreferences", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -521,9 +544,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("CustomItemDisplayPreferences");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.DisplayPreferences", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -578,9 +603,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("DisplayPreferences");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.HomeSection", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.HomeSection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -600,9 +627,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("DisplayPreferencesId");
b.ToTable("HomeSection");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ImageInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -625,9 +654,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("ImageInfos");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.ItemDisplayPreferences", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ItemDisplayPreferences", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -669,9 +700,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("UserId");
b.ToTable("ItemDisplayPreferences");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.ItemValue", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ItemValue", b =>
{
b.Property<Guid>("ItemValueId")
.ValueGeneratedOnAdd()
@ -694,9 +727,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("ItemValues");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.ItemValueMap", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ItemValueMap", b =>
{
b.Property<Guid>("ItemValueId")
.HasColumnType("TEXT");
@ -709,9 +744,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ItemId");
b.ToTable("ItemValuesMap");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.MediaSegment", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.MediaSegment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -736,9 +773,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("Id");
b.ToTable("MediaSegments");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.MediaStreamInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.MediaStreamInfo", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -889,9 +928,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("StreamIndex", "StreamType", "Language");
b.ToTable("MediaStreamInfos");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.People", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.People", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -909,9 +950,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("Name");
b.ToTable("Peoples");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.PeopleBaseItemMap", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.PeopleBaseItemMap", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -937,9 +980,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ItemId", "SortOrder");
b.ToTable("PeopleBaseItemMap");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Permission", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -968,9 +1013,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.HasFilter("[UserId] IS NOT NULL");
b.ToTable("Permissions");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Preference", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -1001,9 +1048,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.HasFilter("[UserId] IS NOT NULL");
b.ToTable("Preferences");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Security.ApiKey", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Security.ApiKey", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -1030,9 +1079,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("ApiKeys");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Security.Device", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Security.Device", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -1088,9 +1139,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("UserId", "DeviceId");
b.ToTable("Devices");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Security.DeviceOptions", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Security.DeviceOptions", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -1109,9 +1162,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("DeviceOptions");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.TrickplayInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.TrickplayInfo", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -1140,9 +1195,11 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("ItemId", "Width");
b.ToTable("TrickplayInfos");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -1200,7 +1257,10 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Property<int>("MaxActiveSessions")
.HasColumnType("INTEGER");
b.Property<int?>("MaxParentalAgeRating")
b.Property<int?>("MaxParentalRatingScore")
.HasColumnType("INTEGER");
b.Property<int?>("MaxParentalRatingSubScore")
.HasColumnType("INTEGER");
b.Property<bool>("MustUpdatePassword")
@ -1252,9 +1312,11 @@ namespace Jellyfin.Server.Implementations.Migrations
.IsUnique();
b.ToTable("Users");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.UserData", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.UserData", b =>
{
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
@ -1305,26 +1367,28 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("ItemId", "UserId", "Played");
b.ToTable("UserData");
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
});
modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.AccessSchedule", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.User", null)
.WithMany("AccessSchedules")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Jellyfin.Data.Entities.AncestorId", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.AncestorId", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("Children")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "ParentItem")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "ParentItem")
.WithMany("ParentAncestors")
.HasForeignKey("ParentItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1335,9 +1399,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("ParentItem");
});
modelBuilder.Entity("Jellyfin.Data.Entities.AttachmentStreamInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.AttachmentStreamInfo", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany()
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1346,9 +1410,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemImageInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemImageInfo", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("Images")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1357,9 +1421,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemMetadataField", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemMetadataField", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("LockedFields")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1368,9 +1432,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemProvider", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemProvider", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("Provider")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1379,9 +1443,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemTrailerType", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemTrailerType", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("TrailerTypes")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1390,9 +1454,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.Chapter", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Chapter", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("Chapters")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1401,50 +1465,50 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.DisplayPreferences", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.User", null)
.WithMany("DisplayPreferences")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Jellyfin.Data.Entities.HomeSection", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.HomeSection", b =>
{
b.HasOne("Jellyfin.Data.Entities.DisplayPreferences", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.DisplayPreferences", null)
.WithMany("HomeSections")
.HasForeignKey("DisplayPreferencesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ImageInfo", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.User", null)
.WithOne("ProfileImage")
.HasForeignKey("Jellyfin.Data.Entities.ImageInfo", "UserId")
.HasForeignKey("Jellyfin.Database.Implementations.Entities.ImageInfo", "UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Jellyfin.Data.Entities.ItemDisplayPreferences", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ItemDisplayPreferences", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.User", null)
.WithMany("ItemDisplayPreferences")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Jellyfin.Data.Entities.ItemValueMap", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ItemValueMap", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("ItemValues")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jellyfin.Data.Entities.ItemValue", "ItemValue")
b.HasOne("Jellyfin.Database.Implementations.Entities.ItemValue", "ItemValue")
.WithMany("BaseItemsMap")
.HasForeignKey("ItemValueId")
.OnDelete(DeleteBehavior.Cascade)
@ -1455,9 +1519,9 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("ItemValue");
});
modelBuilder.Entity("Jellyfin.Data.Entities.MediaStreamInfo", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.MediaStreamInfo", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("MediaStreams")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
@ -1466,15 +1530,15 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("Item");
});
modelBuilder.Entity("Jellyfin.Data.Entities.PeopleBaseItemMap", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.PeopleBaseItemMap", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("Peoples")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jellyfin.Data.Entities.People", "People")
b.HasOne("Jellyfin.Database.Implementations.Entities.People", "People")
.WithMany("BaseItems")
.HasForeignKey("PeopleId")
.OnDelete(DeleteBehavior.Cascade)
@ -1485,25 +1549,25 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("People");
});
modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Permission", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.User", null)
.WithMany("Permissions")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Preference", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", null)
b.HasOne("Jellyfin.Database.Implementations.Entities.User", null)
.WithMany("Preferences")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Jellyfin.Data.Entities.Security.Device", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.Security.Device", b =>
{
b.HasOne("Jellyfin.Data.Entities.User", "User")
b.HasOne("Jellyfin.Database.Implementations.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@ -1512,15 +1576,15 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Jellyfin.Data.Entities.UserData", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.UserData", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Database.Implementations.Entities.BaseItemEntity", "Item")
.WithMany("UserData")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jellyfin.Data.Entities.User", "User")
b.HasOne("Jellyfin.Database.Implementations.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@ -1531,7 +1595,7 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Jellyfin.Data.Entities.BaseItemEntity", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.BaseItemEntity", b =>
{
b.Navigation("Chapters");
@ -1556,22 +1620,22 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Navigation("UserData");
});
modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.DisplayPreferences", b =>
{
b.Navigation("HomeSections");
});
modelBuilder.Entity("Jellyfin.Data.Entities.ItemValue", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.ItemValue", b =>
{
b.Navigation("BaseItemsMap");
});
modelBuilder.Entity("Jellyfin.Data.Entities.People", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.People", b =>
{
b.Navigation("BaseItems");
});
modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>
modelBuilder.Entity("Jellyfin.Database.Implementations.Entities.User", b =>
{
b.Navigation("AccessSchedules");

View File

@ -88,7 +88,7 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
var tvma = ratings.FirstOrDefault(x => x.Name.Equals("TV-MA", StringComparison.Ordinal));
Assert.NotNull(tvma);
Assert.Equal(17, tvma!.Value);
Assert.Equal(17, tvma!.RatingScore!.Score);
}
[Fact]
@ -105,47 +105,49 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
var fsk = ratings.FirstOrDefault(x => x.Name.Equals("FSK-12", StringComparison.Ordinal));
Assert.NotNull(fsk);
Assert.Equal(12, fsk!.Value);
Assert.Equal(12, fsk!.RatingScore!.Score);
}
[Theory]
[InlineData("CA-R", "CA", 18)]
[InlineData("FSK-16", "DE", 16)]
[InlineData("FSK-18", "DE", 18)]
[InlineData("FSK-18", "US", 18)]
[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)
[InlineData("CA-R", "CA", 18, 1)]
[InlineData("FSK-16", "DE", 16, null)]
[InlineData("FSK-18", "DE", 18, null)]
[InlineData("FSK-18", "US", 18, null)]
[InlineData("TV-MA", "US", 17, 1)]
[InlineData("XXX", "asdf", 1000, null)]
[InlineData("Germany: FSK-18", "DE", 18, null)]
[InlineData("Rated : R", "US", 17, 0)]
[InlineData("Rated: R", "US", 17, 0)]
[InlineData("Rated R", "US", 17, 0)]
[InlineData(" PG-13 ", "US", 13, 0)]
public async Task GetRatingLevel_GivenValidString_Success(string value, string countryCode, int? expectedScore, int? expectedSubScore)
{
var localizationManager = Setup(new ServerConfiguration()
{
MetadataCountryCode = countryCode
});
await localizationManager.LoadAll();
var level = localizationManager.GetRatingLevel(value);
Assert.NotNull(level);
Assert.Equal(expectedLevel, level!);
var score = localizationManager.GetRatingScore(value);
Assert.NotNull(score);
Assert.Equal(expectedScore, score.Score);
Assert.Equal(expectedSubScore, score.SubScore);
}
[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)
[InlineData("0", 0, null)]
[InlineData("1", 1, null)]
[InlineData("6", 6, null)]
[InlineData("12", 12, null)]
[InlineData("42", 42, null)]
[InlineData("9999", 9999, null)]
public async Task GetRatingLevel_GivenValidAge_Success(string value, int? expectedScore, int? expectedSubScore)
{
var localizationManager = Setup(new ServerConfiguration { MetadataCountryCode = "nl" });
await localizationManager.LoadAll();
var level = localizationManager.GetRatingLevel(value);
Assert.NotNull(level);
Assert.Equal(expectedLevel, level);
var score = localizationManager.GetRatingScore(value);
Assert.NotNull(score);
Assert.Equal(expectedScore, score.Score);
Assert.Equal(expectedSubScore, score.SubScore);
}
[Fact]
@ -156,10 +158,10 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
UICulture = "de-DE"
});
await localizationManager.LoadAll();
Assert.Null(localizationManager.GetRatingLevel("NR"));
Assert.Null(localizationManager.GetRatingLevel("unrated"));
Assert.Null(localizationManager.GetRatingLevel("Not Rated"));
Assert.Null(localizationManager.GetRatingLevel("n/a"));
Assert.Null(localizationManager.GetRatingScore("NR"));
Assert.Null(localizationManager.GetRatingScore("unrated"));
Assert.Null(localizationManager.GetRatingScore("Not Rated"));
Assert.Null(localizationManager.GetRatingScore("n/a"));
}
[Theory]
@ -173,7 +175,7 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
});
await localizationManager.LoadAll();
Assert.Null(localizationManager.GetRatingLevel(value));
Assert.Null(localizationManager.GetRatingScore(value));
}
[Theory]