Last active
October 12, 2015 15:50
-
-
Save kasperkamperman/db55edc8ccfcd6696962 to your computer and use it in GitHub Desktop.
Get album cover data from Spotify
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
// https://developer.spotify.com/web-api/endpoint-reference/ | |
JSONObject json; | |
PImage [] albumCovers; | |
//Bubble[] bubbles; | |
void setup() { | |
size(640,480); | |
json = loadJSONObject("https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d/albums?market=NL&album_type=album&limit=50"); | |
JSONArray items = json.getJSONArray("items"); | |
printArray(items); | |
albumCovers = new PImage[items.size()]; | |
//bubbles = new Bubble[items.size()]; | |
for (int i = 0; i < items.size(); i++) | |
{ JSONObject item = items.getJSONObject(i); | |
//println(i); | |
JSONArray imageArray = item.getJSONArray("images"); | |
JSONObject cover = imageArray.getJSONObject(2); | |
println(cover); | |
String image = cover.getString("url"); | |
//println(); | |
albumCovers[i] = loadImage(image, "jpg"); | |
} | |
printArray(albumCovers); | |
for(int i = 0; i<albumCovers.length; i++) { | |
int x= (i%10)*64; | |
int y= (i/10)*64; | |
image(albumCovers[i], x,y,64,64); | |
} | |
} | |
void draw() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment