Smart playlists/XSP Method

From Official Kodi Wiki
Jump to: navigation, search
Smart Playlists Contents

Home icon grey.png   ▶ Playlists ▶ Smart playlists ▶ XSP Method


1 Location of XSP Files

The XSP (XBMC Smart Playlist) files are located in the userdata/playlists folder. The location of this folder for each platform is shown in the table below.

Within the /playlists/ folder are three subfolders - mixed, music and video. Playlists must be saved in the correct subfolder.

After saving a XSP file, there is normally no need to restart Kodi, but if the Smart Playlist Manager is active, exit out and re-enter to display the new XSP files.


The Userdata folder is a subfolder of the Kodi Data Folder and is located as shown in the table below.

Operating system Userdata Folder
Android Android/data/org.xbmc.kodi/files/.kodi/userdata/ (see note)
iOS /private/var/mobile/Library/Preferences/Kodi/userdata/
LibreELEC /storage/.kodi/userdata/
Linux ~/.kodi/userdata/
OSMC /home/osmc/.kodi/userdata/
Mac /Users/<your_user_name>/Library/Application Support/Kodi/userdata/
tvOS /private/var/mobile/Library/Preferences/Kodi/userdata/
Windows  %APPDATA%\Kodi\userdata
Windows Portable <Install location chosen by you>\portable_data\userdata\
Windows UWP  %LOCALAPPDATA%\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\
Note: In some Android setups the path may be slightly different to the one stated above.


2 Editing XSP Files

Smart playlists are plain text files that any text editor can create, but we recommend using an editor that can parse XML such as Visual Studio or Notepad++.


3 Breakdown of XSP File

The XSP file consists of the following:

  • Two header tags, <name> and <match>
  • One or more <rule> tags that define the rules to use
  • A <limit> tag to limit the returned results
  • A <group> tag to allow grouping of results
  • An <order> tag to sort the display of the results

Note: All tags and attributes are case-sensitive.


The following example is used to explain each component of the code.

 1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 2 <smartplaylist type="movies">
 3     <name>SciFi by Year</name>
 4     <match>all</match>
 5     <rule field="genre" operator="is">
 6         <value>Science Fiction</value>
 7         <value>Sci-Fi</value>
 8         <value>SciFi</value>
 9     </rule>
10     <group>years</group>
11     <limit>100</limit>
12     <order direction="descending">lastplayed</order>
13 </smartplaylist>


3.1 XML Declaration

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

Must be the first line of the XSP file and there are no variations.


3.2 Top Level Tags

<smartplaylist type="movies">
</smartplaylist>

Top level parent tag which also defines the media type. Only one type can be used and different types of media cannot be mixed into a single playlist.

Available types:

  • Songs
  • Albums
  • Artists
  • Movies
  • TV shows
  • Episodes
  • Music Videos
  • Mixed - used to combine Music and Music Videos.


3.3 Name

    <name>SciFi by Year</name>

The name of the playlist. The name you enter here will be displayed in Kodi.


3.4 Match

    <match>all</match>

If two or more rules have been created add the appropriate rule matching method. If only one rule, use the default all

  • all - an item must match all rules for it to be displayed in the list
  • one - an item needs to match only one of the rules for it to be displayed in the list


3.5 Rules

    <rule field="genre" operator="is">
        <value>Science Fiction</value>
        <value>Sci-Fi</value>
        <value>SciFi</value>
    </rule>

The rule determines how your titles are filtered and added to the smart playlist.

A rule can have multiple <value> entries. Multiple rules can be used in a single smart playlist.

The tag has two attributes:

  • field - Determines which field in the database the rule is applied to
  • operator - Specifies how rule is to be applied. All matching is done case-insensitive. See the Available Rules page for available operators

The <value> tag provides the string to be matched.

For a list of available fields and operators see... Rules & Groupings


3.6 Group

    <group>years</group>

Adds grouping to the results. The displayed list will consist of folder nodes containing matching media items.

eg Selecting group by genre will open a list of all the genres that are used by the titles that match the rules. Then select a genre to see the title list.

The mixed operator can only be used when Sets is chosen as the value. It allows combining of what is considered two classes of media - a set/collection and a movie

  • Disabled - Will only list the collection for movies that belong to a Set. Enter a collection to see the individual movie(s) that match the rule(s).
  • Enabled - Will show the collection that the matching movies belong to as well as the individual movies that do not belong to a set/collection.

For a list of available groupings see... Rules & Groupings


3.7 Limit

    <limit>100</limit>

Used to limit the number of matches in the list. You may want to display all matches or limit to the first 100 matches, for example.

To display all items, omit the tag.


3.8 Order

    <order direction="descending">lastplayed</order>

The order tag will determine the order of the items in the list.

The <order> tag has a direction attribute which can be ascending or descending.

The value can be any value that is used in the Rule field.

For random order use <order>random</order>. Random should be used with care as it can be slow on large libraries.


Note:

  • The rule fields and rule operators can change between Kodi versions. If unsure of available fields and operators, use the GUI method to create the start of your playlist to pre-fill in the unknown fields and operators.


Return to top