@@ -741,7 +741,7 @@ class MediaTag(PlexObject):
741741
742742 Attributes:
743743 filter (str): The library filter for the tag.
744- id (id ): Tag ID (This seems meaningless except to use it as a unique id).
744+ id (int ): Tag ID (This seems meaningless except to use it as a unique id).
745745 key (str): API URL (/library/section/<librarySectionID>/all?<filter>).
746746 role (str): The name of the character role for :class:`~plexapi.media.Role` only.
747747 tag (str): Name of the tag. This will be Animation, SciFi etc for Genres. The name of
@@ -1116,6 +1116,11 @@ class Poster(BaseResource):
11161116 TAG = 'Photo'
11171117
11181118
1119+ class SquareArt (BaseResource ):
1120+ """ Represents a single Square Art object. """
1121+ TAG = 'Photo'
1122+
1123+
11191124class Theme (BaseResource ):
11201125 """ Represents a single Theme object. """
11211126 TAG = 'Track'
@@ -1366,3 +1371,123 @@ class Level(PlexObject):
13661371 def _loadData (self , data ):
13671372 """ Load attribute values from Plex XML response. """
13681373 self .loudness = utils .cast (float , data .attrib .get ('v' ))
1374+
1375+
1376+ @utils .registerPlexObject
1377+ class CommonSenseMedia (PlexObject ):
1378+ """ Represents a single CommonSenseMedia media tag.
1379+ Note: This object is only loaded with partial data from a Plex Media Server.
1380+ Call `reload()` to load the full data from Plex Discover (Plex Pass required).
1381+
1382+ Attributes:
1383+ TAG (str): 'CommonSenseMedia'
1384+ ageRatings (List<:class:`~plexapi.media.AgeRating`>): List of AgeRating objects.
1385+ anyGood (str): A brief description of the media's quality.
1386+ id (int): The ID of the CommonSenseMedia tag.
1387+ key (str): The unique key for the CommonSenseMedia tag.
1388+ oneLiner (str): A brief description of the CommonSenseMedia tag.
1389+ parentalAdvisoryTopics (List<:class:`~plexapi.media.ParentalAdvisoryTopic`>):
1390+ List of ParentalAdvisoryTopic objects.
1391+ parentsNeedToKnow (str): A brief description of what parents need to know about the media.
1392+ talkingPoints (List<:class:`~plexapi.media.TalkingPoint`>): List of TalkingPoint objects.
1393+
1394+ Example:
1395+
1396+ .. code-block:: python
1397+
1398+ from plexapi.server import PlexServer
1399+ plex = PlexServer('http://localhost:32400', token='xxxxxxxxxxxxxxxxxxxx')
1400+
1401+ # Retrieve the Common Sense Media info for a movie
1402+ movie = plex.library.section('Movies').get('Cars')
1403+ commonSenseMedia = movie.commonSenseMedia
1404+ ageRating = commonSenseMedia.ageRatings[0].age
1405+
1406+ # Load the Common Sense Media info from Plex Discover (Plex Pass required)
1407+ commonSenseMedia.reload()
1408+ parentalAdvisoryTopics = commonSenseMedia.parentalAdvisoryTopics
1409+ talkingPoints = commonSenseMedia.talkingPoints
1410+
1411+ """
1412+ TAG = 'CommonSenseMedia'
1413+
1414+ def _loadData (self , data ):
1415+ self .ageRatings = self .findItems (data , AgeRating )
1416+ self .anyGood = data .attrib .get ('anyGood' )
1417+ self .id = utils .cast (int , data .attrib .get ('id' ))
1418+ self .key = data .attrib .get ('key' )
1419+ self .oneLiner = data .attrib .get ('oneLiner' )
1420+ self .parentalAdvisoryTopics = self .findItems (data , ParentalAdvisoryTopic )
1421+ self .parentsNeedToKnow = data .attrib .get ('parentsNeedToKnow' )
1422+ self .talkingPoints = self .findItems (data , TalkingPoint )
1423+
1424+ def _reload (self , ** kwargs ):
1425+ """ Reload the data for the Common Sense Media object. """
1426+ guid = self ._parent ().guid
1427+ if not guid .startswith ('plex://' ):
1428+ return self
1429+
1430+ ratingKey = guid .rsplit ('/' , 1 )[- 1 ]
1431+ account = self ._server .myPlexAccount ()
1432+ key = f'{ account .METADATA } /library/metadata/{ ratingKey } /commonsensemedia'
1433+ data = account .query (key )
1434+ self ._findAndLoadElem (data )
1435+ return self
1436+
1437+
1438+ @utils .registerPlexObject
1439+ class AgeRating (PlexObject ):
1440+ """ Represents a single AgeRating for a Common Sense Media tag.
1441+
1442+ Attributes:
1443+ TAG (str): 'AgeRating'
1444+ age (float): The age rating (e.g. 13, 17).
1445+ ageGroup (str): The age group for the rating (e.g. Little Kids, Teens, etc.).
1446+ rating (float): The star rating (out of 5).
1447+ ratingCount (int): The number of ratings contributing to the star rating.
1448+ type (str): The type of rating (official, adult, child).
1449+ """
1450+ TAG = 'AgeRating'
1451+
1452+ def _loadData (self , data ):
1453+ self .age = utils .cast (float , data .attrib .get ('age' ))
1454+ self .ageGroup = data .attrib .get ('ageGroup' )
1455+ self .rating = utils .cast (float , data .attrib .get ('rating' ))
1456+ self .ratingCount = utils .cast (int , data .attrib .get ('ratingCount' ))
1457+ self .type = data .attrib .get ('type' )
1458+
1459+
1460+ @utils .registerPlexObject
1461+ class TalkingPoint (PlexObject ):
1462+ """ Represents a single TalkingPoint for a Common Sense Media tag.
1463+
1464+ Attributes:
1465+ TAG (str): 'TalkingPoint'
1466+ tag (str): The description of the talking point.
1467+ """
1468+ TAG = 'TalkingPoint'
1469+
1470+ def _loadData (self , data ):
1471+ self .tag = data .attrib .get ('tag' )
1472+
1473+
1474+ @utils .registerPlexObject
1475+ class ParentalAdvisoryTopic (PlexObject ):
1476+ """ Represents a single ParentalAdvisoryTopic for a Common Sense Media tag.
1477+
1478+ Attributes:
1479+ TAG (str): 'ParentalAdvisoryTopic'
1480+ id (str): The ID of the topic (e.g. violence, language, etc.).
1481+ label (str): The label for the topic (e.g. Violence & Scariness, Language, etc.).
1482+ positive (bool): Whether the topic is considered positive.
1483+ rating (float): The rating of the topic (out of 5).
1484+ tag (str): The description of the parental advisory topic.
1485+ """
1486+ TAG = 'ParentalAdvisoryTopic'
1487+
1488+ def _loadData (self , data ):
1489+ self .id = data .attrib .get ('id' )
1490+ self .label = data .attrib .get ('label' )
1491+ self .positive = utils .cast (bool , data .attrib .get ('positive' ))
1492+ self .rating = utils .cast (float , data .attrib .get ('rating' ))
1493+ self .tag = data .attrib .get ('tag' )
0 commit comments