feat(mpd): Add support for date (#222)

This commit is contained in:
Soham Chowdhury 2016-12-05 00:03:04 +05:30 committed by Michael Carlberg
parent d93bd635b4
commit 16b7d09d63
3 changed files with 13 additions and 0 deletions

View File

@ -63,6 +63,7 @@ namespace mpd {
string get_artist();
string get_album();
string get_title();
string get_date();
unsigned get_duration();
private:

View File

@ -76,6 +76,15 @@ namespace mpd {
return string{tag};
}
string mpdsong::get_date() {
assert(m_song);
auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_DATE, 0);
if (tag == nullptr) {
return "";
}
return string{tag};
}
string mpdsong::get_title() {
assert(m_song);
auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_TITLE, 0);

View File

@ -191,6 +191,7 @@ namespace modules {
string artist;
string album;
string title;
string date;
string elapsed_str;
string total_str;
@ -207,6 +208,7 @@ namespace modules {
artist = song->get_artist();
album = song->get_album();
title = song->get_title();
date = song->get_date();
}
}
} catch (const mpd_exception& err) {
@ -219,6 +221,7 @@ namespace modules {
m_label_song->replace_token("%artist%", !artist.empty() ? artist : "untitled artist");
m_label_song->replace_token("%album%", !album.empty() ? album : "untitled album");
m_label_song->replace_token("%title%", !title.empty() ? title : "untitled track");
m_label_song->replace_token("%date%", !date.empty() ? date : "unknown date");
}
if (m_label_time) {