feat(mpd): Get name and/or uri if title not found (#823)

This commit is contained in:
NBonaparte 2017-11-08 21:12:44 -08:00 committed by GitHub
parent 3f9f2dc37f
commit 3092a1b18f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,7 +87,15 @@ namespace mpd {
string mpdsong::get_title() { string mpdsong::get_title() {
assert(m_song); assert(m_song);
auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_TITLE, 0); 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() { unsigned mpdsong::get_duration() {