July 14, 2006

LastFMProxy makes a good service better

Author: Joe 'Zonker' Brockmeier

In "Last.fm makes Internet music social," Dmitri Popov extols the wonders of Last.fm, a "social" music site that lets users create Internet radio stations that fits their tastes. Last.fm provides a free player for Linux, but if you want to use Last.fm with your favorite Linux player, you'll need the LastFMProxy written by Vidar Madsen.

Rather than playing the Last.fm feed directly, the LastFMProxy passes the feed on to another application, such as XMMS, amaroK, or another MP3 player capable of handling streams. The songs and artists played are displayed in your Web browser, as opposed to the standalone client, and you can change stations and control the feed from the Web interface. I've been using the proxy for several months, usually for a couple of hours per day, and it has worked flawlessly.

To start with LastFMProxy, you'll need a Last.fm account, Python, and the software. As of this writing, Madsen provides two versions of LastFMProxy: the stable 1.0.3 release, and 1.1alpha5. In my experience, the alpha works fine, except it doesn't update the Web interface with song information; for that, you might want to stick with the stable version. The stable version was released in October of last year, but Madsen says he does plan to keep the program up-to-date; if any changes on the Last.fm side affect LastFMProxy, expect updates to keep LastFMProxy working.

With either version, the install process is the same. Uncompress the tarball or zip file, and cd to the new directory. Open up the configuration file, config.py, and provide your username and password for Last.fm. By default, LastFMProxy uses port 1881 for the feed, but you can change that as well. If you need to go through a proxy, you can also set the proxy host and username and password in config.py.

Once you have the configuration set, save config.py and then run python main.py. You should see a message that says:

To tune in, point your browser to:

Open that URL in your favorite browser, and click Start Radio. If you've already configured an application to handle M3U files, it will open the stream, and you should be able to start listening to Last.fm right away. Otherwise, select the MP3 player you want to use, and then start listening.

Using the Web interface, you can tell Last.fm to skip songs, ban them, or give them a thumbs-up with the "Love" button. On the right-hand side of the screen, you'll see a drop-down selector for the Last.fm station. This may be empty the first time you start up Last.fm.

You can select new stations by modifying the URL you use to connect to Last.fm. For example, if you want to listen to tunes tagged with "punk," you'd browse to http://localhost:1881/lastfm://globaltags/punk, or you could connect using http://localhost:1881/globaltags/punk.m3u. Once you visit a station, it is added to the drop-down menu on the right.

That's really all there is to it. Install LastFMProxy, edit the config, and you're off and running.

Click Here!