Skip to content

Instantly share code, notes, and snippets.

@pipwilson
Forked from infovore/wotlisten.rb
Created March 6, 2009 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pipwilson/74899 to your computer and use it in GitHub Desktop.
Save pipwilson/74899 to your computer and use it in GitHub Desktop.
a port of wotlisten to use the RSS feed rather than screen-scrape
#!/usr/bin/env ruby -KU
# ported to use the RSS feed rather than screen-scrape
require 'rubygems'
require 'open-uri'
require 'rexml/document'
require 'rexml/xpath'
if ARGV[0]
user = ARGV[0]
url = "http://ws.audioscrobbler.com/1.0/user/#{user}/recenttracks.rss"
doc = REXML::Document.new(open(url))
track = REXML::XPath.first(doc, "/rss/channel/item/title").text
puts track
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