You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling find with a search window (startend) fails #180
I'm trying to work out the syntax for using a search window when using find(). The MPD documentation says:
find {FILTER} [sort {TYPE}] [window {START:END}]
... window can be used to query only a portion of the real response. The parameter is two zero-based record numbers; a start number and an end number.
And the python-mpd2 documentation says
MPDClient.find(type, what[, ..., startend])
...
window can be used to query only a portion of the real response. The parameter is two zero-based record numbers; a start number and an end number.
But I can't find a syntax that doesn't give an error.
Using a single string in the form from the MPD docs like client.find("any", query, "1:100") gives
mpd.base.CommandError: [2@0] {search} Incorrect number of filter arguments
I also tried using space instead of : and using window 1:100 in case the window string is necessary.
Doing the same but adding in the sort parameter (client.find("any", query, "title", "1:100")) gives no search results - I guess it's now trying to find tracks with a title of 1:100.
Using two separate parameters like client.find("any", query, "1", "100") gives
mpd.base.CommandError: [2@0] {search} Unknown filter type
My query is working fine without the window, I'd just like to enable pagination so I don't get thousands of results returned for short queries. I couldn't find any examples in the examples directory and none of the tests use this feature either. Any help would be greatly appreciated. Thanks.
Hi, this is super late, but I was just messing around with this library tonight and randomly discovered how to call this. You have to use the literal string "window" and pass a tuple. So your example should work with client.find("any", query, "window", (0, 99)) (the window is zero-based).
Note that other fixed keywords like "group" and "sort" that you might see in the MPD docs work the same way. So if you want to add sorting by artist name to your query, it would look like: client.find("any", query, "sort", "Artist", "window", (0, 99))
Activity
valrus commentedon Aug 10, 2022
Hi, this is super late, but I was just messing around with this library tonight and randomly discovered how to call this. You have to use the literal string
"window"and pass a tuple. So your example should work withclient.find("any", query, "window", (0, 99))(the window is zero-based).Note that other fixed keywords like "group" and "sort" that you might see in the MPD docs work the same way. So if you want to add sorting by artist name to your query, it would look like:
client.find("any", query, "sort", "Artist", "window", (0, 99))You can see the tuple parameter handling here:
python-mpd2/mpd/base.py
Line 555 in 41459b5