Created
April 21, 2013 20:03
-
-
Save b-murphy/5430883 to your computer and use it in GitHub Desktop.
for lewis.
This file contains hidden or 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
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