Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.