forked from shkh/lastfm-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lastfm.go
69 lines (61 loc) · 1.53 KB
/
lastfm.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
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
package lastfm
const (
UriApiSecBase = "https://ws.audioscrobbler.com/2.0/"
UriApiBase = "http://ws.audioscrobbler.com/2.0/"
UriBrowserBase = "https://www.last.fm/api/auth/"
)
type P map[string]interface{}
type Api struct {
params *apiParams
Album *albumApi
Artist *artistApi
Chart *chartApi
Event *eventApi
Geo *geoApi
Group *groupApi
Library *libraryApi
Playlist *playlistApi
Radio *radioApi
Tag *tagApi
Tasteometer *tasteometerApi
Track *trackApi
User *userApi
Venue *venueApi
}
type apiParams struct {
apikey string
secret string
sk string
useragent string
}
func New(key, secret string) (api *Api) {
params := apiParams{key, secret, "", ""}
api = &Api{
params: ¶ms,
Album: &albumApi{¶ms},
Artist: &artistApi{¶ms},
Chart: &chartApi{¶ms},
Event: &eventApi{¶ms},
Geo: &geoApi{¶ms},
Group: &groupApi{¶ms},
Library: &libraryApi{¶ms},
Playlist: &playlistApi{¶ms},
Radio: &radioApi{¶ms},
Tag: &tagApi{¶ms},
Tasteometer: &tasteometerApi{¶ms},
Track: &trackApi{¶ms},
User: &userApi{¶ms},
Venue: &venueApi{¶ms},
}
return
}
func (api *Api) SetSession(sessionkey string) {
api.params.sk = sessionkey
}
func (api Api) GetSessionKey() (sk string) {
sk = api.params.sk
return
}
func (api *Api) SetUserAgent(useragent string) {
api.params.useragent = useragent
}