Difference between revisions of "Smart playlists"

From Official Kodi Wiki
Jump to: navigation, search
m (Types)
(updated the table for artist smartplaylists)
Line 38: Line 38:
 
{| class="wikitable" style="margin-right: 0;"
 
{| class="wikitable" style="margin-right: 0;"
 
!colspan="2"|<code>field</code>
 
!colspan="2"|<code>field</code>
!colspan="2"|music
+
!colspan="3"|music
 
!colspan="4"|video
 
!colspan="4"|video
 
!colspan="1"|
 
!colspan="1"|
Line 46: Line 46:
 
!style="padding-left: 10px; padding-right: 10px;"|songs
 
!style="padding-left: 10px; padding-right: 10px;"|songs
 
!style="padding-left: 10px; padding-right: 10px;"|albums
 
!style="padding-left: 10px; padding-right: 10px;"|albums
 +
!style="padding-left: 10px; padding-right: 10px;"|artists
 
!style="padding-left: 10px; padding-right: 10px;"|movies
 
!style="padding-left: 10px; padding-right: 10px;"|movies
 
!style="padding-left: 10px; padding-right: 10px;"|tvshows
 
!style="padding-left: 10px; padding-right: 10px;"|tvshows
Line 54: Line 55:
 
|style="padding-left: 5px;"|genre
 
|style="padding-left: 5px;"|genre
 
|string
 
|string
 +
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
Line 66: Line 68:
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 74: Line 77:
 
|style="padding-left: 5px;"|artist
 
|style="padding-left: 5px;"|artist
 
|string
 
|string
 +
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
Line 86: Line 90:
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 95: Line 100:
 
|string
 
|string
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
Line 106: Line 112:
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
Line 115: Line 122:
 
|number
 
|number
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
Line 125: Line 133:
 
|number
 
|number
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 135: Line 144:
 
|string
 
|string
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
Line 145: Line 155:
 
|string
 
|string
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
Line 155: Line 166:
 
|number
 
|number
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
Line 165: Line 177:
 
|date
 
|date
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
Line 174: Line 187:
 
|style="padding-left: 5px;"|inprogress
 
|style="padding-left: 5px;"|inprogress
 
|boolean
 
|boolean
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 186: Line 200:
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
Line 195: Line 210:
 
|string
 
|string
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 204: Line 220:
 
|style="padding-left: 5px;"|dateadded
 
|style="padding-left: 5px;"|dateadded
 
|date
 
|date
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 214: Line 231:
 
|style="padding-left: 5px;"|plot
 
|style="padding-left: 5px;"|plot
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 224: Line 242:
 
|style="padding-left: 5px;"|plotoutline
 
|style="padding-left: 5px;"|plotoutline
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 234: Line 253:
 
|style="padding-left: 5px;"|tagline
 
|style="padding-left: 5px;"|tagline
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 244: Line 264:
 
|style="padding-left: 5px;"|mpaarating
 
|style="padding-left: 5px;"|mpaarating
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 254: Line 275:
 
|style="padding-left: 5px;"|top250
 
|style="padding-left: 5px;"|top250
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 264: Line 286:
 
|style="padding-left: 5px;"|status
 
|style="padding-left: 5px;"|status
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 274: Line 297:
 
|style="padding-left: 5px;"|votes
 
|style="padding-left: 5px;"|votes
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 284: Line 308:
 
|style="padding-left: 5px;"|director
 
|style="padding-left: 5px;"|director
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 294: Line 319:
 
|style="padding-left: 5px;"|actor
 
|style="padding-left: 5px;"|actor
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 304: Line 330:
 
|style="padding-left: 5px;"|studio
 
|style="padding-left: 5px;"|studio
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 314: Line 341:
 
|style="padding-left: 5px;"|country
 
|style="padding-left: 5px;"|country
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 324: Line 352:
 
|style="padding-left: 5px;"|numepisodes
 
|style="padding-left: 5px;"|numepisodes
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 334: Line 363:
 
|style="padding-left: 5px;"|numwatched
 
|style="padding-left: 5px;"|numwatched
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 344: Line 374:
 
|style="padding-left: 5px;"|writers
 
|style="padding-left: 5px;"|writers
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 354: Line 385:
 
|style="padding-left: 5px;"|airdate
 
|style="padding-left: 5px;"|airdate
 
|date
 
|date
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 364: Line 396:
 
|style="padding-left: 5px;"|episode
 
|style="padding-left: 5px;"|episode
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 374: Line 407:
 
|style="padding-left: 5px;"|season
 
|style="padding-left: 5px;"|season
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 384: Line 418:
 
|style="padding-left: 5px;"|tvshow
 
|style="padding-left: 5px;"|tvshow
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 394: Line 429:
 
|style="padding-left: 5px;"|episodetitle
 
|style="padding-left: 5px;"|episodetitle
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 406: Line 442:
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 416: Line 453:
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 425: Line 463:
 
|string
 
|string
 
|{{no}}
 
|{{no}}
 +
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{no}}
 
|{{no}}
Line 435: Line 474:
 
|string
 
|string
 
|{{no}}
 
|{{no}}
 +
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{no}}
 
