Skip to content

Instantly share code, notes, and snippets.

@infovore
Created February 20, 2009 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save infovore/67677 to your computer and use it in GitHub Desktop.
Save infovore/67677 to your computer and use it in GitHub Desktop.
tells you what a username is listening to right now on last.fm. Probably not of use to you.
#!/usr/bin/env ruby -KU
require 'rubygems'
require 'open-uri'
require 'hpricot'
if ARGV[0]
user = ARGV[0]
url = "http://www.last.fm/user/#{user}"
doc = Hpricot(open(url))
track = doc.search("table#recentTracks tbody tr:first td.subjectCell").inner_text.gsub("full track", "").strip
puts "#{user} is listening to #{track}"
else
puts "Wotlisten tells you what a last.fm short username is listening to (or most recently listened to)"
puts "Usage: wotlisten.rb username"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment