Documentation
¶
Overview ¶
Package contentrating is Ether's one content-rating model. Every certification (US MPAA and TV Parental Guidelines, and the boards of the countries TMDB lists) normalises to a Rating: the issuing country, the label as certified, and an age Level. Rules, viewer limits and pickers compare Levels, so "PG" and "TV-PG" are the same choice everywhere.
Stored form. US labels are stored bare ("PG", "TV-14"), exactly as Plex shows them. Any other country's label is stored region-qualified the way Plex Media Server writes it, lowercase country then a slash: "de/6", "gb/12A", "ca/14A". A foreign label is never stored as if it were US.
Index ¶
- Constants
- Variables
- func Allowed(rating, max string) bool
- func Canonical(v string) (key string, ok bool)
- func Equivalents(l Level) []string
- func Exceeds(rating, max string) bool
- func FromPrefixed(label string) string
- func IsNotRated(v string) bool
- func Prefixed(stored string) string
- func Qualify(country, label string) string
- type Certification
- type Level
- type Rating
- type Selection
Constants ¶
const NotRatedKey = "NR"
NotRatedKey is the rule and picker value for titles without a usable rating.
Variables ¶
Levels lists the rated levels, mildest first. There is no separate "7+" level: the 6–11 age ratings (TV-Y7, DE 6, SE 7, BR 10) sit with PG, so an allowlist of G and PG never hides a title rated milder than PG.
Functions ¶
func Canonical ¶
Canonical maps any accepted rule or limit value to the level's Key: "TV-G" and "gb/U" become "G", "Not rated" becomes "NR". ok is false for a value that names no level and is not an explicit "not rated".
func Equivalents ¶
Equivalents lists the labels each country's board uses for level l, as stored values (bare US, "cc/label" elsewhere), US first then by country.
func Exceeds ¶
Exceeds reports whether rating is above the limit max. An empty limit is unrestricted. An unrated title, or a limit that names no level, exceeds every limit: restricted viewers never see what Ether cannot place.
func FromPrefixed ¶
FromPrefixed reads a Jellyfin or Emby rating label back into stored form: "DE-6" is "de/6" when DE is a board Ether knows; anything else ("PG-13", "TV-14") is already a stored label.
func IsNotRated ¶
IsNotRated reports whether an owner value means "titles without a rating".
Types ¶
type Certification ¶
type Certification struct {
Country string // ISO 3166-1, any case
Label string
// ReleaseType is TMDB's movie release type (1 premiere, 2 limited
// theatrical, 3 theatrical, 4 digital, 5 physical, 6 TV); 0 for TV
// show content ratings.
ReleaseType int
}
Certification is one rating a provider lists for a title.
type Level ¶
type Level int
Level is an age band. Higher is more mature; Unrated sorts first and is never inside a limit. The integer values are persisted (catalogue content_rating_rank), so they must not be renumbered.
const ( Unrated Level = iota // no usable certification: blank, NR, Unrated, unknown label AllAges // G, TV-G, TV-Y; U (GB), 0 (DE), L (BR) Parental // PG, TV-PG, TV-Y7; PG (GB), 6 (DE), 7 (SE), 10 (BR) Teen // PG-13, TV-14; 12A (GB), 12 (DE), 14A (CA) Mature // R, TV-MA; 15 (GB), 16 (DE), MA15+ (AU) Adult // NC-17; 18 (GB, DE), R18+ (AU) )
func AgeLevel ¶
AgeLevel is the band holding a minimum age: 0–5 all ages, 6–11 parental guidance, 12–14 teens, 15–17 mature, 18 and over adults.
func Lookup ¶
Lookup is the level of a country's label. A label the country's table does not list falls back to a plain age ("16", "12+"); otherwise it is Unrated.
func (Level) Age ¶
Age is the minimum viewer age the level stands for (-1 when unrated). It is also the parental score other protocols use (Jellyfin and Emby compare these numbers; Jellyfin's US file scores G 0, PG 10, PG-13 13).
type Rating ¶
type Rating struct {
// Country is the ISO 3166-1 code of the issuing board, upper case
// ("US", "DE", "CA-QC"). Empty when a bare stored label is not a US
// label and its country cannot be known.
Country string
Label string // as certified: "TV-PG", "6", "12A"
Level Level
}
Rating is one parsed certification.
func Parse ¶
Parse reads a stored or owner-entered rating. Bare US labels resolve as US. A bare label from another system (stored by an older release, or typed by the owner) resolves only when every board that uses it agrees on the level, or when it is a plain age ("12", "16+"); anything else is Unrated rather than a guess.
type Selection ¶
type Selection struct {
Value string // stored form: "PG", "de/6"; "" when nothing usable
Source string // "tmdb:US:6", "tmdb:CA"; "" when Value is ""
}
Selection is the chosen rating in stored form, and where it came from.
func Select ¶
func Select(certs []Certification, region string) Selection
Select chooses a title's rating from a provider's certifications: the owner's region first, then the US, then other countries (foreignPriority order). Within a country it takes the first label that has an age level, by release type. A foreign rating is kept region-qualified ("de/6"), never passed off as US. When no country has a rated label, an explicit "not rated" from the region or the US is kept ("NR"), as Plex shows it.