Last active
August 29, 2015 14:27
-
-
Save withakay/fc66aea1ca21f9dd6349 to your computer and use it in GitHub Desktop.
Get your discography from beatport
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 | |
require "rubygems" | |
require "json" | |
require "net/http" | |
require "uri" | |
artist = "TR20" | |
uri = URI.parse("http://www.federicogiust.com/beatportapi/beatport_api.php?facets=performerName:#{artist}&sortBy=publishDate%20desc&perPage=150&url=releases") | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Get.new(uri.request_uri) | |
response = http.request(request) | |
if response.code == "200" | |
data_hash = JSON.parse(response.body) | |
results = data_hash["results"] | |
results.each { |r| | |
if r["category"] == "Release" then | |
puts r["name"] + " - " + r["label"]["name"] + " - " + r["releaseDate"] | |
end | |
} | |
else | |
puts "Error " + response.code + " fetching data" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment