-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathme.go
45 lines (41 loc) · 829 Bytes
/
me.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
package spotifyweb
import (
"fmt"
)
//Me is the current logged in user's basic info.
type Me struct {
DisplayName string `json:"display_name"`
Country,
Email,
Href,
Id,
Product,
Type,
Uri string
ExternalUrls map[string]string
Images []Image
Playlists PlaylistPagingObject `json:"-"`
Api SpotifyWeb `json:"-"`
}
func (api SpotifyWeb) Me() (Me, error) {
var me Me
err := api.DoAuth("me", "GET", &me)
me.Api = api
me.GetPlayLists()
return me, err
}
func (me *Me) GetPlayLists() {
err := me.Api.DoAuth("users/"+me.Id+"/playlists", "GET", &me.Playlists)
if err != nil {
fmt.Println(err)
}
var items []PlaylistSimple
for _, pl := range me.Playlists.Items {
pl.Api = me.Api
items = append(items, pl)
if err != nil {
fmt.Println(err)
}
}
me.Playlists.Items = items
}