Merge branch 'added_time_proxy_plugin' of https://github.com/jcorporation/MPD

This commit is contained in:
Max Kellermann 2023-11-26 08:17:41 +01:00
commit fe4695f92a
1 changed files with 17 additions and 0 deletions

View File

@ -209,6 +209,11 @@ ProxySong::ProxySong(const mpd_song *song)
if (_mtime > 0) if (_mtime > 0)
mtime = std::chrono::system_clock::from_time_t(_mtime); mtime = std::chrono::system_clock::from_time_t(_mtime);
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
if (const auto _added = mpd_song_get_added(song); _added > 0)
added = std::chrono::system_clock::from_time_t(_added);
#endif
start_time = SongTime::FromS(mpd_song_get_start(song)); start_time = SongTime::FromS(mpd_song_get_start(song));
end_time = SongTime::FromS(mpd_song_get_end(song)); end_time = SongTime::FromS(mpd_song_get_end(song));
@ -328,6 +333,12 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection,
if (!mpd_search_add_sort_name(connection, "Last-Modified", if (!mpd_search_add_sort_name(connection, "Last-Modified",
selection.descending)) selection.descending))
return false; return false;
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
} else if (selection.sort == SORT_TAG_ADDED) {
if (!mpd_search_add_sort_name(connection, "Added",
selection.descending))
return false;
#endif
} else { } else {
const auto sort = Convert(selection.sort); const auto sort = Convert(selection.sort);
/* if this is an unsupported tag, the sort /* if this is an unsupported tag, the sort
@ -809,6 +820,12 @@ IsSortSupported(TagType tag_type) noexcept
return true; return true;
} }
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
if (tag_type == TagType(SORT_TAG_ADDED)) {
return true;
}
#endif
return Convert(tag_type) != MPD_TAG_COUNT; return Convert(tag_type) != MPD_TAG_COUNT;
} }