-
Notifications
You must be signed in to change notification settings - Fork 0
/
JamendoQueue.js
35 lines (29 loc) · 954 Bytes
/
JamendoQueue.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
const axios = require('axios');
const Queue = require('./Queue');
const RemoteAudio = require('./RemoteAudio');
class JamendoQueue extends Queue {
constructor(limit, fuzzytags) {
super();
const fuzzytagsStr = fuzzytags.join('+');
this.urlReq = `https://api.jamendo.com/v3.0/tracks/?client_id=2b8dda4b&limit=${limit}&fuzzytags=${fuzzytagsStr}&boost=popularity_week`;
}
getUrlReq() {
return this.urlReq;
}
async pull() {
const res = await axios.get(this.urlReq);
const { data } = res;
data.results.forEach((song) => {
const remoteAudio = new RemoteAudio(
song.artist_name,
song.name,
song.audio,
song.album_image,
song.shareurl,
song.duration * 1000
);
this.enqueue(remoteAudio);
});
}
}
module.exports = JamendoQueue;