Monday, March 19, 2007
New Last.fm Tagger for RubyOSA
Laurent Sansonetti was generous enough to ask me if I wanted to contribute my little Last.fm script to the RubyOSA samples directory. And of course, I was more than willing to do that. He actually updated the script to make it even better! Now, you simply select which track in iTunes you want to tag, and run the RubyOSA script. The script will then query Last.fm for the most popular tag, and set the genre to whatever the tag on Last.fm is.
Here's the updated code:
Remember, you can get RubyOSA with the Last.fm Tagger here.
Thanks to Laurent for making an awesome library. It makes playing with Ruby even more fun!
Here's the updated code:
begin require 'rubygems'; rescue LoadError; end
require 'rbosa'
require 'net/http'
require 'cgi'
require 'rexml/document'
include REXML
itunes = OSA.app('iTunes')
selection = itunes.selection.get
if selection.empty?
$stderr.puts "Please select some tracks."
exit 1
end
selection.each do |track|
feed = "http://ws.audioscrobbler.com/1.0/album/#{CGI::escape(track.album)}/toptags.xml"
doc = Document.new(Net::HTTP.get(URI(feed)))
track.genre = doc.root[1][1].text
end
Remember, you can get RubyOSA with the Last.fm Tagger here.
Thanks to Laurent for making an awesome library. It makes playing with Ruby even more fun!
Labels: last.fm, lastfmtagger, osx, programming, ruby, software
Subscribe to Posts [Atom]
