From 92f13ff60d5cb1bd78c5faba4c8f0d8f659a713b Mon Sep 17 00:00:00 2001 From: Eugene Kuzin Date: Thu, 15 Mar 2018 14:43:29 +0200 Subject: [PATCH] media_content_type attribute display fix (#13204) * media_content_type fix Kodi media_content_type attribute display fix * media_content_type fix (#6989) fixes attribute display for unknown media * code cleanup * trailing whitespaces * comments correction * redundant "else:" removed --- homeassistant/components/media_player/kodi.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/kodi.py b/homeassistant/components/media_player/kodi.py index 6450b2f5b35..33116258978 100644 --- a/homeassistant/components/media_player/kodi.py +++ b/homeassistant/components/media_player/kodi.py @@ -73,6 +73,8 @@ MEDIA_TYPES = { 'episode': MEDIA_TYPE_TVSHOW, # Type 'channel' is used for radio or tv streams from pvr 'channel': MEDIA_TYPE_CHANNEL, + # Type 'audio' is used for audio media, that Kodi couldn't scroblle + 'audio': MEDIA_TYPE_MUSIC, } SUPPORT_KODI = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ @@ -480,7 +482,12 @@ class KodiDevice(MediaPlayerDevice): @property def media_content_type(self): - """Content type of current playing media.""" + """Content type of current playing media. + + If the media type cannot be detected, the player type is used. + """ + if MEDIA_TYPES.get(self._item.get('type')) is None and self._players: + return MEDIA_TYPES.get(self._players[0]['type']) return MEDIA_TYPES.get(self._item.get('type')) @property