From 3f718e89248a5c9869bc20bc770d438a590a25e0 Mon Sep 17 00:00:00 2001 From: jcorporation Date: Fri, 30 Aug 2024 21:06:50 +0200 Subject: [PATCH] Change the semantic of the searchplaylist protocol command Old: searchplaylist {NAME} {FILTER} [{START:END}] New: searchplaylist {NAME} {FILTER} [window {START:END}] This is more similar to the other search commands and we can reuse search specific functions in libmpdclient. --- doc/protocol.rst | 2 +- src/command/AllCommands.cxx | 2 +- src/command/PlaylistCommands.cxx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/protocol.rst b/doc/protocol.rst index b938e4ec0..6b9b59eac 100644 --- a/doc/protocol.rst +++ b/doc/protocol.rst @@ -996,7 +996,7 @@ remote playlists (absolute URI with a supported scheme). .. _command_searchplaylist: -:command:`searchplaylist {NAME} {FILTER} [{START:END}]` +:command:`searchplaylist {NAME} {FILTER} [window {START:END}]` Search the playlist for songs matching ``FILTER`` (see :ref:`Filters `). Playlist plugins are supported. A range may be specified to list diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index a97bed4cf..82bd4f0b8 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -176,7 +176,7 @@ static constexpr struct command commands[] = { { "searchaddpl", PERMISSION_CONTROL, 2, -1, handle_searchaddpl }, { "searchcount", PERMISSION_READ, 1, -1, handle_searchcount }, #endif - { "searchplaylist", PERMISSION_READ, 2, 3, handle_searchplaylist }, + { "searchplaylist", PERMISSION_READ, 2, 4, handle_searchplaylist }, { "seek", PERMISSION_PLAYER, 2, 2, handle_seek }, { "seekcur", PERMISSION_PLAYER, 1, 1, handle_seekcur }, { "seekid", PERMISSION_PLAYER, 2, 2, handle_seekid }, diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx index b847d5d49..83f4b0952 100644 --- a/src/command/PlaylistCommands.cxx +++ b/src/command/PlaylistCommands.cxx @@ -164,8 +164,10 @@ handle_searchplaylist(Client &client, Request args, Response &r) args.shift(); RangeArg window = RangeArg::All(); - if (args.size() == 2) { + if (args.size() == 3 && StringIsEqual(args[args.size() - 2], "window")) { window = args.ParseRange(args.size() - 1); + + args.pop_back(); args.pop_back(); }