From 2c8a06bfbec7e90878b11f0e42c03dba8d64e0a7 Mon Sep 17 00:00:00 2001 From: mvillarejo Date: Thu, 16 Mar 2017 00:51:31 +0100 Subject: [PATCH] media_player.kodi extra attributes for tvshow and music media (#6622) * media_player.kodi extra attributes for tvshow and music media * removed extra whitespaces/CR * Kodi - add extra attributes #6250 (removed music attributes) * Restored music attributes, this is ready for merge * linting amended * Fix Kodi artist support * Copy-paste error * Fix for non-music artist lookup Kodi returns an emtpy list on videos, so we need to be able to handle that as well. --- homeassistant/components/media_player/kodi.py | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/kodi.py b/homeassistant/components/media_player/kodi.py index 13994ea4436..f1f2106b441 100644 --- a/homeassistant/components/media_player/kodi.py +++ b/homeassistant/components/media_player/kodi.py @@ -316,7 +316,8 @@ class KodiDevice(MediaPlayerDevice): self._item = (yield from self.server.Player.GetItem( player_id, - ['title', 'file', 'uniqueid', 'thumbnail', 'artist'] + ['title', 'file', 'uniqueid', 'thumbnail', 'artist', + 'albumartist', 'showtitle', 'album', 'season', 'episode'] ))['item'] else: self._properties = {} @@ -398,6 +399,44 @@ class KodiDevice(MediaPlayerDevice): return self._item.get( 'title', self._item.get('label', self._item.get('file'))) + @property + def media_series_title(self): + """Title of series of current playing media, TV show only.""" + return self._item.get('showtitle') + + @property + def media_season(self): + """Season of current playing media, TV show only.""" + return self._item.get('season') + + @property + def media_episode(self): + """Episode of current playing media, TV show only.""" + return self._item.get('episode') + + @property + def media_album_name(self): + """Album name of current playing media, music track only.""" + return self._item.get('album') + + @property + def media_artist(self): + """Artist of current playing media, music track only.""" + artists = self._item.get('artist', []) + if len(artists) > 0: + return artists[0] + else: + return None + + @property + def media_album_artist(self): + """Album artist of current playing media, music track only.""" + artists = self._item.get('albumartist', []) + if len(artists) > 0: + return artists[0] + else: + return None + @property def supported_features(self): """Flag media player features that are supported."""