Skip to content

Instantly share code, notes, and snippets.

@b-murphy
Created April 21, 2013 20:03
Show Gist options
  • Save b-murphy/5430883 to your computer and use it in GitHub Desktop.
Save b-murphy/5430883 to your computer and use it in GitHub Desktop.
for lewis.
require 'rest_client'
require 'json'
class Artwork
def fetch(query)
api_key = '82a7531b6438492cd9e967442e5b12c8'
album = RestClient.get("http://ws.audioscrobbler.com/2.0/?method=album.search&album=#{query}&api_key=#{api_key}&format=json")
album = JSON.parse(album)
results = album.fetch('results').fetch('albummatches').fetch('album')[0].fetch('image').last.fetch('#text')
print results.to_s + "\n"
end
end
art = Artwork.new
art.fetch('britney')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment