MPD now uses the filename if song doesn't have metadata (#10085)

* added support for filename

* used the getter instead - minor mistake

* changed how the filename is generated
This commit is contained in:
Casper Weiss Bang 2017-10-27 11:21:47 +02:00 committed by Pascal Vizeli
parent f17cf1d26b
commit 85d7377beb

View File

@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.mpd/
"""
import logging
import os
from datetime import timedelta
import voluptuous as vol
@ -176,9 +177,13 @@ class MpdDevice(MediaPlayerDevice):
"""Return the title of current playing media."""
name = self._currentsong.get('name', None)
title = self._currentsong.get('title', None)
file_name = self._currentsong.get('file', None)
if name is None and title is None:
return "None"
if file_name is None:
return "None"
else:
return os.path.basename(file_name)
elif name is None:
return title
elif title is None: