From 46f742f82f6d0fda347e2ffade32b4b49d30879c Mon Sep 17 00:00:00 2001
From: Richard Arends <richard@mosibi.nl>
Date: Sun, 13 Dec 2015 18:42:53 +0100
Subject: [PATCH] Added support for MPD to display the name before the title if
 it is available

When using a radio stream, the name of the station is often available in
currentsong['name']. Just like the 'mpc' CLI client, this change displays
the name of the station before the current song title.

For example: "Mick Jagger - Let's Work" becomes "Radio 10: Mick Jagger - Let's Work"
---
 homeassistant/components/media_player/mpd.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/homeassistant/components/media_player/mpd.py b/homeassistant/components/media_player/mpd.py
index b6c89cbfc3f..e1cdadd9ae2 100644
--- a/homeassistant/components/media_player/mpd.py
+++ b/homeassistant/components/media_player/mpd.py
@@ -141,7 +141,15 @@ class MpdDevice(MediaPlayerDevice):
     @property
     def media_title(self):
         """ Title of current playing media. """
-        return self.currentsong['title']
+        name = self.currentsong['name']
+        title = self.currentsong['title']
+
+        if name:
+            separator = ': '
+            nameandtitle = (name, title)
+            return separator.join(nameandtitle)
+        else:
+            return title
 
     @property
     def media_artist(self):
-- 
GitLab