-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
153 lines (116 loc) · 3.36 KB
/
app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//import { Album } from 'Album.js';
var SpotifyWebApi = require('node-spotify-api');
var spotifyApi = new SpotifyWebApi
({
id: '58d4a63fa4b4489697c224afd65b1569',
secret: '348e57ec20b4443cb3a7b295d94ad52f',
});
urlalbums = 'https://api.spotify.com/v1/artists/12Chz98pHFMPJEknJQMWvI/albums'
async function listamalbumes()
{
const data = await spotifyApi.request(urlalbums);
var array = [];
var x;
var idalbum;
var nombrealbum;
for (x of data.items) {
idalbum = x.id;
nombrealbum = x.name;
aobjectalbum = new Album(idalbum, nombrealbum);
array.push(aobjectalbum);
}
return array
}
var res = listamalbumes();
res.then(data => {
var y;
for (y of data)
{
console.log(y.nameal + " " + y.idal)
}
})
//var y;
//list = listalbums();
//console.log(list);
//for (y of list)
//{
//
//}
setTimeout(function () {
process.exit();
}, 100000);
class Album {
idal = 0;
nameal = " ";
constructor(ide, nombre) {
this.idal = ide;
this.nameal = nombre;
}
}
//function listamalbumes() {
// spotifyApi.request(url)
// .then(data => {
// return data;
// }).then(data => {
// var array = [];
// var x;
// var idalbum;
// var nombrealbum;
// for (x of data.items) {
// idalbum = x.id;
// nombrealbum = x.name;
// aobjectalbum = new Album(idalbum, nombrealbum);
// array.push(aobjectalbum);
// }
// return array;
// });
//}
//}
//list = listalbums();
//ide = x.id;
//nombre = x.nombre;
//var x;
//for (x of list) {
// console.log(x.name)
//}
//var resultado = spotifyApi.getArtistAlbums(idmuse, { limit: 20, offset: 0 });
//console.log(resultado.body);
//spotifyApi.getArtistAlbums(
// idmuse,
// limitofset,
// function (err, data) {
// albumes.push(data.body.items.length)
// console.log(data.body.items);
// });
//var Spotify = require('node-spotify-api');
// var spotify = new Spotify({
// id: "58d4a63fa4b4489697c224afd65b1569",
// secret: "348e57ec20b4443cb3a7b295d94ad52f"
//});
// array
// url = 'https://api.spotify.com/v1/artists/12Chz98pHFMPJEknJQMWvI/albums'
//spotify.request(url, function (response, body)
//{
//}
// (function (response,data) {
// arrray.push(data)
// })
//var request = require('request');
//url = 'https://api.spotify.com/v1/artists/12Chz98pHFMPJEknJQMWvI/albums'
//token ='BQDQBoY2fjEEtaeNP7ZGvI8v5KIhd6svToR6L26NKQ-l19G5-kHiIIq84iMt0EK_ntKrwVsJYSLRWQLa8gHbZRylVc14EOtQoQ7UageMqjXL-g7mp3y8vxhG1BznYSG1QJgaE9Mz7lzwUYL4opkZ3cq0omWOiUm-vTLJHJgyu9yLtuD2TxMTpuzvcYJ685sJCZZ-i9bVKPPoUCiHeKJVka-fROBaGbPxXJoAayg6zCPnK3NOgwYAXN2b44AqYBNuitNN_zf3coLthIqcJJwy4vFEH7rkFto1'
//var authOptions1 = {
// url: url,
// headers: {
// 'Authorization': 'Bearer ' + token,
// 'Content-Type': 'application/json',
// }
//};
//request.get(authOptions1, function (error, response, body) {
// console.log(body);
//});
// .then(function (data) {
// console.log(data);
// })
//.catch(function(err) {
// console.error('Error occurred: ' + err);
//});