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
|
||||
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):
|
||||
|
|
Loading…
Add table
Reference in a new issue