-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.go
59 lines (49 loc) · 855 Bytes
/
image.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
package epgdata
import (
"encoding/json"
)
type Images struct {
Size130 *Image
Size320 *Image
Size476 *Image
Size952 *Image
}
type Image struct {
Source string
Width string
Height string
}
func (i *Images) UnmarshalJSON(data []byte) error {
var aux []struct {
Size1 string `json:"size1"`
Size2 string `json:"size2"`
Size3 string `json:"size3"`
Size4 string `json:"size4"`
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if len(aux) > 0 {
i.Size130 = &Image{
Source: aux[0].Size1,
Width: "130",
Height: "101",
}
i.Size320 = &Image{
Source: aux[0].Size2,
Width: "320",
Height: "250",
}
i.Size476 = &Image{
Source: aux[0].Size3,
Width: "476",
Height: "357",
}
i.Size952 = &Image{
Source: aux[0].Size4,
Width: "952",
Height: "714",
}
}
return nil
}