Skip to content

Instantly share code, notes, and snippets.

@withakay
Last active August 29, 2015 14:27
Show Gist options
  • Save withakay/fc66aea1ca21f9dd6349 to your computer and use it in GitHub Desktop.
Save withakay/fc66aea1ca21f9dd6349 to your computer and use it in GitHub Desktop.
Get your discography from beatport
#!/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