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
80 changed files with 3995 additions and 805 deletions

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; }