Smart playlists: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Montellese
(remove "random" from fields table)
No edit summary
(156 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{XBMC wiki toc}}
{{:Smart_playlists/Contents}}
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.
{{mininav|[[Playlists]] }}


== 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:
== Introduction ==
<source lang="xml">
<section begin="intro"/>Smart Playlists are a versatile feature that allow you to create customised lists of media that may be more suited to your browsing preference. They are a set of rules/filters that allow you to display a sub set of the media in your library.<section end="intro"/>
<?xml version="1.0"?>
<smartplaylist type="music">
  <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>
</source>


=== Types ===
Once a smart playlist is created, it can be browsed like any other list in the {{kodi}} library.
Smart playlists can be of one of the following types:
* music
* songs (default)
* albums
* video
* movies
* tvshows
* episodes
* musicvideos
* mixed


=== Name and Match ===
A Smart Playlist can also be set as a menu item on the main menu using any compatible skin. See: '''''[[Custom home items]]'''''
Basically there are 2 header tags, <code><name></code> and <code><match></code> and then a set of <code><rule></code> tags that define the rules to use, along with an <code><order></code> tag to allow sorting and a <code><limit></code> tag to limit the returned results. Note that the tags and attributes are all case-sensitive. The <code><name></code> tag is the name of the playlist and the <code><match></code> tag indicates how the <code><rule></code> tags should be matched. If <code><match>all</match></code> like in the above example, then only songs which satisfy all the <code><rule></code>'s will be included. If <code><match>one</match></code> is specified, then songs that satisfy any one (or more) of the <code><rule></code>'s will be included.


=== Rules ===
'''Notes:'''
The <code><rule></code> tags, of which there can be as many as you wish, have 2 attributes (<code>field</code> and <code>operator</code>) and a value.
* Smart Playlists work by using the information in the databases. A correctly scanned/scraped library is required for accurate results
* It is not possible to combine different classes of media into a playlist. eg you cannot combine Movies and TV Shows. The only combining allowed is Music and Music Videos as these may share a common Artist


==== Fields ====
These pages are a basic guide to help you understand the process of creating a smart playlist. The easiest way to discover the power of smart playlists is to create and test. Create as many as you like, they can all be deleted and there is no effect on the rest of your setup.
{{editor note|I have noticed many discrepencies between what is listed in this page and what is actually available, particular with fields for TV Shows}}


