Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2e5ca1cb
Commit
2e5ca1cb
authored
Oct 14, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/database: add "position" parameter to "findadd" and "searchadd"
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/888
parent
680fb51c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
3 deletions
+39
-3
NEWS
NEWS
+1
-0
protocol.rst
doc/protocol.rst
+5
-2
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+33
-1
No files found.
NEWS
View file @
2e5ca1cb
...
...
@@ -5,6 +5,7 @@ ver 0.23 (not yet released)
- support "listfiles" with arbitrary storage plugins
- support relative positions in "addid"
- fix relative positions in "move" and "moveid"
- add "position" parameter to "findadd" and "searchadd"
* database
- proxy: require MPD 0.20 or later
- proxy: require libmpdclient 2.11 or later
...
...
doc/protocol.rst
View file @
2e5ca1cb
...
...
@@ -1191,15 +1191,18 @@ The music database
.. _command_search:
:command:`search {FILTER} [sort {TYPE}] [window {START:END}]`
:command:`search {FILTER} [sort {TYPE}] [window {START:END}]
[position POS]
`
Search the database for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`). Parameters
have the same meaning as for :ref:`find <command_find>`,
except that search is not case sensitive.
The ``position`` parameter specifies where the songs will be
inserted.
.. _command_searchadd:
:command:`searchadd {FILTER} [sort {TYPE}] [window {START:END}]`
:command:`searchadd {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 queue.
...
...
src/command/DatabaseCommands.cxx
View file @
2e5ca1cb
...
...
@@ -19,6 +19,7 @@
#include "DatabaseCommands.hxx"
#include "Request.hxx"
#include "Partition.hxx"
#include "db/DatabaseQueue.hxx"
#include "db/DatabasePlaylist.hxx"
#include "db/DatabasePrint.hxx"
...
...
@@ -70,6 +71,21 @@ ParseSortTag(const char *s)
return
tag
;
}
static
unsigned
ParseQueuePosition
(
Request
&
args
,
unsigned
queue_length
)
{
if
(
args
.
size
>=
2
&&
StringIsEqual
(
args
[
args
.
size
-
2
],
"position"
))
{
unsigned
position
=
args
.
ParseUnsigned
(
args
.
size
-
1
,
queue_length
);
args
.
pop_back
();
args
.
pop_back
();
return
position
;
}
/* append to the end of the queue by default */
return
queue_length
;
}
/**
* Convert all remaining arguments to a #DatabaseSelection.
*
...
...
@@ -142,11 +158,27 @@ handle_search(Client &client, Request args, Response &r)
static
CommandResult
handle_match_add
(
Client
&
client
,
Request
args
,
bool
fold_case
)
{
auto
&
partition
=
client
.
GetPartition
();
const
auto
queue_length
=
partition
.
playlist
.
queue
.
GetLength
();
const
unsigned
position
=
ParseQueuePosition
(
args
,
queue_length
);
SongFilter
filter
;
const
auto
selection
=
ParseDatabaseSelection
(
args
,
fold_case
,
filter
);
auto
&
partition
=
client
.
GetPartition
();
AddFromDatabase
(
partition
,
selection
);
if
(
position
<
queue_length
)
{
const
auto
new_queue_length
=
partition
.
playlist
.
queue
.
GetLength
();
const
RangeArg
range
{
queue_length
,
new_queue_length
};
try
{
partition
.
MoveRange
(
range
,
position
);
}
catch
(...)
{
/* ignore - shall we handle it? */
}
}
return
CommandResult
::
OK
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment