-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathechonest.js
30 lines (29 loc) · 1.02 KB
/
echonest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
EchoNest = {
getBPM : function(track, callback) {
var artist = track.get("artist");
var title = track.get("track");
var id = track.get("id");
id = "spotify-WW:track:"+id;
var url = 'http://developer.echonest.com/api/v4/track/profile?api_key=N6E4NIOVYMTHNDM8J'+
'&id='+id+
'&bucket=audio_summary';
$.ajax( {
url:url,
success: function(data) {
if (data.response.status.code === 0) {
var bpm = data.response.track.audio_summary.tempo;
console.info(bpm);
callback(track,bpm);
}
else {
console.info("Unable to find "+artist+"-"+title);
callback(null);
}
},
error:function(data, text, error) {
console.error("Fail loading! "+text+": "+error);
}
}
);
}
}