mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
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
@ -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…
x
Reference in New Issue
Block a user