Created
June 10, 2010 12:17
-
-
Save tliff/432905 to your computer and use it in GitHub Desktop.
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 | |
# Make sure to chmod +x this | |
# Usage: lono.rb <ID> | |
require 'digest/sha2' | |
require 'net/http' | |
require 'rexml/document' | |
if ARGV.count != 1 | |
puts "Please pass an id" | |
exit | |
end | |
id = ARGV[0].to_i | |
secret = Digest::SHA2.hexdigest(id.to_s+'-066e88728cb1a38c046481ad0f5e1ae2') | |
response = Net::HTTP.get_response(URI.parse("http://lono.me/secret/#{secret}")).body | |
doc = REXML::Document.new(response) | |
response = Net::HTTP.get_response(URI.parse("http://musicbrainz.org/ws/1/track/#{doc.root.elements["mbid"].text}?type=xml&inc=artist")).body | |
doc = REXML::Document.new(response) | |
puts "#{doc.root.elements['track/artist/name'].text} - #{doc.root.elements["track/title"].text}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment