-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.js
More file actions
53 lines (41 loc) · 1.15 KB
/
fetch.js
File metadata and controls
53 lines (41 loc) · 1.15 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var spotifyAPI = require('spotify-web-api-node');
var settings = {
clientId : "cab4b5b99f96426e9dfaf76d268f3871",
clientSecret: "3000734987d6434a963489d900c65641",
redirectUri : "http%3A%2F%2F129.31.222.56%3A8080%2Fauth"
}
spot = new spotifyAPI({
clientId : settings.clientId,
clientSecret : settings.clientSecret,
redirectUri : settings.redirectUri
});
//tokens array
var tokens = [];
//sets the list of current users connected tokens
exports.setTokens = function(tokenArray){
tokens = tokenArray;
}
exports.setSpot = function(spotify){
spot = spotify;
}
//function to print tokens
exports.printTokens = function(){
console.log(tokens);
}
//get the data to pass to the algorithm
exports.fetch = function(num_of_tracks = 10, num_of_artists = 10){
var ids = [];
var tts = [];
var TAs = [];
for(i = 0; i < tokens.length; i++){
spot.setAccessToken(tokens[i].token);
spot.getUser(tokens[i].userId).then(function(data){
console.log("here");
console.log(data.body);
});
spot.getMyTopTracks({limit: num_of_tracks}).then(function(tt_data){
// console.log(tt_data.body);
});
}
// console.log(IDs[1]);
}