net-flickr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/lib/net/flickr.rb +218 -0
- data/lib/net/flickr/auth.rb +139 -0
- data/lib/net/flickr/errors.rb +35 -0
- data/lib/net/flickr/list.rb +135 -0
- data/lib/net/flickr/people.rb +65 -0
- data/lib/net/flickr/person.rb +251 -0
- data/lib/net/flickr/photo.rb +335 -0
- data/lib/net/flickr/photolist.rb +53 -0
- data/lib/net/flickr/photos.rb +189 -0
- data/lib/net/flickr/tag.rb +55 -0
- metadata +77 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007-2008 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
module Net; class Flickr
|
30
|
+
|
31
|
+
# Paginated list of Flickr photos.
|
32
|
+
#
|
33
|
+
# Don't instantiate this class yourself. An instance will be returned when
|
34
|
+
# necessary by methods such as <tt>Flickr.photos.recent</tt>.
|
35
|
+
class PhotoList < List
|
36
|
+
|
37
|
+
#--
|
38
|
+
# Private Instance Methods
|
39
|
+
#++
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def update_list
|
44
|
+
super
|
45
|
+
|
46
|
+
@response.search('photo').each do |photo_xml|
|
47
|
+
@items << Photo.new(@flickr, photo_xml)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end; end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007-2008 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
module Net; class Flickr
|
30
|
+
|
31
|
+
# Provides methods for retrieving and/or manipulating one or more Flickr
|
32
|
+
# photos.
|
33
|
+
#
|
34
|
+
# Don't instantiate this class yourself. Instead, create an instance of the
|
35
|
+
# +Flickr+ class and then use <tt>Flickr.photos</tt> to access this class,
|
36
|
+
# like so:
|
37
|
+
#
|
38
|
+
# require 'net/flickr'
|
39
|
+
#
|
40
|
+
# flickr = Net::Flickr.new('524266cbd9d3c2xa2679fee8b337fip2')
|
41
|
+
#
|
42
|
+
# flickr.photos.recent.each do |photo|
|
43
|
+
# puts photo.title
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
class Photos
|
47
|
+
|
48
|
+
def initialize(flickr)
|
49
|
+
@flickr = flickr
|
50
|
+
end
|
51
|
+
|
52
|
+
# Gets a list of recent photos from the calling user's contacts. This method
|
53
|
+
# requires authentication with +read+ permission.
|
54
|
+
#
|
55
|
+
# See http://flickr.com/services/api/flickr.photos.getContactsPhotos.html
|
56
|
+
# for details.
|
57
|
+
def contacts(args = {})
|
58
|
+
response = @flickr.request('flickr.photos.getContactsPhotos', args)
|
59
|
+
|
60
|
+
photos = []
|
61
|
+
|
62
|
+
response.search('photos/photo').each do |photo_xml|
|
63
|
+
photos << Photo.new(@flickr, photo_xml)
|
64
|
+
end
|
65
|
+
|
66
|
+
return photos
|
67
|
+
end
|
68
|
+
|
69
|
+
# Gets a list of recent public photos from the specified user's contacts.
|
70
|
+
#
|
71
|
+
# See http://flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html
|
72
|
+
# for details.
|
73
|
+
def contacts_public(user_id, args = {})
|
74
|
+
args[:user_id] = user_id
|
75
|
+
|
76
|
+
response = @flickr.request('flickr.photos.getContactsPublicPhotos', args)
|
77
|
+
|
78
|
+
photos = []
|
79
|
+
|
80
|
+
response.search('photos/photo').each do |photo_xml|
|
81
|
+
photos << Photo.new(@flickr, photo_xml)
|
82
|
+
end
|
83
|
+
|
84
|
+
return photos
|
85
|
+
end
|
86
|
+
|
87
|
+
# Gets a list of photo counts for the given date ranges for the calling
|
88
|
+
# user. The list of photo counts is returned as an XML chunk. This method
|
89
|
+
# requires authentication with +read+ permission.
|
90
|
+
#
|
91
|
+
# See http://flickr.com/services/api/flickr.photos.getCounts.html for
|
92
|
+
# details.
|
93
|
+
def counts(args = {})
|
94
|
+
@flickr.request('flickr.photos.getCounts', args).at('photocounts').
|
95
|
+
to_original_html
|
96
|
+
end
|
97
|
+
|
98
|
+
# Deletes the specified photo from Flickr. This method requires
|
99
|
+
# authentication with +delete+ permission.
|
100
|
+
#
|
101
|
+
# See http://flickr.com/services/api/flickr.photos.delete.html for details.
|
102
|
+
def delete(photo_id)
|
103
|
+
@flickr.request('flickr.photos.delete', :photo_id => photo_id)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Gets a list of the calling user's geotagged photos. This method requires
|
107
|
+
# authentication with +read+ permission.
|
108
|
+
#
|
109
|
+
# See http://flickr.com/services/api/flickr.photos.getWithGeoData.html for
|
110
|
+
# details.
|
111
|
+
def geotagged(args = {})
|
112
|
+
PhotoList.new(@flickr, 'flickr.photos.getWithGeoData', args)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Gets a list of the calling user's photos that have not been geotagged.
|
116
|
+
# This method requires authentication with +read+ permission.
|
117
|
+
#
|
118
|
+
# See http://flickr.com/services/api/flickr.photos.getWithoutGeoData.html
|
119
|
+
# for details.
|
120
|
+
def not_geotagged(args = {})
|
121
|
+
PhotoList.new(@flickr, 'flickr.photos.getWithoutGeoData', args)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Gets a list of the calling user's photos that are not included in any
|
125
|
+
# sets. This method requires authentication with +read+ permission.
|
126
|
+
#
|
127
|
+
# See http://flickr.com/services/api/flickr.photos.getNotInSet.html for
|
128
|
+
# details.
|
129
|
+
def not_in_set(args = {})
|
130
|
+
PhotoList.new(@flickr, 'flickr.photos.getNotInSet', args)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Gets a list of the latest public photos uploaded to Flickr.
|
134
|
+
#
|
135
|
+
# See http://flickr.com/services/api/flickr.photos.getRecent.html for
|
136
|
+
# details.
|
137
|
+
def recent(args = {})
|
138
|
+
PhotoList.new(@flickr, 'flickr.photos.getRecent', args)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Gets a list of the calling user's photos that have been created or
|
142
|
+
# modified since the specified _min_date_. This method requires
|
143
|
+
# authentication with +read+ permission.
|
144
|
+
#
|
145
|
+
# _min_date_ may be either an instance of Time or an integer representing a
|
146
|
+
# Unix timestamp.
|
147
|
+
#
|
148
|
+
# See http://flickr.com/services/api/flickr.photos.recentlyUpdated.html for
|
149
|
+
# details.
|
150
|
+
def recently_updated(min_date, args = {})
|
151
|
+
args[:min_date] = min_date.to_i
|
152
|
+
PhotoList.new(@flickr, 'flickr.photos.recentlyUpdated', args)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Gets a list of photos matching the specified criteria. Only photos visible
|
156
|
+
# to the calling user will be returned. To return private or semi-private
|
157
|
+
# photos, the caller must be authenticated with +read+ permission and have
|
158
|
+
# permission to view the photos. Unauthenticated calls will return only
|
159
|
+
# public photos.
|
160
|
+
#
|
161
|
+
# See http://flickr.com/services/api/flickr.photos.search.html for details.
|
162
|
+
#
|
163
|
+
# Note: Flickr doesn't allow parameterless searches, so be sure to specify
|
164
|
+
# at least one search parameter.
|
165
|
+
def search(args = {})
|
166
|
+
PhotoList.new(@flickr, 'flickr.photos.search', args)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Gets a list of the calling user's photos that have no tags. This method
|
170
|
+
# requires authentication with +read+ permission.
|
171
|
+
#
|
172
|
+
# See http://flickr.com/services/api/flickr.photos.getUntagged.html for
|
173
|
+
# details.
|
174
|
+
def untagged(args = {})
|
175
|
+
PhotoList.new(@flickr, 'flickr.photos.getUntagged', args)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Gets a list of public photos for the specified _user_id_.
|
179
|
+
#
|
180
|
+
# See http://flickr.com/services/api/flickr.people.getPublicPhotos.html for
|
181
|
+
# details.
|
182
|
+
def user(user_id, args = {})
|
183
|
+
args[:user_id] = user_id
|
184
|
+
PhotoList.new(@flickr, 'flickr.people.getPublicPhotos', args)
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end; end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007-2008 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
module Net; class Flickr
|
30
|
+
|
31
|
+
# A Flickr photo tag.
|
32
|
+
#
|
33
|
+
# Don't instantiate this class yourself.
|
34
|
+
class Tag
|
35
|
+
|
36
|
+
attr_reader :id, :author, :raw, :name
|
37
|
+
|
38
|
+
def initialize(flickr, tag_xml)
|
39
|
+
@flickr = flickr
|
40
|
+
|
41
|
+
@id = tag_xml['id']
|
42
|
+
@author = tag_xml['author']
|
43
|
+
@raw = tag_xml['raw']
|
44
|
+
@name = tag_xml.inner_text
|
45
|
+
@machine_tag = tax_xml['machine_tag'] == '1'
|
46
|
+
end
|
47
|
+
|
48
|
+
# +true+ if this tag is a machine tag, +false+ otherwise.
|
49
|
+
def machine?
|
50
|
+
return @machine_tag
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end; end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: net-flickr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Grove
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-09 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hpricot
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0.5"
|
23
|
+
version:
|
24
|
+
description:
|
25
|
+
email: ryan@wonko.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- lib/net
|
34
|
+
- lib/net/flickr
|
35
|
+
- lib/net/flickr/auth.rb
|
36
|
+
- lib/net/flickr/errors.rb
|
37
|
+
- lib/net/flickr/list.rb
|
38
|
+
- lib/net/flickr/people.rb
|
39
|
+
- lib/net/flickr/person.rb
|
40
|
+
- lib/net/flickr/photo.rb
|
41
|
+
- lib/net/flickr/photolist.rb
|
42
|
+
- lib/net/flickr/photos.rb
|
43
|
+
- lib/net/flickr/tag.rb
|
44
|
+
- lib/net/flickr.rb
|
45
|
+
- LICENSE
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://code.google.com/p/net-flickr/
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --title
|
51
|
+
- Net::Flickr Documentation
|
52
|
+
- --main
|
53
|
+
- Net::Flickr
|
54
|
+
- --line-numbers
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.4
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: net-flickr
|
72
|
+
rubygems_version: 1.0.1
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: Flickr library for Ruby.
|
76
|
+
test_files: []
|
77
|
+
|