command/queue: "playlistfind"/"playlistsearch" have a "window" parameter

This commit is contained in:
Max Kellermann 2022-02-14 08:34:26 +01:00
parent e9e3d8c57c
commit 11d24a583d
3 changed files with 18 additions and 2 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.24 (not yet released) ver 0.24 (not yet released)
* protocol
- "playlistfind"/"playlistsearch" have a "window" parameter
* player * player
- add option "mixramp_analyzer" to scan MixRamp tags on-the-fly - add option "mixramp_analyzer" to scan MixRamp tags on-the-fly
* tags * tags

View File

@ -773,10 +773,15 @@ Whenever possible, ids should be used.
.. _command_playlistfind: .. _command_playlistfind:
:command:`playlistfind {FILTER}` :command:`playlistfind {FILTER} [window {START:END}]`
Search the queue for songs matching Search the queue for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`). ``FILTER`` (see :ref:`Filters <filter_syntax>`).
``window`` can be used to query only a portion of the real
response. The parameter is two zero-based queue positions; a
start index (including) and an end index (excluding). The end
index can be omitted, which means the range is open-ended.
.. _command_playlistid: .. _command_playlistid:
:command:`playlistid {SONGID}` :command:`playlistid {SONGID}`
@ -794,7 +799,7 @@ Whenever possible, ids should be used.
.. _command_playlistsearch: .. _command_playlistsearch:
:command:`playlistsearch {FILTER}` :command:`playlistsearch {FILTER} [window {START:END}]`
Search the queue for songs matching Search the queue for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`). ``FILTER`` (see :ref:`Filters <filter_syntax>`).
Parameters have the same meaning as for :ref:`find Parameters have the same meaning as for :ref:`find

View File

@ -290,6 +290,14 @@ static CommandResult
handle_playlist_match(Client &client, Request args, Response &r, handle_playlist_match(Client &client, Request args, Response &r,
bool fold_case) bool fold_case)
{ {
RangeArg window = RangeArg::All();
if (args.size >= 2 && StringIsEqual(args[args.size - 2], "window")) {
window = args.ParseRange(args.size - 1);
args.pop_back();
args.pop_back();
}
SongFilter filter; SongFilter filter;
try { try {
filter.Parse(args, fold_case); filter.Parse(args, fold_case);
@ -302,6 +310,7 @@ handle_playlist_match(Client &client, Request args, Response &r,
QueueSelection selection; QueueSelection selection;
selection.filter = &filter; selection.filter = &filter;
selection.window = window;
playlist_print_find(r, client.GetPlaylist(), selection); playlist_print_find(r, client.GetPlaylist(), selection);
return CommandResult::OK; return CommandResult::OK;