Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,15 @@ The music database
the queue. Parameters have the same meaning as for
:ref:`find <command_find>` and :ref:`searchadd <command_searchadd>`.

.. _command_findaddpl:

:command:`findaddpl {NAME} {FILTER} [sort {TYPE}] [window {START:END}] [position POS]`
Search the database for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`) and add them to
the playlist named ``NAME``.

Parameters have the same meaning as for :ref:`searchaddpl <command_searchadd>`.

.. _command_list:

:command:`list {TYPE} {FILTER} [group {GROUPTYPE}] [window {START:END}]`
Expand Down
1 change: 1 addition & 0 deletions src/command/AllCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static constexpr struct command commands[] = {
#ifdef ENABLE_DATABASE
{ "find", PERMISSION_READ, 1, -1, handle_find },
{ "findadd", PERMISSION_ADD, 1, -1, handle_findadd},
{ "findaddpl", PERMISSION_CONTROL, 2, -1, handle_findaddpl },
#endif
#ifdef ENABLE_CHROMAPRINT
{ "getfingerprint", PERMISSION_READ, 1, 1, handle_getfingerprint },
Expand Down
45 changes: 28 additions & 17 deletions src/command/DatabaseCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -189,29 +189,15 @@ handle_match_add(Client &client, Request args, bool fold_case, bool strip_diacri
return CommandResult::OK;
}

CommandResult
handle_findadd(Client &client, Request args, Response &)
{
return handle_match_add(client, args, false, false);
}

CommandResult
handle_searchadd(Client &client, Request args, Response &)
{
auto strip_diacritics = client.StringNormalizationEnabled(SN_STRIP_DIACRITICS);
return handle_match_add(client, args, true, strip_diacritics);
}

CommandResult
handle_searchaddpl(Client &client, Request args, Response &)
{
static CommandResult
handle_match_addpl(Client &client, Request args, bool fold_case) {
const char *playlist = args.shift();

const unsigned position = ParseQueuePosition(args, UINT_MAX);

SongFilter filter;
auto strip_diacritics = client.StringNormalizationEnabled(SN_STRIP_DIACRITICS);
const auto selection = ParseDatabaseSelection(args, true, strip_diacritics, filter);
const auto selection = ParseDatabaseSelection(args, fold_case, strip_diacritics, filter);

const Database &db = client.GetDatabaseOrThrow();

Expand All @@ -225,6 +211,31 @@ handle_searchaddpl(Client &client, Request args, Response &)
return CommandResult::OK;
}

CommandResult
handle_findadd(Client &client, Request args, Response &)
{
return handle_match_add(client, args, false, false);
}

CommandResult
handle_searchadd(Client &client, Request args, Response &)
{
auto strip_diacritics = client.StringNormalizationEnabled(SN_STRIP_DIACRITICS);
return handle_match_add(client, args, true, strip_diacritics);
}
Comment on lines +214 to +225
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't move code around that you did not modify and that's not the target of your patch. That increases the diff size and is confusing.


CommandResult
handle_findaddpl(Client &client, Request args, Response &)
{
return handle_match_addpl(client, args, false);
}

CommandResult
handle_searchaddpl(Client &client, Request args, Response &)
{
return handle_match_addpl(client, args, true);
}

static CommandResult
handle_count_internal(Client &client, Request args, Response &r, bool fold_case, bool strip_diacritics)
{
Expand Down
3 changes: 3 additions & 0 deletions src/command/DatabaseCommands.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ handle_find(Client &client, Request request, Response &response);
CommandResult
handle_findadd(Client &client, Request request, Response &response);

CommandResult
handle_findaddpl(Client &client, Request request, Response &response);

CommandResult
handle_search(Client &client, Request request, Response &response);

Expand Down