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:
parent
85b62a20c8
commit
035d518cb6
1 changed files with 4 additions and 4 deletions
|
@ -141,13 +141,13 @@ class MpdDevice(MediaPlayerDevice):
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
""" Title of current playing media. """
|
""" Title of current playing media. """
|
||||||
name = self.currentsong['name']
|
name = self.currentsong.get('name', None)
|
||||||
title = self.currentsong['title']
|
title = self.currentsong['title']
|
||||||
|
|
||||||
if name:
|
if name is None:
|
||||||
return '{}: {}'.format(name, title)
|
|
||||||
else:
|
|
||||||
return title
|
return title
|
||||||
|
else:
|
||||||
|
return '{}: {}'.format(name, title)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_artist(self):
|
def media_artist(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue