From 013d05087e1cbc20ca367783262ebac01bff8253 Mon Sep 17 00:00:00 2001 From: Flo Faber <48768148+FloFaber@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:23:23 +0200 Subject: [PATCH 1/2] Implement findaddpl command --- src/command/AllCommands.cxx | 1 + src/command/DatabaseCommands.cxx | 45 ++++++++++++++++++++------------ src/command/DatabaseCommands.hxx | 3 +++ 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index 86d7b7dc13..9722c7b904 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -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 }, diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 13fd705ae9..2be7497a2c 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -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(); @@ -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); +} + +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) { diff --git a/src/command/DatabaseCommands.hxx b/src/command/DatabaseCommands.hxx index 3d979d58f8..34f5eb8b45 100644 --- a/src/command/DatabaseCommands.hxx +++ b/src/command/DatabaseCommands.hxx @@ -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); From 4669556a58887ee48d33af2901d3304e7c57c848 Mon Sep 17 00:00:00 2001 From: Flo Faber <48768148+FloFaber@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:37:20 +0200 Subject: [PATCH 2/2] Added documentation for findaddpl --- doc/protocol.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/protocol.rst b/doc/protocol.rst index 5272fc4a3c..1d8cd0a8ba 100644 --- a/doc/protocol.rst +++ b/doc/protocol.rst @@ -1197,6 +1197,15 @@ The music database the queue. Parameters have the same meaning as for :ref:`find ` and :ref:`searchadd `. +.. _command_findaddpl: + +:command:`findaddpl {NAME} {FILTER} [sort {TYPE}] [window {START:END}] [position POS]` + Search the database for songs matching + ``FILTER`` (see :ref:`Filters `) and add them to + the playlist named ``NAME``. + + Parameters have the same meaning as for :ref:`searchaddpl `. + .. _command_list: :command:`list {TYPE} {FILTER} [group {GROUPTYPE}] [window {START:END}]`