Smart Playlists
Here's the ugly summary of playlist production rules:
query -> anded_expression
anded_expression -> ored_expression [ ‘and’ ored_expression ]
ored_expression -> expression [ ‘or’ expression ]
expression -> ‘(’ anded_expression ‘)’ | criterion
criterion -> string_criterion | date_criterion | int_criterion
string_criterion -> string_field [‘!’] string_op string
date_criterion -> date_field [‘!’] date_op date
int_criterion -> int_field [‘!’] int_op int
string_op -> ‘=’ | ‘includes’ | ‘startswith’ | ‘endswith’
string -> ‘”’ BACKSLASH-ESCAPED-STRING-LITERAL ‘”’
date_op -> ‘before’ | ‘after’
date -> YYYY-MM-DD | int date_interval (‘before’ | ‘after’) date |
‘today’
date_interval -> ‘day[s]’ | ‘week[s]’ | ‘month[s]’
int_op -> ‘>’ | ‘<’ | ‘=’ | ‘<=’ | ‘>=’
int -> [0-9]+
Basically, that comes down to one or more criteria connected with AND and OR terms. Valid criteria are integer criteria, date criteria, and string criteria.
String Criteria
String criteria look like this:
field op "value"
where field is a valid database field (column), op is a valid string operator, and value is a literal string value.
Valid string fields include:
- path
- fname
- title
- artist
- album
- genre
- comment
- type
- composer
- orchestra
- grouping
- url
- description
- codectype
For a complete list of valid string fields, refer to the DB Fields page.
Valid string operators include:
- =
- includes
- startswith
- endswith
Each of these operators can be preceded by the unary negate operator (!).
Examples:
path includes "incoming" (artist = "morrissey") or (artist = "smiths") genre != "rap"
Integer Criteria
Like string criteria, except with integer fields.
Valid fields:
- id
- bitrate (in kbps)
- samplerate
- song_length (in ms)
- file_size
- year
- track
- total_tracks
- bpm
- compilation
- rating (0-100, 100 = 5 stars)
- play_count
- data_kind
- item_kind
- sample_count
- force_update
- idx
For a complete list of valid integer fields, refer to the DB Fields page. Some of these fields (force_update, date_kind, item_kind, idx) aren't very useful for playlists.
Valid integer operators:
>
<
- =
>=
<=
Each of these can also be preceeded by the unary negate operator (!).
Examples:
rating > 80 play_count = 0
These would select 4 & 5 star songs, and songs that haven't yet been played, respectively.
Date Criteria
Date criteria is the most complex. Basically, it boils down to:
field dateop date
date can be expressed in several different ways: as a date in YYYY-MM-DD format (or the special date TODAY), or as a time interval before or after a date.
Date fields:
- time_added
- time_modified
- time_played
- db_timestamp
db_timestamp is not very useful for playlists (last time the file was scanned for changes).
valid date operators:
- before
- after
Examples:
time_played after 1 week before today time_added after 1 month before today (time_added before 1 month before today) and (time_added after 2 months before today)
which would give songs played in the last week, songs first added to the database this month, and songs first added to the database last month, respectively.
[Signs Star]
... the Media Server.