Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Play LastFM customized radio streams in iTunes Apps
last.fm is a website that will analyze the music you like to play, and then find musical recommendations for you. It can also stream you a custom radio station comprising that recommended music (streamed from last.fm's own library). I find it to be a great way to hear new music without really looking for it.

Normally you need to play your recommended radio station in last.fm's proprietary player, but this hint describes how to listen using iTunes. This lets you listen through Airport Express speakers, or is good if you just prefer to do all your listening in iTunes.
  1. Create an account at last.fm.
  2. Download and install the Audioscrobbler plugin for iTunes (it's called iScrobbler) from last.fm. You'll need to enter your last.fm username and password into the preferences. This runs in the background and tells last.fm about your listening habits as you use your iTunes normally (when you play your own music). An invasion of privacy, yes, but that is what you're trying to accomplish -- this not only improves the quality of last.fm's collective musical brain, but is also the thing that allows last.fm to make recommendations for you.
  3. You need to use iTunes for some time (I think at least a week) before last.fm can begin to make recommendations for you. You can see your recommendations on your last.fm recommendations page.
Now here's the hint on how to listen to your recommended radio station through iTunes, instead of using the proprietary player. Download Vidar Madsen's LastFMProxy. This is a Python script that translates (proxies) the station in real time into a standard M3U stream, which iTunes is compatible with. Normally you need to start LastFMProxy from the command line, and then listen in conjunction with a web browser. However, the following steps show you how to start it from the Scripts menu of iTunes.

To run LastFMProxy from iTunes' Scripts menu, do the following:
  1. Unzip LastFMProxy and copy the folder into ~/Library/iTunes/Scripts. Rename the folder lastfmproxy.
  2. In that folder, edit the file config.py to change the username and password settings to be your last.fm username and password.
  3. Download these scripts (4KB; macosxhints mirror) and put them in ~/Library -> iTunes -> Scripts. Restart iTunes so they show up in the Scripts menu. These are simple scripts that just save you from using the command line to control LastFMProxy and integrate it better into iTunes.
The Lastfm Start script is the one that starts the Python proxy, and then tells iTunes to play the stream. It takes a second or two to start playing. If you run this script more than once without quitting the proxy, it's ok -- it shouldn't start two instances of the proxy (because the socket is already in use), but should just tune iTunes into the existing proxy.

For more detail about what's playing, run the Lastfm Control script. This just points Safari to a page generated by the LastFMProxy, which also lets you use Lastfm's Skip and Ban functions, as well as modify the station.

The Lastfm Quit script tells the LastFMProxy server to quit (potentially freeing up some tiny amount of computer resources, compared to just pressing Stop or changing the track in iTunes).

You can also add LastFMProxy's stream to your iTunes library, the URL is http://localhost:1881/lastfm.m3u. This can be convenient so you can switch among playing Lastfm and other things, but remember the proxy needs to be started via the Lastfm Start script before that stream will work.

Other Applescripts could easily be written to control LastFMProxy in other ways, such as to tune into various keyword or neighbor stations, or to do the Skip or Ban functions. See LastFMProxy's Readme file for suggestions. Enjoy your music!
    •    
  • Currently 3.33 / 5
  You rated: 4 / 5 (6 votes cast)
 
[87,987 views]  

Play LastFM customized radio streams in iTunes | 13 comments | Create New Account
Click here to return to the 'Play LastFM customized radio streams in iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Play LastFM customized radio streams in iTunes
Authored by: Daij-Djan on May 11, '06 10:11:25AM

cool^2 - for a while I've been using last.fm and always hated having to use the official player. I took the suggestion and TRIEd writing more commands and additionally make them close the browser window... the scripts work but give me an error:

[code]
set link to (text returned of result)
set toclose to false

tell application "Safari"
open location "http://localhost:1881/" & link

repeat with w in windows
if name of w is "http://localhost:1881/" & link then
set toclose to true
end if
if toclose is true then
tell w to close
end if
end repeat
end tell
[/code]

Any idea why?



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: bugmenot on May 11, '06 11:36:01AM
... or just use amua, an alternative player using iTunes to play the stations. It works well for me.

[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: geppo1982 on May 11, '06 03:55:38PM

Great suggestion, thanks!



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: catzforever on May 11, '06 08:06:08PM

I love it when after a long and complicated and boring hint someone comes up with a "... or just use" solution that actually works perfectly. ;)

Thanks for Amua!



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: r0n on May 12, '06 12:31:18AM

Amua is dope!



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: clofresh on May 11, '06 05:06:17PM

A prize goes to whoever makes a Widget out of the proxy control page.



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: spegis on May 11, '06 08:13:26PM

I tried the hint, but it's giving me a paramater error. no more info than that. Any idea why?

What version of python should I be running, and how do I know if I have python on my mac at all? Is it a part of the base system install or the developer's tools?



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: mroutley on May 27, '06 11:01:42AM

Switching from the "stable" to the "alpha" release solved this problem for me.

Cheers,
Matt

---
--
Matthew Routley
Information Consultant
http://matt.routleynet.org



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: Daij-Djan on May 12, '06 02:43:40AM

anua IS cool but the hint doesnt want n alternate player it focuses on using iTunes, no?!



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: siMac on May 12, '06 08:35:34AM

Amua DOES play through iTunes... a little research before sarky comments?



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: Daij-Djan on May 13, '06 08:26:59AM

Just looked up sarky as I didnt understand it. Now I do but I dont know why I sounded sarky and definiatly didnt mean to.



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: alternapop on May 12, '06 08:22:39AM

Amua is nice but it doesn't tell iTunes what track is playing... only a generic "last.fm" tag.

If I use Quicksilver or SizzlingKeys to notify me of tracks then it doesn't work. Also, if I have iChat changing my status to the track I'm listening to, then that doesn't work either.

Give me that function alone and I'd use Amua. I realize I can have the Amua track window open separately but I'd like to be able to show and hide it with a quick key.



[ Reply to This | # ]
Play LastFM customized radio streams in iTunes
Authored by: flupirupi on Apr 24, '07 06:07:35AM
This hint is great. I don't like to use 5 different apps just to list to my music. iTunes all the way. However, I came up with this little script to skip the currently playing track

tell application "iTunes"
  try
    open location "http://localhost:1881/skip"
  on error
    open location "http://localhost:1881/lastfm.mp3"
  end try
end tell

I don't know why, but trying to play the "skip" part, throws an error. Any hints?
Now I only would like to retrieve the artwork from last.fm?

[ Reply to This | # ]