Added "searchcount" command, a case-insensitive "count"
The `count` command isn't case-insensitive. This adds `searchcount` which is a case-insensitive version of `count`.
This commit is contained in:
parent
8b1ff3f005
commit
6adff85fd6
1
NEWS
1
NEWS
|
@ -1,5 +1,6 @@
|
|||
ver 0.24 (not yet released)
|
||||
* protocol
|
||||
- new command "searchcount" (case-insensitive "count")
|
||||
- "playlistfind"/"playlistsearch" have "sort" and "window" parameters
|
||||
- "save" can append to or replace an existing playlist
|
||||
- filter "prio" (for "playlistfind"/"playlistsearch")
|
||||
|
|
|
@ -1286,6 +1286,16 @@ The music database
|
|||
The ``position`` parameter specifies where the songs will be
|
||||
inserted. [#since_0_23_4]_
|
||||
|
||||
.. _command_searchcount:
|
||||
|
||||
:command:`searchcount {FILTER} [group {GROUPTYPE}]`
|
||||
Count the number of songs and their total playtime in
|
||||
the database matching ``FILTER`` (see
|
||||
:ref:`Filters <filter_syntax>`).
|
||||
|
||||
Parameters have the same meaning as for :ref:`count <command_search>`
|
||||
except the search is not case sensitive.
|
||||
|
||||
.. _command_update:
|
||||
|
||||
:command:`update [URI]`
|
||||
|
|
|
@ -189,6 +189,7 @@ static constexpr struct command commands[] = {
|
|||
{ "search", PERMISSION_READ, 1, -1, handle_search },
|
||||
{ "searchadd", PERMISSION_ADD, 1, -1, handle_searchadd },
|
||||
{ "searchaddpl", PERMISSION_CONTROL, 2, -1, handle_searchaddpl },
|
||||
{ "searchcount", PERMISSION_READ, 1, -1, handle_searchcount },
|
||||
#endif
|
||||
{ "seek", PERMISSION_PLAYER, 2, 2, handle_seek },
|
||||
{ "seekcur", PERMISSION_PLAYER, 1, 1, handle_seekcur },
|
||||
|
|
|
@ -231,8 +231,8 @@ handle_searchaddpl(Client &client, Request args, Response &)
|
|||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_count(Client &client, Request args, Response &r)
|
||||
static CommandResult
|
||||
handle_count_internal(Client &client, Request args, Response &r, bool fold_case)
|
||||
{
|
||||
TagType group = TAG_NUM_OF_ITEM_TYPES;
|
||||
if (args.size() >= 2 && StringIsEqual(args[args.size() - 2], "group")) {
|
||||
|
@ -251,7 +251,7 @@ handle_count(Client &client, Request args, Response &r)
|
|||
SongFilter filter;
|
||||
if (!args.empty()) {
|
||||
try {
|
||||
filter.Parse(args, false);
|
||||
filter.Parse(args, fold_case);
|
||||
} catch (...) {
|
||||
r.Error(ACK_ERROR_ARG,
|
||||
GetFullMessage(std::current_exception()).c_str());
|
||||
|
@ -265,6 +265,18 @@ handle_count(Client &client, Request args, Response &r)
|
|||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_count(Client &client, Request args, Response &r)
|
||||
{
|
||||
return handle_count_internal(client, args, r, false);
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_searchcount(Client &client, Request args, Response &r)
|
||||
{
|
||||
return handle_count_internal(client, args, r, true);
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_listall(Client &client, Request args, Response &r)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,9 @@ handle_searchadd(Client &client, Request request, Response &response);
|
|||
CommandResult
|
||||
handle_searchaddpl(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_searchcount(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_count(Client &client, Request request, Response &response);
|
||||
|
||||
|
|
Loading…
Reference in New Issue