From 3092a1b18f6a5030dfc3567c1ca7c606d2c8fa39 Mon Sep 17 00:00:00 2001 From: NBonaparte Date: Wed, 8 Nov 2017 21:12:44 -0800 Subject: [PATCH] feat(mpd): Get name and/or uri if title not found (#823) --- src/adapters/mpd.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/adapters/mpd.cpp b/src/adapters/mpd.cpp index bbe37b74..6140064f 100644 --- a/src/adapters/mpd.cpp +++ b/src/adapters/mpd.cpp @@ -87,7 +87,15 @@ namespace mpd { string mpdsong::get_title() { assert(m_song); auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_TITLE, 0); - return string{tag != nullptr ? tag : ""}; + if (tag == nullptr) { + tag = mpd_song_get_tag(m_song.get(), MPD_TAG_NAME, 0); + if (tag == nullptr) { + auto uri = mpd_song_get_uri(m_song.get()); + auto name = strrchr(uri, '/'); + tag = name ? name + 1 : uri; + } + } + return string{tag}; } unsigned mpdsong::get_duration() {