Add command stickertypes

Prints all available stickertypes like tagtypes for tags.
This commit is contained in:
jcorporation 2024-08-14 20:53:41 +02:00
parent 965c466e9b
commit f94caa96b8
5 changed files with 26 additions and 1 deletions

2
NEWS
View File

@ -10,7 +10,7 @@ ver 0.24 (not yet released)
- show PCRE support in "config" response - show PCRE support in "config" response
- apply Unicode normalization to case-insensitive filter expressions - apply Unicode normalization to case-insensitive filter expressions
- stickers on playlists and some tag types - stickers on playlists and some tag types
- new commands "stickernames" and "playlistlength" - new commands "stickernames", "stickertypes" and "playlistlength"
- new "search"/"find" filter "added-since" - new "search"/"find" filter "added-since"
- allow range in listplaylist and listplaylistinfo - allow range in listplaylist and listplaylistinfo
- "sticker find" supports sort and window parameter and new sticker compare operators "eq", "lt" and "gt" - "sticker find" supports sort and window parameter and new sticker compare operators "eq", "lt" and "gt"

View File

@ -1579,6 +1579,9 @@ Examples:
:command:`stickernames` :command:`stickernames`
Gets a list of uniq sticker names. Gets a list of uniq sticker names.
:command:`stickertypes`
Shows a list of available sticker types.
Connection settings Connection settings
=================== ===================

View File

@ -188,6 +188,7 @@ static constexpr struct command commands[] = {
#ifdef ENABLE_SQLITE #ifdef ENABLE_SQLITE
{ "sticker", PERMISSION_ADMIN, 3, -1, handle_sticker }, { "sticker", PERMISSION_ADMIN, 3, -1, handle_sticker },
{ "stickernames", PERMISSION_ADMIN, 0, 0, handle_sticker_names }, { "stickernames", PERMISSION_ADMIN, 0, 0, handle_sticker_names },
{ "stickertypes", PERMISSION_ADMIN, 0, 0, handle_sticker_types },
#endif #endif
{ "stop", PERMISSION_PLAYER, 0, 0, handle_stop }, { "stop", PERMISSION_PLAYER, 0, 0, handle_stop },
{ "subscribe", PERMISSION_READ, 1, 1, handle_subscribe }, { "subscribe", PERMISSION_READ, 1, 1, handle_subscribe },

View File

@ -17,6 +17,7 @@
#include "Instance.hxx" #include "Instance.hxx"
#include "util/StringAPI.hxx" #include "util/StringAPI.hxx"
#include "util/ScopeExit.hxx" #include "util/ScopeExit.hxx"
#include "tag/Settings.hxx"
#include "tag/ParseName.hxx" #include "tag/ParseName.hxx"
#include "tag/Names.hxx" #include "tag/Names.hxx"
#include "sticker/TagSticker.hxx" #include "sticker/TagSticker.hxx"
@ -25,6 +26,7 @@
#include "db/PlaylistInfo.hxx" #include "db/PlaylistInfo.hxx"
#include "db/PlaylistVector.hxx" #include "db/PlaylistVector.hxx"
#include "db/DatabaseLock.hxx" #include "db/DatabaseLock.hxx"
#include <fmt/format.h>
#include "song/Filter.hxx" #include "song/Filter.hxx"
namespace { namespace {
@ -454,3 +456,20 @@ handle_sticker(Client &client, Request args, Response &r)
r.Error(ACK_ERROR_ARG, "bad request"); r.Error(ACK_ERROR_ARG, "bad request");
return CommandResult::ERROR; return CommandResult::ERROR;
} }
CommandResult
handle_sticker_types(Client &client, Request args, Response &r)
{
(void) client;
(void) args;
const auto tag_mask = global_tag_mask & r.GetTagMask();
r.Fmt("stickertype: filter\n");
r.Fmt("stickertype: playlist\n");
r.Fmt("stickertype: song\n");
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
if (sticker_allowed_tags.Test(TagType(i)) &&
tag_mask.Test(TagType(i)))
r.Fmt(FMT_STRING("stickertype: {}\n"), tag_item_names[i]);
return CommandResult::OK;
}

View File

@ -14,5 +14,7 @@ CommandResult
handle_sticker(Client &client, Request request, Response &response); handle_sticker(Client &client, Request request, Response &response);
CommandResult CommandResult
handle_sticker_names(Client &client, Request request, Response &response); handle_sticker_names(Client &client, Request request, Response &response);
CommandResult
handle_sticker_types(Client &client, Request request, Response &response);
#endif #endif