diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index f4f67cb2..843d85ec 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -539,6 +539,13 @@ class API(object): """ return self.item.get('grandparentRatingKey') + def grandparent_title(self): + """ + Returns the title for the corresponding grandparent, e.g. a TV show + name for episodes, or None + """ + return self.item.get('grandparentTitle') + def episode_data(self): """ Call on a single episode. diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 34601af5..03c83a00 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -1589,13 +1589,12 @@ class Music(Items): genre = None try: if self.compilation == 0: - artists = item.attrib.get('grandparentTitle') + artists = api.grandparent_title() else: artists = item.attrib.get('originalTitle') except AttributeError: # compilation not set - artists = item.attrib.get('originalTitle', - item.attrib.get('grandparentTitle')) + artists = item.attrib.get('originalTitle', api.grandparent_title()) tracknumber = int(item.attrib.get('index', 0)) disc = int(item.attrib.get('parentIndex', 1)) if disc == 1: @@ -1780,8 +1779,8 @@ class Music(Items): # Link song to artists artist_loop = [{ - 'Name': item.attrib.get('grandparentTitle'), - 'Id': item.attrib.get('grandparentRatingKey') + 'Name': api.grandparent_title(), + 'Id': api.grandparent_id() }] # for index, artist in enumerate(item['ArtistItems']): for index, artist in enumerate(artist_loop):