Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Content rating #3637

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Draft: Content rating #3637

wants to merge 4 commits into from

Conversation

xi
Copy link

@xi xi commented Jul 24, 2024

See #114

I worked on this during GUADEC, and I am not sure if I will be able to continue working on this any further. Unfortunately I did not get it to a usable state, but I will try to note down all interesting details so someone else can pick this up and finish the remaining bits and pieces.

gnome-software worked on this a while ago and upstreamed its logic into libappstream (see ximion/appstream@18c8b18). There are some details to this that we should consider:

  • In libappstream, there is a difference between an empty and a missing content rating: empty means none, missing means unknown.
  • They mapped each content rating item to a minimum age, then used the maximum of those. Then they used a locale-dependent rating system (e.g. ESRB for the US or FSK for Germany) to convert that minimum age to a string.
  • In our case, the rating system will probably depend on the Accept-Language header, which is probably fine, but not a perfect match.
  • Note that the mapping of content rating to a minimum age is not locale-dependent. So different cultural ideas about things like nudity are not accounted for.
  • Most controversial is probably the mapping of sexual orientation. See https://gitlab.gnome.org/GNOME/gnome-software/-/blob/5f65a4a09d0892bb3b6e86ce2d02de880b8e52f5/src/gs-age-rating-context-dialog.c#L343.
  • libappstream also provides localized descriptions of all content ratings. I was not sure how to integrate this with flathub's approach to i18n. We could either try to hook into that. Or we could duplicate the code.
  • It would be nice to be able to color-code the minimum age. Unfortunately, the locale-dependent rating systems have different numbers of levels. I do not have a good idea about that yet.
  • For the UI, I planned to have something that is similar to what we do for content safety. My idea was to map every content rating attribute to an icon and every level to a color.
  • It turns out that most icon libraries do not have representations for stuff like violence-bloodshed readily available. It is probably a good idea to look into what gnome-software does.
  • I did not yet have time to add https://schema.org/contentRating annotations

continue
c_level = AppStream.ContentRatingValue.from_string(level)
rating.add_attribute(attr, c_level)
description = AppStream.ContentRating.attribute_get_description(attr, c_level)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure where this gets its locale from.

@xi xi force-pushed the content-rating branch from 4838c7a to e64f45b Compare July 24, 2024 14:48
system = AppStream.ContentRatingSystem.from_locale(locale)
rating = AppStream.ContentRating()
rating.set_kind(content_rating["kind"])
details = {"attrs": []}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylance complains here, I guess details = {} should work fine here

@@ -394,6 +397,33 @@ def appstream2dict(appstream_url=None) -> tuple[dict[str, dict], dict[str, dict]
return apps, apps_locale


def get_content_rating_details(content_rating: dict, locale: str) -> dict:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you work this into the update routine at some point already?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because I wasn't sure how to. See my comment above:

libappstream also provides localized descriptions of all content ratings. I was not sure how to integrate this with flathub's approach to i18n. We could either try to hook into that. Or we could duplicate the code.

@razzeee
Copy link
Member

razzeee commented Jul 28, 2024

Looks promising, work should focus on the backend part for now

@razzeee
Copy link
Member

razzeee commented Oct 12, 2024

kind seems to be wrong and should be type

@razzeee
Copy link
Member

razzeee commented Oct 12, 2024

Pushed something that has started to work, more problems are:

  • description doesn't get translated, do we need to do that on our end?
  • we set a locale which is for e.g. de, but that's not mapping clearly to a rating system so we could assume de_DE, but it might be wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants