-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.js
40 lines (36 loc) · 877 Bytes
/
get.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
var request = require("request");
const _=require('underscore');
const env = require('dotenv').config();
var options = { method: 'GET',
url: 'https://api.setlist.fm/rest/1.0/search/setlists',
qs:
{ artistName: 'Eddie Vedder',
cityName: 'Amsterdam',
year: '2017',
countryCode: 'NL',
},
headers:
{ Accept: 'application/json',
'x-api-key': process.env.apikey } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
var obj = JSON.parse(body);
var res=_(obj.setlist).chain().
pluck('sets').
flatten().
pluck('set').
flatten().
pluck('song').
flatten().
countBy('name').
map(function(count,name){
return{
title: name,
count: count
}
}).
sortBy('count').
value();
console.dir(res.reverse());
console.dir(res.length+" unique songs in the setlists");
});