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') 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): def episode_data(self):
""" """
Call on a single episode. Call on a single episode.

View file

@ -1589,13 +1589,12 @@ class Music(Items):
genre = None genre = None
try: try:
if self.compilation == 0: if self.compilation == 0:
artists = item.attrib.get('grandparentTitle') artists = api.grandparent_title()
else: else:
artists = item.attrib.get('originalTitle') artists = item.attrib.get('originalTitle')
except AttributeError: except AttributeError:
# compilation not set # compilation not set
artists = item.attrib.get('originalTitle', artists = item.attrib.get('originalTitle', api.grandparent_title())
item.attrib.get('grandparentTitle'))
tracknumber = int(item.attrib.get('index', 0)) tracknumber = int(item.attrib.get('index', 0))
disc = int(item.attrib.get('parentIndex', 1)) disc = int(item.attrib.get('parentIndex', 1))
if disc == 1: if disc == 1:
@ -1780,8 +1779,8 @@ class Music(Items):
# Link song to artists # Link song to artists
artist_loop = [{ artist_loop = [{
'Name': item.attrib.get('grandparentTitle'), 'Name': api.grandparent_title(),
'Id': item.attrib.get('grandparentRatingKey') 'Id': api.grandparent_id()
}] }]
# for index, artist in enumerate(item['ArtistItems']): # for index, artist in enumerate(item['ArtistItems']):
for index, artist in enumerate(artist_loop): for index, artist in enumerate(artist_loop):