Expect the case where currentsong['name'] can be absent. Use the .get

funtion with a default value set to None
This commit is contained in:
Richard Arends 2015-12-13 19:54:10 +01:00
parent 85b62a20c8
commit 035d518cb6

View file

@ -141,13 +141,13 @@ class MpdDevice(MediaPlayerDevice):
@property
def media_title(self):
""" Title of current playing media. """
name = self.currentsong['name']
name = self.currentsong.get('name', None)
title = self.currentsong['title']
if name:
return '{}: {}'.format(name, title)
else:
if name is None:
return title
else:
return '{}: {}'.format(name, title)
@property
def media_artist(self):