/
main.go
39 lines (29 loc) · 885 Bytes
/
main.go
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
package fma;
import(
"strconv"
"encoding/json"
"github.com/bramvdbogaerde/fma/httputil"
)
func GetFeaturedTracks(page ...int) Tracks{
pageNumber := 1
if len(page) >= 1{
pageNumber = page[0]
}
options := map[string]string{};
options["page"] = strconv.Itoa(pageNumber);
return GetTracks(options)
}
func GetTracks(params map[string]string) Tracks{
parameters := buildParameters(params)
response := httputil.DoGet("http://freemusicarchive.org/api/get/tracks.json?"+parameters)
tracksDataSet := Tracks{}
json.Unmarshal([]byte(response), &tracksDataSet);
return tracksDataSet;
}
func GetGenres(params map[string] string) Genres{
parameters := buildParameters(params);
response := httputil.DoGet("http://freemusicarchive.org/api/get/genres.json?"+parameters)
genresDataSet := Genres{}
json.Unmarshal([]byte(response), &genresDataSet);
return genresDataSet;
}