|{{no}}
Line 446: Line 486:
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 456: Line 497:
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 464: Line 506:
 
|style="padding-left: 5px;"|hastrailer
 
|style="padding-left: 5px;"|hastrailer
 
|boolean
 
|boolean
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 474: Line 517:
 
|style="padding-left: 5px;"|videoresolution
 
|style="padding-left: 5px;"|videoresolution
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 484: Line 528:
 
|style="padding-left: 5px;"|audiochannels
 
|style="padding-left: 5px;"|audiochannels
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 494: Line 539:
 
|style="padding-left: 5px;"|videocodec
 
|style="padding-left: 5px;"|videocodec
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 504: Line 550:
 
|style="padding-left: 5px;"|audiocodec
 
|style="padding-left: 5px;"|audiocodec
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 514: Line 561:
 
|style="padding-left: 5px;"|audiolanguage
 
|style="padding-left: 5px;"|audiolanguage
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 524: Line 572:
 
|style="padding-left: 5px;"|subtitlelanguage
 
|style="padding-left: 5px;"|subtitlelanguage
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 534: Line 583:
 
|style="padding-left: 5px;"|videoaspect
 
|style="padding-left: 5px;"|videoaspect
 
|number
 
|number
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 544: Line 594:
 
|style="padding-left: 5px;"|set
 
|style="padding-left: 5px;"|set
 
|string
 
|string
 +
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
 
|{{no}}
Line 551: Line 602:
 
|{{no}}
 
|{{no}}
 
|{{yes}}
 
|{{yes}}
 +
|-
 +
|style="padding-left: 5px;"|instruments
 +
|string
 +
|{{no}}
 +
|{{no}}
 +
