echonest / jEN

the java client for The Echo Nest API
67 stars 43 forks source link

Multiple Request #2

Open cvaught opened 11 years ago

cvaught commented 11 years ago

I have a dynamic playlist session where I need to get the next song and get the spotify ID for this song. Right now I do the following:

Playlist playlist = session.next(); //request 1 for (Song song : playlist.getSongs()) { Track track = song.getTrack("spotify-WW"); //request 2 String spotifyID = track.getForeignID(); // request 3 }

This results in 3 api calls. Is there anyway to get the spotify ID at the same time as getting the next song such that it is only 1 api call? If not, then shouldn't track.getForeignID() NOT result in a third request since the foreign id is included in the raw json response?

nahojkap commented 11 years ago

Having the same issue - you can get EchoNest to return the foreign ids in the 1st request by adding this to the create parameters:

p.add("bucket","id:spotify-WW"); p.add("bucket","tracks");

However, the returned data is not parsed correctly just now from the looks of it - still looking at what the exact issue is

nahojkap commented 11 years ago

Seems the getTrackNew will not make the request unessarily (if I understand things correctly) - if you also add the buckets above