We use last.fm a lot in the office - but one thing I always found annoying was that there’s no easy way to find out what’s currently playing (you need to go to the web page and hit refresh, very distracting) so I knocked up a little ruby script which uses growl to display the currently playing song.
#!/usr/bin/env ruby
require ‘rubygems’
require ‘ruby-growl’
require ‘hpricot’
require ‘cgi’
require ‘open-uri’
raise “#{$0} <user>” if ARGV.empty?
user = ARGV[0]
already_notified = []
while true do
now_listening = Hpricot(open(“http://www.last.fm/user/#{user}”))/“.nowListening td.subject”
unless now_listening.empty?
currently_played = now_listening.last.inner_text.strip
unless already_notified.include?(currently_played)
already_notified << currently_played
g = Growl.new(“localhost”, “ruby-growl”, ["ruby-growl Notification"])
g.notify(“ruby-growl Notification”, “#{user} is listening to”,
CGI::unescapeHTML(currently_played))
end
end
sleep 60
end
Make sure that you have hpricot and ruby-growl installed (gem install hpricot ruby-growl -y), then copy and paste the script (or download it) and start it with a last.fm username as parameter. You also need to have “Listen for incoming notifications” and “Allow remote registration” checked in growl’s preferences (System Preferences | Growl | Network).

September 29th, 2007 at 7:41 pm
i just downloaded the newest version of last.fm and looked in the preferences, and have no idea what Growl is?? help?
September 29th, 2007 at 7:42 pm
Or you could go to Last.fm preferences -> growl -> send notification to growl when a new track starts
September 29th, 2007 at 7:43 pm
right, but i want to get notification for songs someone else is playing
September 29th, 2007 at 7:44 pm
ah, right. office with shared music setup. didn’t think of that — great idea!
July 24th, 2008 at 2:24 pm
To get this to work with the new layout of last.fm, change the following line:
now_listening = Hpricot(open(“http://www.last.fm/user/#{user}”))/“.nowListening td.subject”
to:
now_listening = Hpricot(open(“http://www.last.fm/user/#{user}”))/“td.featuredTrack”