-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
85 lines (69 loc) · 1.62 KB
/
structs.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package coverartarchive
import "encoding/json"
type Thumbnails struct {
Large string `json:"large"`
Small string `json:"small"`
}
type Image struct {
ID json.Number `json:"id,Number"`
URL string `json:"image"`
Edit int `json:"edit"`
Approved bool `json:"approved"`
Back bool `json:"back"`
Front bool `json:"front"`
Comment string `json:"comment"`
Thumbnails Thumbnails `json:"thumbnails"`
Types []string `json:"types"`
}
type CoverArtResponse struct {
Images []*Image `json:"images"`
Release string `json:"release"`
}
func (c *CoverArtResponse) Front() *Image {
for _, image := range c.Images {
if image.Front && !image.Back {
return image
}
}
return nil
}
func (c *CoverArtResponse) FrontSmallThumbnailURL() string {
for _, image := range c.Images {
if image.Front && !image.Back {
return image.Thumbnails.Small
}
}
return ""
}
func (c *CoverArtResponse) FrontLargeThumbnailURL() string {
for _, image := range c.Images {
if image.Front && !image.Back {
return image.Thumbnails.Large
}
}
return ""
}
func (c *CoverArtResponse) Back() *Image {
for _, image := range c.Images {
if image.Back && !image.Front {
return image
}
}
return nil
}
func (c *CoverArtResponse) BackSmallThumbnailURL() string {
for _, image := range c.Images {
if image.Back && !image.Front {
return image.Thumbnails.Small
}
}
return ""
}
func (c *CoverArtResponse) BackLargeThumbnailURL() string {
for _, image := range c.Images {
if image.Back && !image.Front {
return image.Thumbnails.Large
}
}
return ""
}