<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Setup smart playlists

From SqueezeboxWiki

Revision as of 12:18, 24 June 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Overview

This example will show how to enable support for smart playlists in SqueezeCenter (formerly known as SlimServer) and also how to create a few different types of smart playlists. In this example, we will create the following smart playlists in SqueezeCenter.

  • Top rated pop songs: Should play random songs that have a rating of 4 and above and belong to the Pop genre
  • Mixed rated songs: Should play random songs for the whole library but 80 % of the songs played should be those with a rating of 3 or above
  • Random songs without Christmas: Should play random songs from the whole library but exclude those that belong to the Christmas genre
  • Top rated for decade: Should play random songs that have a rating for 4 and above, when the playlist is started it shall prompt the user for a decade and the playlist should only contain songs within that decade.

Installation

  1. You will need to install the following plugins:
  2. After installing everything you might optionally also want to look at:

If you are using SlimServer 6.5 or earlier, you probably want to look at the old version of this guide instead.

Configuring: Top rated pop songs

To configure the Top rated pop songs playlist you do as follows:

  1. Goto "Extras/SQL Playlist" in the web interface
  2. Select Create new playlist
  3. Select playlist type: Advanced with rating
  4. Enter playlist parameters
    • Playlist name: Top rated pop songs
    • Minimum rating: ****
    • Include genres: Mark Pop deselect the rest
  5. Click Next
  6. Change parameters
    • Filename: topratedpopsongs.sql.values
  7. Click Save to store the changes

You should now have a working Top rated pop songs playlist available in the Dynamic Playlists menu

Configuring: Mixed rated songs

To configure the Mixed rated songs playlist you do as follows:

  1. Goto "Extras/SQL Playlist" in the web interface
  2. Select Create new playlist
  3. Select playlist type: Random rated songs
  4. Enter playlist parameters
    • Playlist name: Mixed rated songs
    • Percentage tracks rated less than *** (50): 20%
  5. Click Next
  6. Change parameters
    • Filename: mixedratedsongs.sql.values
  7. Click Save to store the changes

You should now have a working Mixed rated songs playlist available in the Dynamic Playlists menu

Configuring: Random songs without Christmas

To configure the Random songs without Christmas playlist you do as follows:

  1. Goto "Extras/SQL Playlist" in the web interface
  2. Select Create new playlist
  3. Select playlist type: Random Songs
  4. Enter playlist parameters
    • Playlist name: Random songs without Christmas
    • Exclude genres: Mark Christmas deselect the rest
  5. Click Next
  6. Change parameters
    • Filename: randomsongswithoutchristmas.sql.values
  7. Click Save to store the changes

You should now have a working Random songs without Christmas playlist available in the Dynamic Playlists menu

Configuring: Top rated for decade

To configure the Top rated for decade playlist we will need to edit the SQL manually since no predefined playlist template exist for this senario, do as follows to create this playlist.

  1. Goto "Extras/SQL Playlist" in the web interface
  2. Select Create new playlist
  3. Select playlist type: Top rated for year (This is the one that is closest to what we want)
  4. Enter playlist parameters
    • Playlist name: Top rated for decade
    • Minimum rating: ****
    • Customize SQL: Select Customize SQL
  5. Click Next

You should now see the raw playlist configuration in the SQL Query field, which should look something like this:

-- PlaylistParameter1:year:Select year:
select tracks.url from tracks
	join track_statistics on
		tracks.url=track_statistics.url
	left join dynamicplaylist_history on
		tracks.id=dynamicplaylist_history.id
	where
		audio=1
		and tracks.year='PlaylistParameter1'
		and dynamicplaylist_history.id is null
		and track_statistics.rating>=70
	group by tracks.id
	order by rand()
	limit 10;

This playlist will prompt the user for a year instead of a decade, we change this by changing the first row from:

-- PlaylistParameter1:year:Select year:

To this (please note that this is a single line that continues outside this web page):

-- PlaylistParameter1:custom:Select decade:select floor(tracks.year/10)*10,case when tracks.year>0 then floor(tracks.year/10)*10 else 'Unknown' end from tracks where tracks.audio=1 group by floor(tracks.year/10)*10 order by tracks.year asc

The next step is that we need to change the filtering inside the query, the interesting part is this row:

and tracks.year='PlaylistParameter1'

Which needs to be changed to this:

and tracks.year>='PlaylistParameter1'
and tracks.year<('PlaylistParameter1'+10)

You should now have a SQL Query field that looks like this:

-- PlaylistParameter1:custom:Select decade:select floor(tracks.year/10)*10,case when tracks.year>0 then floor(tracks.year/10)*10 else 'Unknown' end from tracks where tracks.audio=1 group by floor(tracks.year/10)*10 order by tracks.year asc
select tracks.url from tracks
	join track_statistics on
		tracks.url=track_statistics.url
	left join dynamicplaylist_history on
		tracks.id=dynamicplaylist_history.id
	where
		audio=1
		and tracks.year>='PlaylistParameter1'
		and tracks.year<('PlaylistParameter1'+10)
		and dynamicplaylist_history.id is null
		and track_statistics.rating>=70
 	group by tracks.id
	order by rand()
	limit 10;

Now change the rest of the parameters:

  • Filename: topratedfordecade.sql

Finally click Save to store the changes.

You should now have a working Top rated for decade playlist available in the "Music Library/Dynamic Playlists" menu