View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001580MPDCommandspublic2007-09-25 20:032009-06-20 20:44
Assigned Tocirrus 
PlatformOSOS Version
Product Version 
Target Version0.16.xFixed in Version 
Summary0001580: [PATCH] add complex/regex searching to mpd
DescriptionBecause I use this feature a lot in my current music player, but would like to switch to mpd, I added complex and regular-expression-based searching to mpd, via a new command, "complex_search". The syntax is a bit strange, because I wanted to make the parser as small as possible (currently it's a single 114-line recursive function). I'd really like to see this feature make it into mainline mpd, so if in order to achieve this the command needs new syntax, I'd be happy to do that for you, although I'd feel happier splitting it out into a separate file in that case.

Also, this program relies on POSIX "regex.h" to compile and match regular expressions. I don't know how unportable this may or may not make this program. It compiled and ran without modification to the autoconf magic (which I know nothing about) on the system I created it on, which is x86 Linux (Red-Hat based).

The syntax is as follows:

The equivalent of "search <tagname> <value>" is "complex_search :tag <tagname> <value". To do a regex search, do "complex_search :tag-regex <tagname> <regex>". Regex syntax is POSIX extended regular expressions. Tag can also be "file", "filename" or "any", just like in a regular search.

To 'AND' multiple queries, you do ":all <query> <query> ... !". To 'OR' multiple queries, you do ":any <query> <query> ... !". To 'NOT' multiple queries, do ":none <query> <query> ... !". Multiple exclamation points must each occupy their own argument; you cannot do ":all :tag foo bar :any :tag this that :tag xyzzy plugh !!". What you CAN do, however, is put a number after an exclamation point to indicate how many higher-level queries it ends. For example:

"complex_search :all :none :tag artist "bob dylan" ! :any :tag genre folk :tag genre jazz :tag genre blues !2"

This would search for all songs in the genres "folk", "jazz", or "blues" by artists not named "bob dylan" (ignoring case).

Attached is patch including my changes (produced by "diff -r").
TagsNo tags attached.
Attached Filespatch file icon mpd-search.patch [^] (8,402 bytes) 2007-09-25 20:03 [Show Content]

- Relationships

-  Notes
qball (administrator)
2007-09-26 07:11

This looks like a _very_ interesting patch.
But out of curiosity, what is the performance of the complex_search?
qball (administrator)
2007-12-06 16:14

Again, can you look at performance? does this still work with 100.000 songs?
Avuton Olrich (administrator)
2008-11-23 00:38

What would be even better then at this point, since glib is now ingrained in MPD if Glib/GRegex could be utilized for this purpose. The patch would probably be much smaller in that case, and much easier to accept.
cirrus (administrator)
2009-03-14 11:11

Moved to target version 0.16, due to time constraints.
Misery (reporter)
2009-04-25 23:18

My dynamic-playlist plugin for gmpc would benefit a lot from complex searches.
Misery (reporter)
2009-06-20 20:44

By the way... it would be nice if it would support stickers like
:stickers song rate 5
or if stickers used as blacklist
:none :stickers artist blocked true

- Issue History
Date Modified Username Field Change
2007-09-25 20:03 daekharel New Issue
2007-09-25 20:03 daekharel Status new => assigned
2007-09-25 20:03 daekharel Assigned To => shank
2007-09-25 20:03 daekharel File Added: mpd-search.patch
2007-09-26 07:11 qball Note Added: 0001650
2007-12-06 16:14 qball Note Added: 0001834
2008-10-25 17:01 Avuton Olrich Assigned To shank => cirrus
2008-10-25 20:00 Avuton Olrich Category => Commands
2008-11-23 00:38 Avuton Olrich Note Added: 0002453
2009-02-25 09:42 cirrus Target Version => 0.15
2009-03-14 11:10 cirrus Target Version 0.15 => 0.16.x
2009-03-14 11:11 cirrus Note Added: 0003400
2009-04-25 23:18 Misery Note Added: 0003682
2009-06-20 20:44 Misery Note Added: 0004016

Copyright © 2000 - 2016 MantisBT Team
Powered by Mantis Bugtracker