|{{yes}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|-
 +
|style="padding-left: 5px;"|biography
 +
|string
 +
|{{no}}
 +
|{{no}}
 +
|{{yes}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|-
 +
|style="padding-left: 5px;"|born
 +
|string
 +
|{{no}}
 +
|{{no}}
 +
|{{yes}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|-
 +
|style="padding-left: 5px;"|band formed
 +
|string
 +
|{{no}}
 +
|{{no}}
 +
|{{yes}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|-
 +
|style="padding-left: 5px;"|disbanded
 +
|string
 +
|{{no}}
 +
|{{no}}
 +
|{{yes}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|-
 +
|style="padding-left: 5px;"|died
 +
|string
 +
|{{no}}
 +
|{{no}}
 +
|{{yes}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 +
|{{no}}
 
|-
 
|-
 
|style="padding-left: 5px;"|playlist
 
|style="padding-left: 5px;"|playlist
 
|string
 
|string
 +
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}
 
|{{yes}}

Revision as of 11:40, 20 August 2012

Template:XBMC wiki toc XBMC supports "Smart" playlists for all types of media, which essentially use a set of rules to limit the results from the databases. They can be created either by using the built-in GUI Smart Playlist Editor accessible from the Playlist section, or by creating an xml file with the extension .xsp (XBMC Smart Playlist). They should be placed in your Userdata directory and cannot be read off of remote shares at present.

1 Format of a Smart Playlist File

Smart playlists are plain text files that can be parsed by an xml reader. Any text editor can be used to create them.

The format is as follows:

<?xml version="1.0"?>
<smartplaylist type="songs">
  <name>All U2 from after 1990</name>
  <match>all</match>
  <rule field="artist" operator="is">U2</rule>
  <rule field="year" operator="greaterthan">1990</rule>
  <limit>50</limit>
  <order direction="descending">playcount</order>
</smartplaylist>

1.1 Types

Smart playlists can be of one of the following types:

  • songs (default)
  • albums
  • movies
  • tvshows
  • episodes
  • musicvideos
  • mixed (audio and music videos)

1.2 Name and Match

Basically there are 2 header tags, <name> and <match> and then a set of <rule> tags that define the rules to use, along with an <order> tag to allow sorting and a <limit> tag to limit the returned results. Note that the tags and attributes are all case-sensitive. The <name> tag is the name of the playlist and the <match> tag indicates how the <rule> tags should be matched. If <match>all</match> like in the above example, then only songs which satisfy all the <rule>'s will be included. If <match>one</match> is specified, then songs that satisfy any one (or more) of the <rule>'s will be included.

1.3 Rules

The <rule> tags, of which there can be as many as you wish, have 2 attributes (field and operator) and a value.

1.3.1 Fields

Depending on the type of the Smart Playlist different fields are available:

field music video
Name Data type songs albums artists movies tvshows episodes musicvideos mixed
genre string Yes Yes Yes Yes Yes Yes Yes Yes
album string Yes Yes No No No No Yes Yes
artist string Yes Yes Yes No No No Yes Yes
albumartist string Yes Yes No No No No Yes Yes
title string Yes No No Yes No No Yes Yes
year number Yes Yes No Yes Yes Yes Yes Yes
time number Yes No No Yes No Yes Yes Yes
tracknumber number Yes No No No No No No Yes
filename string Yes No No Yes No Yes Yes Yes
path string Yes No No Yes Yes Yes Yes Yes
playcount number Yes No No Yes Yes Yes Yes Yes
lastplayed date Yes No No Yes No Yes Yes Yes
inprogress boolean No No No Yes No Yes No Yes
rating number Yes Yes No Yes Yes Yes No Yes
comment string Yes No No No No No No Yes
dateadded date No No No No No No No No
plot string No No No Yes Yes Yes Yes Yes
plotoutline string No No No Yes No No No Yes
tagline string No No No Yes No No No Yes
mpaarating string No No No Yes Yes Yes No Yes
top250 number No No No Yes No No No Yes
status string No No No No Yes No No Yes
votes number No No No Yes Yes Yes No Yes
director string No No No Yes Yes Yes Yes Yes
actor string No No No Yes Yes Yes No Yes
studio string No No No Yes Yes Yes Yes Yes
country string No No No Yes No No No Yes
numepisodes number No No No No Yes No No Yes
numwatched number No No No No Yes No No Yes
writers string No No No Yes No Yes No Yes
airdate date No No No No No Yes No Yes
episode number No No No No No Yes No Yes
season number No No No No No Yes No Yes
tvshow string No No No No Yes Yes No Yes
episodetitle string No No No No No Yes No Yes
review string No Yes No No No No No Yes
themes string No Yes No No No No No Yes
moods string No Yes Yes No No No No Yes
styles string No Yes Yes No No No No Yes
type string No Yes No No No No No Yes
label string No Yes No No No No No Yes
hastrailer boolean No No No Yes No No No Yes
videoresolution number No No No Yes No Yes Yes Yes
audiochannels number No No No Yes No Yes Yes Yes
videocodec string No No No Yes No Yes Yes Yes
audiocodec string No No No Yes No Yes Yes Yes
audiolanguage string No No No Yes No Yes Yes Yes
subtitlelanguage string No No No Yes No Yes Yes Yes
videoaspect number No No No Yes No Yes Yes Yes
set string No No No Yes No No No Yes
instruments string No No Yes No No No No No
biography string No No Yes No No No No No
born string No No Yes No No No No No
band formed string No No Yes No No No No No
disbanded string No No Yes No No No No No
died string No No Yes No No No No No
playlist string Yes Yes Yes Yes Yes Yes Yes Yes

1.3.2 Operators

The operator attribute specifies the rule that should be used to match the parameter to the field. All matching is done case-insensitive. The allowed operators are:

contains 
True if the field contains the parameter as a substring
doesnotcontain 
True if the field does not contain the parameter as a substring
is 
True if the field matches the parameter exactly
isnot 
True if the field does not match the parameter exactly
startswith 
True if the start of the field matches the parameter
endswith 
True if the end of the field matches the parameter
lessthan 
True if the content of the field is less than the parameter
greaterthan 
True if the content of the field is greater than the parameter
after 
True if the content of the field comes after the parameter
before 
True if the content of the field comes before the parameter
inthelast 
True if the field falls in the last range specified by the parameter. Only applicable for a date field.
notinthelast 
True if the field does not fall in the last range specified by the parameter. Only applicable for a date field.

1.4 Limit and Order

The <limit> tag simply takes a number of songs as it's limit. A missing limit tag, or <limit>0</limit> will retrieve all matching songs. The <order> tag has a direction attribute, the values of which can be ascending or descending, and it's value is a field as above, or can be <order>random</order> if you want a random ordering returned. Note that random should be used with care - it is quite slow if the returned results from the <rule> sets is large (more than 500 items).

The above example, therefore selects all songs whose artist field is U2 and whose year field is greater than 1990, orders them by the number of times they've been played (most played first) then limits it to just 50. Thus, the top 50 songs you've played from all U2 songs published after 1990.

2 Combining Playlists

The playlist field can be used to combine several playlists together. When playlists are combined, the <limit> and <order> tags of the included playlists are ignored; only the <order> and <limit> of the final playlist are used.

As a simple example, lets create a new playlist combining the "Rock Music from the 1970s" and "Recently Played Songs" playlists above, to produce a playlist with the recently played rock songs from the 1970s.

Recently played rock tracks from the 1970s

<?xml version="1.0"?>
<smartplaylist type="songs">
  <name>Recently played  Rock Tracks from the 1970s</name>
  <match>all</match>
  <rule field="playlist" operator="is">Rock Music from the 1970s</rule>
  <rule field="playlist" operator="is">Recently Played Songs</rule>
</smartplaylist>

Using this system allows very complex queries to be built. Note that in a single playlist, you can only match ALL of the rules, or ONE (or more) of the rules. This is basically either ANDing the conditions together, or ORing them together. You cannot mix AND with OR in a single playlist. To build up a playlist with both AND and OR operations on the rules, you use multiple playlists to group the AND operations and the OR operations, then combine them as above.

3 Examples

3.1 Recently played songs

<?xml version="1.0"?>
<smartplaylist type="songs">
  <name>Recently Played Songs</name>
  <match>all</match>
  <rule field="lastplayed" operator="inthelast">2 weeks</rule>
  <order direction="descending">lastplayed</order>
</smartplaylist>

3.2 Top 100 songs

<?xml version="1.0"?>
<smartplaylist type="songs">
  <name>Top 100 Songs</name>
  <match>all</match>
  <rule field="playcount" operator="greaterthan">0</rule>
  <order direction="descending">playcount</order>
  <limit>100</limit>
</smartplaylist>

3.3 Rock music from the 1970s

<?xml version="1.0"?>
<smartplaylist type="songs">
  <name>Rock Music from the 1970s</name>
  <match>all</match>
  <rule field="genre" operator="is">Rock</rule>
  <rule field="year" operator="greaterthan">1969</rule>
  <rule field="year" operator="lessthan">1980</rule>
</smartplaylist>