New api method grandparent title

This commit is contained in:
croneter 2018-03-10 14:56:24 +01:00
parent 04f94f0828
commit e642e30978
2 changed files with 11 additions and 5 deletions

View file

@ -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.

View file

@ -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):