This repository has been archived by the owner on Jan 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
atom.go
100 lines (89 loc) · 2.92 KB
/
atom.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
// Copyright 2014 Tamás Gulácsi. All rights reserved.
// Use of this source code is governed by an Apache 2.0
// license that can be found in the LICENSE file.
package picago
import (
"encoding/xml"
"io"
"time"
)
type Atom struct {
ID string `xml:"id"`
Name string `xml:"name"`
Updated time.Time `xml:"updated"`
Title string `xml:"title"`
Subtitle string `xml:"subtitle"`
Icon string `xml:"icon"`
Thumbnail string `xml:"http://schemas.google.com/photos/2007 thumbnail"`
Author Author `xml:"author"`
NumPhotos int `xml:"numphotos"`
StartIndex int `xml:"startIndex"`
TotalResults int `xml:"totalResults"`
ItemsPerPage int `xml:"itemsPerPage"`
Entries []Entry `xml:"entry"`
}
type Entry struct {
ETag string `xml:"etag,attr"`
EntryID string `xml:"http://www.w3.org/2005/Atom id"`
ID string `xml:"http://schemas.google.com/photos/2007 id"`
Published time.Time `xml:"published"`
Updated time.Time `xml:"updated"`
Name string `xml:"http://schemas.google.com/photos/2007 name"`
Title string `xml:"title"`
Summary string `xml:"summary"`
Rights string `xml:"rights"`
AlbumType string `xml:"albumType"`
Links []Link `xml:"link"`
Author Author `xml:"author"`
Location string `xml:"http://schemas.google.com/photos/2007 location"`
NumPhotos int `xml:"numphotos"`
Content EntryContent `xml:"content"`
Media *Media `xml:"group"`
Exif *Exif `xml:"tags"`
Point string `xml:"where>Point>pos"`
}
type Exif struct {
FStop float32 `xml:"fstop"`
Make string `xml:"make"`
Model string `xml:"model"`
Exposure float32 `xml:"exposure"`
Flash bool `xml:"flash"`
FocalLength float32 `xml:"focallength"`
ISO int32 `xml:"iso"`
Timestamp int64 `xml:"time"`
UID string `xml:"imageUniqueID"`
}
type Link struct {
Rel string `xml:"rel,attr"`
Type string `xml:"type,attr"`
URL string `xml:"href,attr"`
}
type Media struct {
Title string `xml:"http://search.yahoo.com/mrss title"`
Description string `xml:"description"`
Keywords string `xml:"keywords"`
Content []MediaContent `xml:"content"`
Thumbnail []MediaContent `xml:"thumbnail"`
}
type MediaContent struct {
URL string `xml:"url,attr"`
Type string `xml:"type,attr"`
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
Medium string `xml:"medium,attr"` // "image" or "video" for Picasa at least
}
type EntryContent struct {
URL string `xml:"src,attr"`
Type string `xml:"type,attr"`
}
type Author struct {
Name string `xml:"name"`
URI string `xml:"uri"`
}
func ParseAtom(r io.Reader) (*Atom, error) {
result := new(Atom)
if err := xml.NewDecoder(r).Decode(result); err != nil {
return nil, err
}
return result, nil
}