-
Notifications
You must be signed in to change notification settings - Fork 15
/
json_structs.go
135 lines (119 loc) · 3.04 KB
/
json_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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package smugmug
import (
"bytes"
"errors"
"text/template"
"time"
)
type currentUser struct {
Response struct {
User struct {
NickName string `json:"NickName"`
}
}
}
type user struct {
Response struct {
User struct {
Uris struct {
UserAlbums struct {
URI string `json:"Uri"`
} `json:"UserAlbums"`
} `json:"Uris"`
} `json:"User"`
} `json:"Response"`
}
type albumsResponse struct {
Response struct {
URI string `json:"Uri"`
Album []album `json:"Album"`
Pages struct {
NextPage string `json:"NextPage"`
} `json:"Pages"`
} `json:"Response"`
}
type album struct {
URLPath string `json:"UrlPath"`
Uris struct {
AlbumImages struct {
URI string `json:"Uri"`
} `json:"AlbumImages"`
} `json:"Uris"`
}
type albumImagesResponse struct {
Response struct {
URI string `json:"Uri"`
AlbumImage []albumImage `json:"AlbumImage"`
Pages struct {
NextPage string `json:"NextPage"`
} `json:"Pages"`
} `json:"Response"`
}
type imageMetadataResponse struct {
Response struct {
DateTimeCreated time.Time `json:"DateTimeCreated"`
DateTimeModified time.Time `json:"DateTimeModified"`
} `json:"Response"`
}
type albumImage struct {
AlbumPath string // From album.URLPath
FileName string `json:"FileName"`
ImageKey string `json:"ImageKey"` // Use as unique ID if FileName is empty
ArchivedMD5 string `json:"ArchivedMD5"`
ArchivedSize int64 `json:"ArchivedSize"`
ArchivedUri string `json:"ArchivedUri"`
IsVideo bool `json:"IsVideo"`
Processing bool `json:"Processing"`
UploadKey string `json:"UploadKey"`
DateTimeOriginal string `json:"DateTimeOriginal"`
Caption string `json:"Caption"`
DateTimeUploaded string `json:"DateTimeUploaded"`
Keywords string `json:"Keywords"`
Latitude string `json:"Latitude"`
Longitude string `json:"Longitude"`
Status string `json:"Status"`
SubStatus string `json:"SubStatus"`
Uris struct {
ImageMetadata struct {
Uri string `json:"Uri"`
} `json:"ImageMetadata"`
LargestVideo struct {
Uri string `json:"Uri"`
} `json:"LargestVideo"`
} `json:"Uris"`
builtFilename string // The final filename, after template replacements
}
func (a *albumImage) buildFilename(tmpl *template.Template) error {
replacementVars := map[string]string{
"FileName": a.FileName,
"ImageKey": a.ImageKey,
"ArchivedMD5": a.ArchivedMD5,
"UploadKey": a.UploadKey,
}
var builtFilename bytes.Buffer
if err := tmpl.Execute(&builtFilename, replacementVars); err != nil {
return err
}
a.builtFilename = builtFilename.String()
if a.builtFilename == "" {
return errors.New("empty resulting name")
}
return nil
}
func (a *albumImage) Name() string {
if a.builtFilename != "" {
return a.builtFilename
}
if a.FileName != "" {
return a.FileName
}
return a.ImageKey
}
type albumVideo struct {
Response struct {
LargestVideo struct {
Size int64 `json:"Size"`
Url string `json:"Url"`
} `json:"LargestVideo"`
} `json:"Response"`
}