-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaapje.go
More file actions
87 lines (75 loc) · 2.31 KB
/
aapje.go
File metadata and controls
87 lines (75 loc) · 2.31 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
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
package main
import (
"net/http"
"io/ioutil"
"encoding/json"
"bytes"
)
// https://github.com/ChimeraCoder/gojson
// curl -s http://radiobox2.omroep.nl/data/radiobox2/nowonair/2.json\?npo_cc_skip_wall\=1 | gojson -name=OnAir
const (
aapjeURL string = "http://radiobox2.omroep.nl/data/radiobox2/nowonair/2.json?npo_cc_skip_wall=1"
)
type OnAir struct {
Results []struct {
Channel int64 `json:"channel"`
Date string `json:"date"`
ID int64 `json:"id"`
Songfile struct {
References struct {
Channel string `json:"channel"`
} `json:"_references"`
ReferencesSsl struct {
Channel string `json:"channel"`
} `json:"_references_ssl"`
Artist string `json:"artist"`
BumaID string `json:"buma_id"`
DaletID string `json:"dalet_id"`
Hidden int64 `json:"hidden"`
ID int64 `json:"id"`
LastUpdated string `json:"last_updated"`
Rb1id int64 `json:"rb1id"`
SongID int64 `json:"song_id"`
Songversion struct {
ID int64 `json:"id"`
Image []struct {
AllowedToUse int64 `json:"allowed_to_use"`
Created string `json:"created"`
Deleted int64 `json:"deleted"`
Filename string `json:"filename"`
Hash string `json:"hash"`
ID int64 `json:"id"`
Name string `json:"name"`
OriginalHeight int64 `json:"original_height"`
OriginalWidth int64 `json:"original_width"`
Replaced int64 `json:"replaced"`
Source string `json:"source"`
Updated string `json:"updated"`
URL string `json:"url"`
URLSsl string `json:"url_ssl"`
} `json:"image"`
} `json:"songversion"`
Title string `json:"title"`
} `json:"songfile"`
Startdatetime string `json:"startdatetime"`
Stopdatetime string `json:"stopdatetime"`
} `json:"results"`
}
func getAapjeData() (OnAir, error) {
req, err := http.Get(aapjeURL)
/*if err != nil {
return nil, err
}*/
body, err := ioutil.ReadAll(req.Body)
/*if err != nil {
return nil, err
}*/
var dat OnAir
err = json.Unmarshal(body, &dat)
return dat, err
}
func getCurrentTrack(air OnAir) string {
var buffer bytes.Buffer
buffer.WriteString("Nu op Top2000: " + air.Results[0].Songfile.Title + " - " + air.Results[0].Songfile.Artist)
return buffer.String()
}