-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathphoto.go
97 lines (86 loc) · 2.67 KB
/
photo.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
// Copyright 2011 Muthukannan T <manki@manki.in>. All Rights Reserved.
package flickgo
import (
"fmt"
)
// Image sizes supported by Flickr. See
// http://www.flickr.com/services/api/misc.urls.html for more information.
const (
SizeSmallSquare = "s"
SizeThumbnail = "t"
SizeSmall = "m"
SizeMedium500 = "-"
SizeMedium640 = "z"
SizeLarge = "b"
SizeOriginal = "o"
)
// Response for photo search requests.
type SearchResponse struct {
Page string `xml:"page,attr"`
Pages string `xml:"pages,attr"`
PerPage string `xml:"perpage,attr"`
Total string `xml:"total,attr"`
Photos []Photo `xml:"photo"`
}
// A Flickr user.
type User struct {
UserName string `xml:"username,attr"`
NSID string `xml:"nsid,attr"`
}
// Represents a Flickr photo.
type Photo struct {
ID string `xml:"id,attr"`
Owner string `xml:"owner,attr"`
Secret string `xml:"secret,attr"`
Server string `xml:"server,attr"`
Farm string `xml:"farm,attr"`
Title string `xml:"title,attr"`
IsPublic string `xml:"ispublic,attr"`
WidthT string `xml:"width_t,attr"`
HeightT string `xml:"height_t,attr"`
// Photo's aspect ratio: width divided by height.
Ratio float64
}
// Returns the URL to this photo in the specified size.
func (p *Photo) URL(size string) string {
if size == "-" {
return fmt.Sprintf("http://farm%s.static.flickr.com/%s/%s_%s.jpg",
p.Farm, p.Server, p.ID, p.Secret)
}
return fmt.Sprintf("http://farm%s.static.flickr.com/%s/%s_%s_%s.jpg",
p.Farm, p.Server, p.ID, p.Secret, size)
}
type PhotoSet struct {
ID string `xml:"id,attr"`
Title string `xml:"title"`
Description string `xml:"description"`
}
type LocationResponse struct {
Photo string `xml:"id,attr"`
Location Location `xml:"location"`
}
type Location struct {
Latitude string `xml:"latitude,attr"`
Longitude string `xml:"longitude,attr"`
Accuracy string `xml:"accuracy,attr"`
Context string `xml:"context,attr"`
PlaceID string `xml:"place_id,attr"`
WOEID string `xml:"woeid,attr"`
}
type PersonResponse struct {
ID string `xml:"id,attr"`
NSID string `xml:"nsid,attr"`
IsPro string `xml:"ispro,attr"`
IconServer string `xml:"iconserver,attr"`
IconFarm string `xml:"iconfarm,attr"`
PathAlias string `xml:"path_alias,attr"`
Gender string `xml:"gender,attr"`
Ignored string `xml:"ignored,attr"`
Contact string `xml:"contact,attr"`
Friend string `xml:"friend,attr"`
Family string `xml:"family,attr"`
ReverseContact string `xml:"revcontact,attr"`
ReverseFriend string `xml:"revfriend,attr"`
ReverseFamily string `xml:"revfamily,attr"`
UserName string `xml:"username"`
}