From f64f11623b763f6da5591b5fd11e88223f647621 Mon Sep 17 00:00:00 2001 From: skidoo23 Date: Tue, 6 Aug 2024 18:41:21 +0200 Subject: [PATCH] Support MPD 0.22 tag "label" --- NEWS | 1 + src/Instance.cxx | 3 +++ src/SearchPage.cxx | 4 +++- src/SongPage.cxx | 4 ++++ src/strfsong.cxx | 2 ++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 989ca9ab..3d9bb2ce 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ncmpc 0.50 - not yet released * build: require Meson 0.56 * lyrics/musixmatch: add new lyrics extension * lyrics/google: fix partial loading of lyrics +* support MPD 0.22 tag "label" (requires libmpdclient 2.17) ncmpc 0.49 - (2023-08-04) * fix UI freeze if lyrics plugin is stuck diff --git a/src/Instance.cxx b/src/Instance.cxx index 8c5ea0dc..534eb20c 100644 --- a/src/Instance.cxx +++ b/src/Instance.cxx @@ -26,6 +26,9 @@ static constexpr TagMask global_tag_whitelist{ MPD_TAG_TRACK, MPD_TAG_DATE, MPD_TAG_GENRE, +#if LIBMPDCLIENT_CHECK_VERSION(2,17,0) + MPD_TAG_LABEL, +#endif MPD_TAG_COMMENT, }; diff --git a/src/SearchPage.cxx b/src/SearchPage.cxx index 9ae8436b..c21534de 100644 --- a/src/SearchPage.cxx +++ b/src/SearchPage.cxx @@ -40,6 +40,7 @@ static constexpr struct { { MPD_TAG_DATE, "date", N_("date") }, { MPD_TAG_COMPOSER, "composer", N_("composer") }, { MPD_TAG_PERFORMER, "performer", N_("performer") }, + { MPD_TAG_LABEL, "label", N_("label") }, { MPD_TAG_COMMENT, "comment", N_("comment") }, { MPD_TAG_COUNT, nullptr, nullptr } }; @@ -88,7 +89,8 @@ static const char *const help_text[] = { " Example: modified:14d (units: s, M, h, d, m, y)", "", " Available tags: artist, album, title, track,", - " name, genre, date composer, performer, comment, file", + " name, genre, date composer, performer, label,", + " comment, file", "", }; diff --git a/src/SongPage.cxx b/src/SongPage.cxx index 6d166b13..8bcdbee7 100644 --- a/src/SongPage.cxx +++ b/src/SongPage.cxx @@ -63,6 +63,9 @@ static constexpr struct tag_label tag_labels[] = { { MPD_TAG_TRACK, N_("Track") }, { MPD_TAG_DATE, N_("Date") }, { MPD_TAG_GENRE, N_("Genre") }, +#if LIBMPDCLIENT_CHECK_VERSION(2,17,0) + { MPD_TAG_LABEL, N_("Label") }, +#endif { MPD_TAG_COMMENT, N_("Comment") }, { LABEL_PATH, N_("Path") }, { LABEL_BITRATE, N_("Bitrate") }, @@ -342,6 +345,7 @@ SongPage::AddSong(const struct mpd_song *song) noexcept AppendTag(song, MPD_TAG_TRACK); AppendTag(song, MPD_TAG_DATE); AppendTag(song, MPD_TAG_GENRE); + AppendTag(song, MPD_TAG_LABEL); AppendTag(song, MPD_TAG_COMMENT); AppendLine(get_tag_label(LABEL_PATH), mpd_song_get_uri(song), diff --git a/src/strfsong.cxx b/src/strfsong.cxx index 6ad05af5..a414124c 100644 --- a/src/strfsong.cxx +++ b/src/strfsong.cxx @@ -186,6 +186,8 @@ _strfsong(char *const s0, char *const end, tag = MPD_TAG_WORK; else if (strncmp("%grouping%", p, n) == 0) tag = MPD_TAG_GROUPING; + else if (strncmp("%label%", p, n) == 0) + tag = MPD_TAG_LABEL; #endif else if (strncmp("%title%", p, n) == 0) tag = MPD_TAG_TITLE;