-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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