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:

For a complete list of valid string fields, refer to the DB Fields page.

Valid string operators include:

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:

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 &gt; 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:

db_timestamp is not very useful for playlists (last time the file was scanned for changes).

valid date operators:

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]

Smart playlists (last edited 2007-11-10 04:23:41 by sr-14)