Jump to content

Parental Ratings custom labels


Gecko

Recommended Posts

Hello guys,

Discovering a recent UI update about the parental rating label on the web app, I started playing with what could be displayed instead of the fixed COUNTRYCODE-PARENTAL LEVEL like (NL-6) for children media.

I discovered that forcing Emby to save any random text instead of a numerical value was authorized, yet, the parental mechanism behind it would tag the media as an unknown rating, hiding it to restricted users.

image.png.b9304ea6ddf4cfe297094bb6fda622d6.png

 

Looking into the API of the latest beta, I found out that there is an /Localization/ParentalRatings endpoint to retrieve all parental values and labels for the currently selected metadata country.

I would have imagine a POST variant to update those labels to something more custom.

curl -X 'POST' \
'https://emby.media/emby/Localization/ParentalRatings?api_key=XXXXXX' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '[{
"Name": "for all audiences",
"Value": "1"
},
{
"Name": "for child under 6",
"Value": "2"
}
]'

 

But rather to wait for this come true and for those who wants custom labels and still keep the parental mechanism working, I ended up with this (temporary) solution using caddy reverse proxy. For only the specific api endpoint used by emby to retrieve the media metadata, I created a response body manipulation with some regexp to quickly render the labels I want to see. Here is the code for a Caddyfile :

emby.domain.com {

	# specify which api endpoint must be considered
	@ratings {
		method GET
		path /emby/Users/*/Items/*
	}

	handle @ratings {
		replace {
			re "\"OfficialRating\":\"[[:alpha:]]{2}-(TP|AL|U)\"" "\"OfficialRating\":\"All audience\""  # foreign all audience classification
			re "\"OfficialRating\":\"[[:alpha:]]{2}-" "\"OfficialRating\":\"-" # remove any country reference keeping the -XX age
			re "\"OfficialRating\":\"R\"" "\"OfficialRating\":\"-16\""			# US-R = EU-16 
			re "\"OfficialRating\":\"PG\"" "\"OfficialRating\":\"-9\""			# US-PG = EU -9
			re "\"OfficialRating\":\"NR\"," ""									# US-NR should not display anything for clarity
			re "\"OfficialRating\":\"-U\"," ""									# -U is strange so remove it
			re "\"OfficialRating\":\"G\"" "\"OfficialRating\":\"All audience\""	# US-G is All audience
		}
        
		reverse_proxy 192.168.1.100:8096 { # your emby's local ip
			header_up -Accept-Encoding # ask emby server to not compress the response
		}
	}
}

 

So now, even if emby fetch a classification from another country than the one I specified or if it fallback to the US classification, the label displayed is at least consistent to show only the lower age limit for a media, or "All audience" if no restriction apply, which is more appealing for my taste :)

image.png.39b03b6df2948a636bbbf9d747065111.png

 

Hope this helps anyone with this subject and looking forward an official way to customize this element. 

 

 

Edited by Gecko
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...