<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Code Train &#187; hack day</title>
	<atom:link href="http://thecodetrain.co.uk/tag/hack-day/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecodetrain.co.uk</link>
	<description>Where Neil Crosby talks about coding on the train...</description>
	<lastBuildDate>Sun, 03 Apr 2011 18:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Last Genius &#8211; A last.fm hack day project</title>
		<link>http://thecodetrain.co.uk/2008/12/last-genius-a-lastfm-hack-day-project/</link>
		<comments>http://thecodetrain.co.uk/2008/12/last-genius-a-lastfm-hack-day-project/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 11:02:13 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[genius]]></category>
		<category><![CDATA[genius playlists]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[hack day]]></category>
		<category><![CDATA[last.fm]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=182</guid>
		<description><![CDATA[<p>Gosh, it&#8217;s thursday already?  Last Sunday I attended <a href="http://last.fm">last.fm</a>&#8216;s first open <a href="http://www.last.fm/group/Hack+Day">Hack Day</a> near Brick Lane in London with the intention of building a system to allow creation of Genius Playlists using last.fm&#8217;s data.</p>

<p>For those of you who aren&#8217;t sure, a Genius Playlist is a playlist of music that all &#8220;works together&#8221; that&#8217;s created from one seed track of the user&#8217;s choice.  Essentially, it&#8217;s a shortcut to creating playlists of stuff that suits how you&#8217;re feeling at that moment, rather than you having to go to the trouble of creating the playlist yourself.</p>

<p>Whilst I was initially sceptical of how well this would work (I&#8217;ve worked in this problem space before, so I know it isn&#8217;t awesomely easy), since iTunes gained this feature in v8 I&#8217;ve become more and more reliant on it.  My reliance has been so great that I&#8217;ve expected the feature in all the other music based services I use.  For example, when I started using <a href="http://spotify.com">Spotify</a>, one of the first things I did without thinking was to start playing  a track that I wanted to listen to and then look for the &#8220;genius&#8221; button to see what else Spotify would try and play for me.  It upset me that this feature wasn&#8217;t there.  Sure, Spotify and last.fm allow you to play radio stations based on a certain genre, artist or tag, but that misses a piece of perceived control that starting with a chosen song implies.</p>

<p>So, for last.fm&#8217;s hack day I decided to hack together a genius playlist creator.  After all, <a href="http://last.fm/api">last.fm&#8217;s API</a> supplies the <a href="http://www.last.fm/api/show?service=319">track.getSimilar</a> method, which pretty much gives all the data you need for a genius playlist.  </p>

<p>There were a few hurdles to get through though.  First up was playlist creation and playback itself.  It turns out that in last.fm-world you can only create actual playlists if you&#8217;re a paid subscriber to the service.  That&#8217;s not a dealbreaker for me, so I paid my £1.50 for a month&#8217;s subscription to see how it went.  Unfortunately, at that point I realised that whilst I could now create playlists, I could only play them back if they had at least 45 songs in them by at least 15 different artists.  Oh, and I could only play them back in shuffle mode.  On the website.  Not in the desktop app or on the iPhone.  Somewhat sub-optimal.</p>

<p>So, I went back to the drawing board.  If I couldn&#8217;t do playlists how I wanted in last.fm, how about if I found the data I wanted in last.fm and then used Spotify to play it?  Unfortunately, Spotify doesn&#8217;t yet have an API, so this also proved impossible.</p>

<p>Scratch Plan B then.  Thankfully, I did have a Plan 9 available to me &#8211; last.fm&#8217;s ability to autostart tracks on the website by adding <code>?autostart</code> to the end of any song page URL.  Using this ability, I reckoned, I would be able to create a page containing a list of songs that could then be played in a browser window by loading up the individual song pages in a hidden iframe.  Simplicity itsef, and as if by magic it actually worked!</p>

<p>There was, of course, more magic that went into creating Last Genius.  Not all songs on the site are available to stream, and of those that are not all of them are full length tracks.  Because I was playing the songs in iframes I had no way of knowing when a song had actually ended.  I had to make sure that you didn&#8217;t end up hearing the same song twice in a playlist.  All these things and more were hacked around during the hack day, and in the end I had something that actually worked.</p>

<p>The end result was a bookmarklet that you can stick into your browser toolbar and click to create a genius playlist any time you want.  Just make sure you&#8217;re on a Last.fm song page and a playlist will be created for you.  If you&#8217;re not on a song page, lets just say that the system will try and find you some music that it reckons you&#8217;ll like.</p>

<p><a href="javascript:void(window.open('http://projects.thecodetrain.co.uk/last-genius/playlist.php?url='+location.href,'mywin','left=20,top=20,width=700,height=300,toolbar=0,resizable=1'));">Last Genius</a> bookmarklet &#8211; drag onto your toolbar.</p>

<p>All I ask is that you remember that this is a hack.  It&#8217;s only tested in Firefox 3 on the Mac, because during a hack day you don&#8217;t have time to make everything work everywhere (it&#8217;ll probably work elsewhere, I just haven&#8217;t tested yet).  Because Last Genius has to make quite a few calls back to the mothership to set itself up, it might also take a little while to start up.  Just be patient.  For what it&#8217;s worth, I have plans to improve this over Christmas.</p>

<p>Because this is a toy I want for myself I plan to spend a bit more time making it nicer.  With that in mind, if you have any ideas for things that will make it better, please let me know.  Likewise, <a href="https://github.com/NeilCrosby/last-genius/tree">the source code</a> is up on GitHub, so please go fork it and make improvements.  Anything awesome I&#8217;ll very happily merge back into the trunk.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>Gosh, it&#8217;s thursday already?  Last Sunday I attended <a href="http://last.fm">last.fm</a>&#8216;s first open <a href="http://www.last.fm/group/Hack+Day">Hack Day</a> near Brick Lane in London with the intention of building a system to allow creation of Genius Playlists using last.fm&#8217;s data.</p>

<p>For those of you who aren&#8217;t sure, a Genius Playlist is a playlist of music that all &#8220;works together&#8221; that&#8217;s created from one seed track of the user&#8217;s choice.  Essentially, it&#8217;s a shortcut to creating playlists of stuff that suits how you&#8217;re feeling at that moment, rather than you having to go to the trouble of creating the playlist yourself.</p>

<p>Whilst I was initially sceptical of how well this would work (I&#8217;ve worked in this problem space before, so I know it isn&#8217;t awesomely easy), since iTunes gained this feature in v8 I&#8217;ve become more and more reliant on it.  My reliance has been so great that I&#8217;ve expected the feature in all the other music based services I use.  For example, when I started using <a href="http://spotify.com">Spotify</a>, one of the first things I did without thinking was to start playing  a track that I wanted to listen to and then look for the &#8220;genius&#8221; button to see what else Spotify would try and play for me.  It upset me that this feature wasn&#8217;t there.  Sure, Spotify and last.fm allow you to play radio stations based on a certain genre, artist or tag, but that misses a piece of perceived control that starting with a chosen song implies.</p>

<p>So, for last.fm&#8217;s hack day I decided to hack together a genius playlist creator.  After all, <a href="http://last.fm/api">last.fm&#8217;s API</a> supplies the <a href="http://www.last.fm/api/show?service=319">track.getSimilar</a> method, which pretty much gives all the data you need for a genius playlist.  </p>

<p>There were a few hurdles to get through though.  First up was playlist creation and playback itself.  It turns out that in last.fm-world you can only create actual playlists if you&#8217;re a paid subscriber to the service.  That&#8217;s not a dealbreaker for me, so I paid my £1.50 for a month&#8217;s subscription to see how it went.  Unfortunately, at that point I realised that whilst I could now create playlists, I could only play them back if they had at least 45 songs in them by at least 15 different artists.  Oh, and I could only play them back in shuffle mode.  On the website.  Not in the desktop app or on the iPhone.  Somewhat sub-optimal.</p>

<p>So, I went back to the drawing board.  If I couldn&#8217;t do playlists how I wanted in last.fm, how about if I found the data I wanted in last.fm and then used Spotify to play it?  Unfortunately, Spotify doesn&#8217;t yet have an API, so this also proved impossible.</p>

<p>Scratch Plan B then.  Thankfully, I did have a Plan 9 available to me &#8211; last.fm&#8217;s ability to autostart tracks on the website by adding <code>?autostart</code> to the end of any song page URL.  Using this ability, I reckoned, I would be able to create a page containing a list of songs that could then be played in a browser window by loading up the individual song pages in a hidden iframe.  Simplicity itsef, and as if by magic it actually worked!</p>

<p>There was, of course, more magic that went into creating Last Genius.  Not all songs on the site are available to stream, and of those that are not all of them are full length tracks.  Because I was playing the songs in iframes I had no way of knowing when a song had actually ended.  I had to make sure that you didn&#8217;t end up hearing the same song twice in a playlist.  All these things and more were hacked around during the hack day, and in the end I had something that actually worked.</p>

<p>The end result was a bookmarklet that you can stick into your browser toolbar and click to create a genius playlist any time you want.  Just make sure you&#8217;re on a Last.fm song page and a playlist will be created for you.  If you&#8217;re not on a song page, lets just say that the system will try and find you some music that it reckons you&#8217;ll like.</p>

<p><a href="javascript:void(window.open('http://projects.thecodetrain.co.uk/last-genius/playlist.php?url='+location.href,'mywin','left=20,top=20,width=700,height=300,toolbar=0,resizable=1'));">Last Genius</a> bookmarklet &#8211; drag onto your toolbar.</p>

<p>All I ask is that you remember that this is a hack.  It&#8217;s only tested in Firefox 3 on the Mac, because during a hack day you don&#8217;t have time to make everything work everywhere (it&#8217;ll probably work elsewhere, I just haven&#8217;t tested yet).  Because Last Genius has to make quite a few calls back to the mothership to set itself up, it might also take a little while to start up.  Just be patient.  For what it&#8217;s worth, I have plans to improve this over Christmas.</p>

<p>Because this is a toy I want for myself I plan to spend a bit more time making it nicer.  With that in mind, if you have any ideas for things that will make it better, please let me know.  Likewise, <a href="https://github.com/NeilCrosby/last-genius/tree">the source code</a> is up on GitHub, so please go fork it and make improvements.  Anything awesome I&#8217;ll very happily merge back into the trunk.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2008/12/last-genius-a-lastfm-hack-day-project/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