Depending on the type of the Smart Playlist different <code>field</code>s are available:
{| class="wikitable" style="margin-right: 0;"
!colspan="2"|<code>field</code>
!colspan="2"|music
!colspan="4"|video
!colspan="1"|
|-
!style="padding-left: 5px; padding-right: 10px;"|Name
!style="padding-left: 10px; padding-right: 10px;"|Data type
!style="padding-left: 10px; padding-right: 10px;"|songs
!style="padding-left: 10px; padding-right: 10px;"|albums
!style="padding-left: 10px; padding-right: 10px;"|movies
!style="padding-left: 10px; padding-right: 10px;"|tvshows
!style="padding-left: 10px; padding-right: 10px;"|episodes
!style="padding-left: 10px; padding-right: 10px;"|musicvideos
!style="padding-left: 10px; padding-right: 10px;"|mixed
|-
|style="padding-left: 5px;"|genre
|string
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|album
|string
|{{yes}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|artist
|string
|{{yes}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|albumartist
|string
|{{yes}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|title
|string
|{{yes}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|year
|number
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|time
|number
|{{yes}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|tracknumber
|number
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|filename
|string
|{{yes}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|path
|string
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|playcount
|number
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|lastplayed
|date
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|inprogress
|boolean
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|rating
|number
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|comment
|string
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|dateadded
|date
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|-
|style="padding-left: 5px;"|plot
|string
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|plotoutline
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|tagline
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|mpaarating
|string
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|top250
|number
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|status
|string
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|votes
|number
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|director
|string
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|actor
|string
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|studio
|string
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|country
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|numepisodes
|number
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|numwatched
|number
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|writers
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|airdate
|date
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|episode
|number
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|season
|number
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|tvshow
|string
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|episodetitle
|string
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|review
|string
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|themes
|string
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|moods
|string
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|styles
|string
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|type
|string
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|label
|string
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|hastrailer
|boolean
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|videoresolution
|number
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|audiochannels
|number
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|videocodec
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|audiocodec
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|audiolanguage
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|subtitlelanguage
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|videoaspect
|number
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px;"|set
|string
|{{no}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;"|playlist
|string
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|}


==== Operators ====
== Methods ==
The <code>operator</code> attribute specifies the rule that should be used to match the parameter to the <code>field</code>. All matching is done case-insensitive. The allowed <code>operator</code>s are:
Playlists can be created and edited using either of the two following methods :
; 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.


=== Limit and Order ===
{{big|'''[[Smart_playlists/GUI Method|GUI Method]]'''}} - Create and edit playlists directly in {{kodi}} using the playlist editor
The <code><limit></code> tag simply takes a number of songs as it's limit. A missing limit tag, or <code><limit>0</limit></code> will retrieve all matching songs. The <code><order></code> tag has a <code>direction</code> attribute, the values of which can be <code>ascending</code> or <code>descending</code>, and it's value is a field as above, or can be <code><order>random</order></code> 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 <code><rule></code> 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.
{{big|'''[[Smart_playlists/XSP Method|XSP Method]]'''}} - Advanced users can create and edit the XSP files located in the '''[[userdata]]\playlists''' folder


== Combining Playlists ==
Also...
The <code>playlist</code> <code>field</code> can be used to combine several playlists together. When playlists are combined, the <code><limit></code> and <code><order></code> tags of the included playlists are ignored; only the <code><order></code> and <code><limit></code> 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.
: '''[[Smart_playlists/Rules_and_groupings|Rules & Groupings]]''' - A list of Rules, Fields, Operators and Values that can be used in the XSP files


'''Recently played rock tracks from the 1970s'''
: '''[[Smart_playlists/Examples|Example XSP files]]''' - Example XSP files that can be copied into your own setup
<source lang="xml">
<?xml version="1.0"?>
<smartplaylist type="music">
  <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>
</source>


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.


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


=== Top 100 songs ===
{{updated|18}}
<source lang="xml">
[[Category:Index]]
<?xml version="1.0"?>
[[Category:Guides]]
<smartplaylist type="music">
[[Category:Manual]]
  <name>Top 100 Songs</name>
[[Category:Karellen]]
  <match>all</match>
[[Category:Video library]]
  <rule field="playcount" operator="greaterthan">0</rule>
[[Category:Music library]]
  <order direction="descending">playcount</order>
[[Category:Advanced topics]]
  <limit>100</limit>
</smartplaylist>
</source>
 
=== Rock music from the 1970s ===
<source lang="xml">
<?xml version="1.0"?>
<smartplaylist type="music">
  <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>
</source>
 
[[Category:User Interface]]
[[Category:Video Library]]
[[Category:Music Library]]

Revision as of 20:20, 16 November 2020

Smart Playlists Contents

Home icon grey.png   ▶ Playlists ▶ Smart playlists


Introduction

Smart Playlists are a versatile feature that allow you to create customised lists of media that may be more suited to your browsing preference. They are a set of rules/filters that allow you to display a sub set of the media in your library.

Once a smart playlist is created, it can be browsed like any other list in the Kodi library.

A Smart Playlist can also be set as a menu item on the main menu using any compatible skin. See: Custom home items

Notes:

  • Smart Playlists work by using the information in the databases. A correctly scanned/scraped library is required for accurate results
  • It is not possible to combine different classes of media into a playlist. eg you cannot combine Movies and TV Shows. The only combining allowed is Music and Music Videos as these may share a common Artist

These pages are a basic guide to help you understand the process of creating a smart playlist. The easiest way to discover the power of smart playlists is to create and test. Create as many as you like, they can all be deleted and there is no effect on the rest of your setup.


Methods

Playlists can be created and edited using either of the two following methods :

GUI Method - Create and edit playlists directly in Kodi using the playlist editor

XSP Method - Advanced users can create and edit the XSP files located in the userdata\playlists folder

Also...

Rules & Groupings - A list of Rules, Fields, Operators and Values that can be used in the XSP files
Example XSP files - Example XSP files that can be copied into your own setup