feat(mpd): add support for MPD_TAG_ALBUM_ARTIST

This commit is contained in:
tamago 2018-05-31 10:08:18 +01:00 committed by NBonaparte
parent 2e198ec9c2
commit b70d5b55d8
3 changed files with 10 additions and 0 deletions

View File

@ -64,6 +64,7 @@ namespace mpd {
operator bool(); operator bool();
string get_artist(); string get_artist();
string get_album_artist();
string get_album(); string get_album();
string get_title(); string get_title();
string get_date(); string get_date();

View File

@ -85,6 +85,12 @@ namespace mpd {
return string{tag != nullptr ? tag : ""}; return string{tag != nullptr ? tag : ""};
} }
string mpdsong::get_album_artist() {
assert(m_song);
auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_ALBUM_ARTIST, 0);
return string{tag != nullptr ? tag : ""};
}
string mpdsong::get_album() { string mpdsong::get_album() {
assert(m_song); assert(m_song);
auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_ALBUM, 0); auto tag = mpd_song_get_tag(m_song.get(), MPD_TAG_ALBUM, 0);

View File

@ -206,6 +206,7 @@ namespace modules {
} }
string artist; string artist;
string album_artist;
string album; string album;
string title; string title;
string date; string date;
@ -223,6 +224,7 @@ namespace modules {
if (song && song.get()) { if (song && song.get()) {
artist = song->get_artist(); artist = song->get_artist();
album_artist = song->get_album_artist();
album = song->get_album(); album = song->get_album();
title = song->get_title(); title = song->get_title();
date = song->get_date(); date = song->get_date();
@ -236,6 +238,7 @@ namespace modules {
if (m_label_song) { if (m_label_song) {
m_label_song->reset_tokens(); m_label_song->reset_tokens();
m_label_song->replace_token("%artist%", !artist.empty() ? artist : "untitled artist"); m_label_song->replace_token("%artist%", !artist.empty() ? artist : "untitled artist");
m_label_song->replace_token("%album-artist%", !album_artist.empty() ? album_artist : "untitled album artist");
m_label_song->replace_token("%album%", !album.empty() ? album : "untitled album"); 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("%title%", !title.empty() ? title : "untitled track");
m_label_song->replace_token("%date%", !date.empty() ? date : "unknown date"); m_label_song->replace_token("%date%", !date.empty() ? date : "unknown date");