@@ -455,30 +455,40 @@ def appstream2dict(appstream_url=None) -> dict[str, dict]:
455455 app ["id" ] = appid
456456 apps [appid ] = app
457457
458+ if "content_rating" in app :
459+ print (get_content_rating_details (app ["content_rating" ], "de_DE" ))
460+
458461 return apps
459462
460463
461464def get_content_rating_details (content_rating : dict , locale : str ) -> dict :
465+ if content_rating is None or content_rating .get ("type" ) is None :
466+ return {}
462467 system = AppStream .ContentRatingSystem .from_locale (locale )
463468 rating = AppStream .ContentRating ()
464- rating .set_kind (content_rating ["kind" ])
465- details = {"attrs" : []}
469+
470+ rating .set_kind (content_rating ["type" ])
471+ contentRatingResult = {}
466472
467473 for attr , level in content_rating .items ():
468474 if attr == "kind" :
469475 continue
470476 c_level = AppStream .ContentRatingValue .from_string (level )
471477 rating .add_attribute (attr , c_level )
472478 description = AppStream .ContentRating .attribute_get_description (attr , c_level )
473- details [ "attrs " ] = {
474- "attr " : attr ,
479+ contentRatingResult [ "details " ] = {
480+ "id " : attr ,
475481 "level" : level ,
476482 "description" : description ,
477483 }
478484
479485 min_age = AppStream .ContentRating .get_minimum_age (rating )
486+ # Maxint is used for no details available
480487 if min_age == MAXUINT :
481- details ["minimumAge" ] = None
488+ contentRatingResult ["minimumAge" ] = None
489+ contentRatingResult ["contentRatingSystem" ] = (
490+ AppStream .ContentRatingSystem .to_string (system )
491+ )
482492 else :
483493 details ["minimumAge" ] = AppStream .ContentRatingSystem .format_age (
484494 system , min_age
0 commit comments