Open JakobDev opened 2 years ago
I've been playing around with this for some days, trying to use the c api via pygobject to construct a content rating and call the minimum age method. But it seems like python still hates me.
When we do this, we should also expose it via schema.org if possible https://schema.org/contentRating
I am currently looking into this. I want to document my progress so far:
The code that was used in gnome-software was upstreamed in https://github.com/ximion/appstream/commit/18c8b18d5a131669fa25a01d283a06f896ca438c
We probably want to do something like this:
import gi
gi.require_version("AppStream", "1.0")
from gi.repository import AppStream
LEVELS = {
'unknown': AppStream.ContentRatingValue.UNKNOWN,
'none': AppStream.ContentRatingValue.NONE,
'mild': AppStream.ContentRatingValue.MILD,
'moderate': AppStream.ContentRatingValue.MODERATE,
'intense': AppStream.ContentRatingValue.INTENSE,
}
def get_content_rating_summary(data: dict, locale: str) -> tuple[str, str]:
system = AppStream.ContentRatingSystem.from_locale(locale)
age = max([
AppStream.ContentRating.attribute_to_csm_age(key, LEVELS[value])
for key, value in data.items()
], default=0)
return (
AppStream.ContentRatingSystem.format_age(system, age),
AppStream.ContentRatingSystem.to_string(system),
)
print(get_content_rating_summary({
'violence-cartoon': 'moderate',
'violence-fantasy': 'intense',
}, 'de_DE'))
# ('6', 'USK')
I think this issue should be addressed as a priority. Refer https://github.com/flathub/net.krafting.PleasureDVR/issues/2.
The OARS informations are currently missing on the Website