3.1.4.1 mppopm Filter Syntax

The mpdpopm filter syntax is a (small) superset of the MPD syntax. The following is a grammar for filter expressions in modified BNF:

<expr> ::= <term> | <negation> | <conjunction> | <disjunction>
           
<term> ::= "(" <comparison> ")"

<negation> ::= "(" "!" <expr> ")"

<conjunction> ::= "(" <conj-list> ")"

<conj-list> ::= <expr> "AND" <expr> |
                <expr> "AND" <conj-list>

<disjunction> ::= "(" <disj-list> ")"

<disj-list> ::= <expr> "OR" <expr> |
                <expr> "OR" <disj-list>

<comparison> ::= <tag> <op> <qtext>                             |
                 "file" "==" <qtext>                            |
                 "base" <qtext>                                 |
                 "modified-since" <qtext>                       |
                 "AudioFormat" <audio-format-op> <audio-format> |
                 <mpdpopm-numeric-tag> <numeric-op> <number>    |
                 "lastplayed" <numeric-op> <date-or-epoch>

<tag> ::= "artist" | "artistsort" | "album" | "albumsort" |
          "albumartist" | "albumartistsort" | "title" | "track" |
          "name" | "genre" | "date" | "originaldate" | "composer" |
          "performer" | "conductor" | "work | "grouping" | "comment" |
          "disc" | "label" | "musicbrainz_artistid" |
          "musicbrainz_albumid" | "musicbrainz_albumartistid" |
          "musicbrainz_trackid" | "musicbrainz_releasetrackid" |
          "musicbrainz_workid"

<op> ::= "==" | "!=" | "contains" | "=~" | "!~"

<audio-format-op> ::= "==" | "=~"

<audio-format> ::= "'" <samplerate>:<bits>:<channels> "'"

<mpdpopm-numeric-tag> ::= "rating" | "playcount"

<numeric-op> ::= "==" | "!=" | "<" | "<=" | ">" | ">="

<number> ::= [0-9]+

<qtext> ::= text enclosed in either single- or double-quotes; if the text
            contains single- or double-quotes, or backslashes, they shall
            be backslash-escaped

<date-or-epoch> ::= either <number> or a single- or double-quoted ISO
                    8601 timestamp

In the above grammar, the non-terminals <samplerate>, <bits>, and <channels> are undefined; please see the MPD manual for details on how to specify them.

Note that tags are matched without regard to case; for consistency’s sake, mpdpopm-defined attributes are also matched case-insensitively.

For a detailed description of how tags are matched, also please see the MPD manual, since mpdpopm delegates the evaluation of all terms already supported by MPD to thereto.