flickrie 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -3
- data/lib/flickrie/api_methods.rb +10 -737
- data/lib/flickrie/api_methods/media.rb +698 -0
- data/lib/flickrie/api_methods/set.rb +23 -0
- data/lib/flickrie/api_methods/user.rb +45 -0
- data/lib/flickrie/client.rb +16 -0
- data/lib/flickrie/media.rb +10 -10
- data/lib/flickrie/media/class_methods.rb +46 -1
- data/lib/flickrie/photo.rb +2 -33
- data/lib/flickrie/version.rb +1 -1
- data/lib/flickrie/video.rb +2 -21
- metadata +23 -20
data/README.md
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
This gem is a nice wrapper for the Flickr API with an object-oriented interface.
|
4
4
|
|
5
|
+
- Homepage: [http://janko-m.github.com/flickrie/](http://janko-m.github.com/flickrie/)
|
6
|
+
|
5
7
|
- GitHub page: [https://github.com/janko-m/flickrie](https://github.com/janko-m/flickrie)
|
6
8
|
|
7
|
-
- Documentation: [http://rubydoc.info/
|
9
|
+
- Documentation: [http://rubydoc.info/github/janko-m/flickrie](http://rubydoc.info/github/janko-m/flickrie/)
|
8
10
|
|
9
11
|
- Wiki: [https://github.com/janko-m/flickrie/wiki](https://github.com/janko-m/flickrie/wiki)
|
10
12
|
|
@@ -25,7 +27,7 @@ just some of the reason I decided to make this gem.
|
|
25
27
|
The method names here aren't called the same as Flickr's API methods
|
26
28
|
(and they can't be), but they follow a pattern which
|
27
29
|
shouldn't be too difficult to predict. Take a look at the ["Currently covered API
|
28
|
-
methods"](
|
30
|
+
methods"](#currently-covered-api-methods) section of this readme.
|
29
31
|
|
30
32
|
Also, some attribute names that you get from the response are changed.
|
31
33
|
So, for example, the `last_update` attribute is called `updated_at`,
|
@@ -53,7 +55,7 @@ You first need to install the gem.
|
|
53
55
|
Then, if you're using Bundler in your project, put it into your `Gemfile`:
|
54
56
|
|
55
57
|
```ruby
|
56
|
-
gem "flickrie", "~> 1.
|
58
|
+
gem "flickrie", "~> 1.4"
|
57
59
|
```
|
58
60
|
|
59
61
|
Then in your app you set the API key and shared secret (if you don't have them
|
@@ -288,6 +290,7 @@ basis of this gem.
|
|
288
290
|
|
289
291
|
# photos.licenses
|
290
292
|
"flickr.photos.licenses.getInfo" -> Flickrie.get_licenses
|
293
|
+
"flickr.photos.licenses.setLicense" -> Flickrie.set_photo_license
|
291
294
|
|
292
295
|
# photos.upload
|
293
296
|
"flickr.photos.upload.checkTickets" -> Flickrie.check_upload_tickets
|
data/lib/flickrie/api_methods.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'flickrie/api_methods/media'
|
2
|
+
require 'flickrie/api_methods/user'
|
3
|
+
require 'flickrie/api_methods/set'
|
4
|
+
|
1
5
|
module Flickrie
|
2
6
|
module ApiMethods
|
3
7
|
# For uploading photos and videos to Flickr. Example:
|
@@ -46,697 +50,6 @@ module Flickrie
|
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
# Fetches the Flickr user with the given email.
|
50
|
-
#
|
51
|
-
# @param email [String]
|
52
|
-
# @return [Flickrie::User]
|
53
|
-
# @api_method [flickr.people.findByEmail](http://www.flickr.com/services/api/flickr.people.findByEmail.html)
|
54
|
-
def find_user_by_email(email, params = {})
|
55
|
-
response = client.find_user_by_email(email, params)
|
56
|
-
User.from_find(response.body['user'])
|
57
|
-
end
|
58
|
-
|
59
|
-
# Fetches the Flickr user with the given username.
|
60
|
-
#
|
61
|
-
# @param username [String]
|
62
|
-
# @return [Flickrie::User]
|
63
|
-
# @api_method [flickr.people.findByUsername](http://www.flickr.com/services/api/flickr.people.findByUsername.html)
|
64
|
-
def find_user_by_username(username, params = {})
|
65
|
-
response = client.find_user_by_username(username, params)
|
66
|
-
User.from_find(response.body['user'])
|
67
|
-
end
|
68
|
-
|
69
|
-
# Fetches the Flickr user with the given NSID.
|
70
|
-
#
|
71
|
-
# @param nsid [String]
|
72
|
-
# @return [Flickrie::User]
|
73
|
-
# @api_method [flickr.people.getInfo](http://www.flickr.com/services/api/flickr.people.getInfo.html)
|
74
|
-
def get_user_info(nsid, params = {})
|
75
|
-
response = client.get_user_info(nsid, params)
|
76
|
-
User.from_info(response.body['person'])
|
77
|
-
end
|
78
|
-
|
79
|
-
# Fetches photos and videos from the Flickr user with the given NSID.
|
80
|
-
#
|
81
|
-
# @param nsid [String]
|
82
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
83
|
-
# @api_method [flickr.people.getPhotos](http://www.flickr.com/services/api/flickr.people.getPhotos.html)
|
84
|
-
#
|
85
|
-
# @note This method requires authentication with "read" permissions.
|
86
|
-
def media_from_user(nsid, params = {})
|
87
|
-
response = client.media_from_user(nsid, params)
|
88
|
-
Media.from_user(response.body['photos'])
|
89
|
-
end
|
90
|
-
# Fetches photos from the Flickr user with the given NSID.
|
91
|
-
#
|
92
|
-
# @param nsid [String]
|
93
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
94
|
-
# @api_method [flickr.people.getPhotos](http://www.flickr.com/services/api/flickr.people.getPhotos.html)
|
95
|
-
#
|
96
|
-
# @note This method requires authentication with "read" permissions.
|
97
|
-
def photos_from_user(nsid, params = {})
|
98
|
-
media_from_user(nsid, params).select { |media| media.is_a?(Photo) }
|
99
|
-
end
|
100
|
-
# Fetches videos from the Flickr user with the given NSID.
|
101
|
-
#
|
102
|
-
# @param nsid [String]
|
103
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
104
|
-
# @api_method [flickr.people.getPhotos](http://www.flickr.com/services/api/flickr.people.getPhotos.html)
|
105
|
-
#
|
106
|
-
# @note This method requires authentication with "read" permissions.
|
107
|
-
def videos_from_user(nsid, params = {})
|
108
|
-
media_from_user(nsid, params).select { |media| media.is_a?(Video) }
|
109
|
-
end
|
110
|
-
|
111
|
-
# Fetches photos and videos containing a Flickr user with the given NSID.
|
112
|
-
#
|
113
|
-
# @param nsid [String]
|
114
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
115
|
-
# @api_method [flickr.people.getPhotosOf](http://www.flickr.com/services/api/flickr.people.getPhotosOf.html)
|
116
|
-
def media_of_user(nsid, params = {})
|
117
|
-
response = client.media_of_user(nsid, params)
|
118
|
-
Media.of_user(response.body['photos'])
|
119
|
-
end
|
120
|
-
# Fetches photos containing a Flickr user with the given NSID.
|
121
|
-
#
|
122
|
-
# @param nsid [String]
|
123
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
124
|
-
# @api_method [flickr.people.getPhotosOf](http://www.flickr.com/services/api/flickr.people.getPhotosOf.html)
|
125
|
-
def photos_of_user(nsid, params = {})
|
126
|
-
media_of_user(nsid, params).select { |media| media.is_a?(Photo) }
|
127
|
-
end
|
128
|
-
# Fetches videos containing a Flickr user with the given NSID.
|
129
|
-
#
|
130
|
-
# @param nsid [String]
|
131
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
132
|
-
# @api_method [flickr.people.getPhotosOf](http://www.flickr.com/services/api/flickr.people.getPhotosOf.html)
|
133
|
-
def videos_of_user(nsid, params = {})
|
134
|
-
media_of_user(nsid, params).select { |media| media.is_a?(Video) }
|
135
|
-
end
|
136
|
-
|
137
|
-
# Fetches public photos and videos from the Flickr user with the given
|
138
|
-
# NSID.
|
139
|
-
#
|
140
|
-
# @param nsid [String]
|
141
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
142
|
-
# @api_method [flickr.people.getPublicPhotos](http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html)
|
143
|
-
def public_media_from_user(nsid, params = {})
|
144
|
-
response = client.public_media_from_user(nsid, params)
|
145
|
-
Media.from_user(response.body['photos'])
|
146
|
-
end
|
147
|
-
# Fetches public photos from the Flickr user with the given NSID.
|
148
|
-
#
|
149
|
-
# @param nsid [String]
|
150
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
151
|
-
# @api_method [flickr.people.getPublicPhotos](http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html)
|
152
|
-
def public_photos_from_user(nsid, params = {})
|
153
|
-
public_media_from_user(nsid, params).select { |media| media.is_a?(Photo) }
|
154
|
-
end
|
155
|
-
# Fetches public videos from the Flickr user with the given NSID.
|
156
|
-
#
|
157
|
-
# @param nsid [String]
|
158
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
159
|
-
# @api_method [flickr.people.getPublicPhotos](http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html)
|
160
|
-
def public_videos_from_user(nsid, params = {})
|
161
|
-
public_media_from_user(nsid, params).select { |media| media.is_a?(Video) }
|
162
|
-
end
|
163
|
-
|
164
|
-
# Returns the upload status of the user who is currently authenticated.
|
165
|
-
#
|
166
|
-
# @return [Flickrie::User]
|
167
|
-
# @api_method [flickr.people.getUploadStatus](http://www.flickr.com/services/api/flickr.people.getUploadStatus.html)
|
168
|
-
# @see Flickrie::User#upload_status
|
169
|
-
#
|
170
|
-
# @note This method requires authentication with "read" permissions.
|
171
|
-
def get_upload_status(params = {})
|
172
|
-
response = client.get_upload_status(params)
|
173
|
-
User.from_upload_status(response.body['user'])
|
174
|
-
end
|
175
|
-
|
176
|
-
# Add tags to the photo/video with the given ID.
|
177
|
-
#
|
178
|
-
# @param media_id [String, Fixnum]
|
179
|
-
# @param tags [String] A space delimited string with tags
|
180
|
-
# @return [nil]
|
181
|
-
# @api_method [flickr.photos.addTags](http://www.flickr.com/services/api/flickr.photos.addTags.html)
|
182
|
-
#
|
183
|
-
# @note This method requires authentication with "write" permissions.
|
184
|
-
def add_media_tags(media_id, tags, params = {})
|
185
|
-
client.add_media_tags(media_id, tags, params)
|
186
|
-
nil
|
187
|
-
end
|
188
|
-
alias add_photo_tags add_media_tags
|
189
|
-
alias add_video_tags add_media_tags
|
190
|
-
|
191
|
-
# Deletes the photo/video with the given ID.
|
192
|
-
#
|
193
|
-
# @param media_id [String, Fixnum]
|
194
|
-
# @return [nil]
|
195
|
-
# @api_method [flickr.photos.delete](http://www.flickr.com/services/api/flickr.photos.delete.html)
|
196
|
-
#
|
197
|
-
# @note This method requires authentication with "delete" permissions.
|
198
|
-
def delete_media(media_id, params = {})
|
199
|
-
client.delete_media(media_id, params)
|
200
|
-
nil
|
201
|
-
end
|
202
|
-
alias delete_photo delete_media
|
203
|
-
alias delete_video delete_media
|
204
|
-
|
205
|
-
# Fetches photos and videos from contacts of the user who authenticated.
|
206
|
-
#
|
207
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
208
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
209
|
-
# @api_method [flickr.photos.getContactsPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html)
|
210
|
-
#
|
211
|
-
# @note This method requires authentication with "read" permissions.
|
212
|
-
def media_from_contacts(params = {})
|
213
|
-
response = client.media_from_contacts(params)
|
214
|
-
Media.from_contacts(response.body['photos'])
|
215
|
-
end
|
216
|
-
# Fetches photos from contacts of the user who authenticated.
|
217
|
-
#
|
218
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
219
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
220
|
-
# @api_method [flickr.photos.getContactsPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html)
|
221
|
-
#
|
222
|
-
# @note This method requires authentication with "read" permissions.
|
223
|
-
def photos_from_contacts(params = {})
|
224
|
-
media_from_contacts(params).select { |media| media.is_a?(Photo) }
|
225
|
-
end
|
226
|
-
# Fetches videos from contacts of the user who authenticated.
|
227
|
-
#
|
228
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
229
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
230
|
-
# @api_method [flickr.photos.getContactsPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html)
|
231
|
-
#
|
232
|
-
# @note This method requires authentication with "read" permissions.
|
233
|
-
def videos_from_contacts(params = {})
|
234
|
-
media_from_contacts(params).select { |media| media.is_a?(Video) }
|
235
|
-
end
|
236
|
-
|
237
|
-
# Fetches public photos and videos from contacts of the user with the
|
238
|
-
# given NSID.
|
239
|
-
#
|
240
|
-
# @param nsid [String]
|
241
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
242
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
243
|
-
# @api_method [flickr.photos.getContactsPublicPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html)
|
244
|
-
def public_media_from_user_contacts(nsid, params = {})
|
245
|
-
response = client.public_media_from_user_contacts(nsid, params)
|
246
|
-
Media.from_contacts(response.body['photos'])
|
247
|
-
end
|
248
|
-
# Fetches public photos from contacts of the user with the
|
249
|
-
# given NSID.
|
250
|
-
#
|
251
|
-
# @param nsid [String]
|
252
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
253
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
254
|
-
# @api_method [flickr.photos.getContactsPublicPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html)
|
255
|
-
def public_photos_from_user_contacts(nsid, params = {})
|
256
|
-
public_media_from_user_contacts(nsid, params).
|
257
|
-
select { |media| media.is_a?(Photo) }
|
258
|
-
end
|
259
|
-
# Fetches public videos from contacts of the user with the
|
260
|
-
# given NSID.
|
261
|
-
#
|
262
|
-
# @param nsid [String]
|
263
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
264
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
265
|
-
# @api_method [flickr.photos.getContactsPublicPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html)
|
266
|
-
def public_videos_from_user_contacts(nsid, params = {})
|
267
|
-
public_media_from_user_contacts(nsid, params).
|
268
|
-
select { |media| media.is_a?(Video) }
|
269
|
-
end
|
270
|
-
|
271
|
-
# Fetches context of the photo/video with the given ID. Example:
|
272
|
-
#
|
273
|
-
# context = Flickrie.get_photo_context(37124234)
|
274
|
-
# context.count # => 23
|
275
|
-
# context.previous # => #<Photo: id=2433240, ...>
|
276
|
-
# context.next # => #<Video: id=1282404, ...>
|
277
|
-
#
|
278
|
-
# @param media_id [String, Fixnum]
|
279
|
-
# @return [Struct]
|
280
|
-
# @api_method [flickr.photos.getContext](http://www.flickr.com/services/api/flickr.photos.getContext.html)
|
281
|
-
def get_media_context(media_id, params = {})
|
282
|
-
response = client.get_media_context(media_id, params)
|
283
|
-
Media.from_context(response.body)
|
284
|
-
end
|
285
|
-
alias get_photo_context get_media_context
|
286
|
-
alias get_video_context get_media_context
|
287
|
-
|
288
|
-
# Fetches numbers of photos and videos for given date ranges. Example:
|
289
|
-
#
|
290
|
-
# require 'date'
|
291
|
-
# dates = [DateTime.parse("3rd Jan 2011").to_time, DateTime.parse("11th Aug 2011").to_time]
|
292
|
-
# counts = Flickrie.get_media_counts(:taken_dates => dates.map(&:to_i).join(','))
|
293
|
-
#
|
294
|
-
# count = counts.first
|
295
|
-
# count.value # => 24
|
296
|
-
# count.date_range # => 2011-01-03 01:00:00 +0100..2011-08-11 02:00:00 +0200
|
297
|
-
# count.date_range.begin # => 2011-01-03 01:00:00 +0100
|
298
|
-
# count.from # => 2011-01-03 01:00:00 +0100
|
299
|
-
#
|
300
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
301
|
-
# @return [Flickrie::MediaCount]
|
302
|
-
# @api_method [flickr.photos.getCounts](http://www.flickr.com/services/api/flickr.photos.getCounts.html)
|
303
|
-
def get_media_counts(params = {})
|
304
|
-
response = client.get_media_counts \
|
305
|
-
MediaCount.ensure_utc(params)
|
306
|
-
response.body['photocounts']['photocount'].
|
307
|
-
map { |info| MediaCount.new(info, params) }
|
308
|
-
end
|
309
|
-
alias get_photos_counts get_media_counts
|
310
|
-
alias get_videos_counts get_media_counts
|
311
|
-
|
312
|
-
# Fetches the exif for the photo with the given ID. Example:
|
313
|
-
#
|
314
|
-
# photo = Flickrie.get_photo_exif(27234987)
|
315
|
-
# photo.exif.get('Model') # => 'Canon PowerShot G12'
|
316
|
-
#
|
317
|
-
# photo.exif.get('X-Resolution', :data => 'raw') # => '180'
|
318
|
-
# photo.exif.get('X-Resolution', :data => 'clean') # => '180 dpi'
|
319
|
-
# photo.exif.get('X-Resolution') # => '180 dpi'
|
320
|
-
#
|
321
|
-
# @param photo_id [String, Fixnum]
|
322
|
-
# @return [Flickrie::Photo]
|
323
|
-
# @api_method [flickr.photos.getExif](http://www.flickr.com/services/api/flickr.photos.getExif.html)
|
324
|
-
def get_photo_exif(photo_id, params = {})
|
325
|
-
response = client.get_media_exif(photo_id, params)
|
326
|
-
Photo.new(response.body['photo'])
|
327
|
-
end
|
328
|
-
# Fetches the exif for the video with the given ID. Example:
|
329
|
-
#
|
330
|
-
# video = Flickrie.get_video_exif(27234987)
|
331
|
-
# video.exif.get('Model') # => 'Canon PowerShot G12'
|
332
|
-
#
|
333
|
-
# video.exif.get('X-Resolution', :data => 'raw') # => '180'
|
334
|
-
# video.exif.get('X-Resolution', :data => 'clean') # => '180 dpi'
|
335
|
-
# video.exif.get('X-Resolution') # => '180 dpi'
|
336
|
-
#
|
337
|
-
# @param video_id [String, Fixnum]
|
338
|
-
# @return [Flickrie::Video]
|
339
|
-
# @api_method [flickr.photos.getExif](http://www.flickr.com/services/api/flickr.photos.getExif.html)
|
340
|
-
def get_video_exif(video_id, params = {})
|
341
|
-
response = client.get_media_exif(video_id, params)
|
342
|
-
Video.new(response.body['photo'])
|
343
|
-
end
|
344
|
-
|
345
|
-
# Fetches the list of users who favorited the photo with the given ID.
|
346
|
-
# Example:
|
347
|
-
#
|
348
|
-
# photo = Flickrie.get_photo_favorites(24810948)
|
349
|
-
# photo.favorites.first.username # => "John Smith"
|
350
|
-
#
|
351
|
-
# @param photo_id [String, Fixnum]
|
352
|
-
# @return [Flickrie::Photo]
|
353
|
-
# @api_method [flickr.photos.getFavorites](http://www.flickr.com/services/api/flickr.photos.getFavorites.html)
|
354
|
-
def get_photo_favorites(photo_id, params = {})
|
355
|
-
response = client.get_media_favorites(photo_id, params)
|
356
|
-
Photo.new(response.body['photo'])
|
357
|
-
end
|
358
|
-
# Fetches the list of users who favorited the video with the given ID.
|
359
|
-
# Example:
|
360
|
-
#
|
361
|
-
# video = Flickrie.get_video_favorites(24810948)
|
362
|
-
# video.favorites.first.username # => "John Smith"
|
363
|
-
#
|
364
|
-
# @param video_id [String, Fixnum]
|
365
|
-
# @return [Flickrie::Video]
|
366
|
-
# @api_method [flickr.photos.getFavorites](http://www.flickr.com/services/api/flickr.photos.getFavorites.html)
|
367
|
-
def get_video_favorites(video_id, params = {})
|
368
|
-
response = client.get_media_favorites(video_id, params)
|
369
|
-
Video.new(response.body['photo'])
|
370
|
-
end
|
371
|
-
|
372
|
-
# Fetches info of the photo/video with the given ID.
|
373
|
-
#
|
374
|
-
# @param media_id [String, Fixnum]
|
375
|
-
# @return [Flickrie::Photo, Flickrie::Video]
|
376
|
-
# @api_method [flickr.photos.getInfo](http://www.flickr.com/services/api/flickr.photos.getInfo.html)
|
377
|
-
def get_media_info(media_id, params = {})
|
378
|
-
response = client.get_media_info(media_id, params)
|
379
|
-
Media.from_info(response.body['photo'])
|
380
|
-
end
|
381
|
-
alias get_photo_info get_media_info
|
382
|
-
alias get_video_info get_media_info
|
383
|
-
|
384
|
-
# Fetches photos and videos from the authenticated user
|
385
|
-
# that are not in any set.
|
386
|
-
#
|
387
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
388
|
-
# @api_method [flickr.photos.getNotInSet](http://www.flickr.com/services/api/flickr.photos.getNotInSet.html)
|
389
|
-
#
|
390
|
-
# @note This method requires authentication with "read" permissions.
|
391
|
-
def media_not_in_set(params = {})
|
392
|
-
response = client.media_not_in_set({:media => 'all'}.merge(params))
|
393
|
-
Media.from_not_in_set(response.body['photos'])
|
394
|
-
end
|
395
|
-
# Fetches photos from the authenticated user
|
396
|
-
# that are not in any set.
|
397
|
-
#
|
398
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
399
|
-
# @api_method [flickr.photos.getNotInSet](http://www.flickr.com/services/api/flickr.photos.getNotInSet.html)
|
400
|
-
#
|
401
|
-
# @note This method requires authentication with "read" permissions.
|
402
|
-
def photos_not_in_set(params = {})
|
403
|
-
media_not_in_set({:media => "photos"}.merge(params))
|
404
|
-
end
|
405
|
-
# Fetches videos from the authenticated user
|
406
|
-
# that are not in any set.
|
407
|
-
#
|
408
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
409
|
-
# @api_method [flickr.photos.getNotInSet](http://www.flickr.com/services/api/flickr.photos.getNotInSet.html)
|
410
|
-
#
|
411
|
-
# @note This method requires authentication with "read" permissions.
|
412
|
-
def videos_not_in_set(params = {})
|
413
|
-
media_not_in_set({:media => "videos"}.merge(params))
|
414
|
-
end
|
415
|
-
|
416
|
-
# Gets permissions of a photo with the given ID.
|
417
|
-
#
|
418
|
-
# @return [Flickrie::Photo]
|
419
|
-
# @api_method [flickr.photos.getPerms](http://www.flickr.com/services/api/flickr.photos.getPerms.html)
|
420
|
-
#
|
421
|
-
# @note This method requires authentication with "read" permissions.
|
422
|
-
def get_photo_permissions(photo_id, params = {})
|
423
|
-
response = client.get_media_permissions(photo_id, params)
|
424
|
-
Photo.from_perms(response.body['perms'])
|
425
|
-
end
|
426
|
-
# Gets permissions of a video with the given ID.
|
427
|
-
#
|
428
|
-
# @return [Flickrie::Video]
|
429
|
-
# @api_method [flickr.photos.getPerms](http://www.flickr.com/services/api/flickr.photos.getPerms.html)
|
430
|
-
#
|
431
|
-
# @note This method requires authentication with "read" permissions.
|
432
|
-
def get_video_permissions(video_id, params = {})
|
433
|
-
response = client.get_media_permissions(video_id, params)
|
434
|
-
Video.from_perms(response.body['perms'])
|
435
|
-
end
|
436
|
-
|
437
|
-
# Fetches the latest photos and videos uploaded to Flickr.
|
438
|
-
#
|
439
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
440
|
-
# @api_method [flickr.photos.getRecent](http://www.flickr.com/services/api/flickr.photos.getRecent.html)
|
441
|
-
def get_recent_media(params = {})
|
442
|
-
response = client.get_recent_media(params)
|
443
|
-
Media.from_recent(response.body['photos'])
|
444
|
-
end
|
445
|
-
# Fetches the latest photos uploaded to Flickr.
|
446
|
-
#
|
447
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
448
|
-
# @api_method [flickr.photos.getRecent](http://www.flickr.com/services/api/flickr.photos.getRecent.html)
|
449
|
-
def get_recent_photos(params = {})
|
450
|
-
get_recent_media(params).select { |media| media.is_a?(Photo) }
|
451
|
-
end
|
452
|
-
# Fetches the latest videos uploaded to Flickr.
|
453
|
-
#
|
454
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
455
|
-
# @api_method [flickr.photos.getRecent](http://www.flickr.com/services/api/flickr.photos.getRecent.html)
|
456
|
-
def get_recent_videos(params = {})
|
457
|
-
get_recent_media(params).select { |media| media.is_a?(Video) }
|
458
|
-
end
|
459
|
-
|
460
|
-
# Fetches the sizes of the photo with the given ID. Example:
|
461
|
-
#
|
462
|
-
# photo = Flickrie.get_photo_sizes(242348)
|
463
|
-
# photo.medium!(500)
|
464
|
-
# photo.size # => "Medium 500"
|
465
|
-
# photo.source_url # => "http://farm8.staticflickr.com/7090/7093101501_9337f28800.jpg"
|
466
|
-
#
|
467
|
-
# @param photo_id [String, Fixnum]
|
468
|
-
# @return [Flickrie::Photo]
|
469
|
-
# @api_method [flickr.photos.getSizes](http://www.flickr.com/services/api/flickr.photos.getSizes.html)
|
470
|
-
def get_photo_sizes(photo_id, params = {})
|
471
|
-
response = client.get_media_sizes(photo_id, params)
|
472
|
-
Photo.from_sizes(response.body['sizes'].merge('id' => photo_id.to_s))
|
473
|
-
end
|
474
|
-
# Fetches the sizes of the video with the given ID. Example:
|
475
|
-
#
|
476
|
-
# video = Flickrie.get_video_sizes(438492)
|
477
|
-
# video.download_url # => "..."
|
478
|
-
#
|
479
|
-
# @param video_id [String, Fixnum]
|
480
|
-
# @return [Flickrie::Video]
|
481
|
-
# @api_method [flickr.photos.getSizes](http://www.flickr.com/services/api/flickr.photos.getSizes.html)
|
482
|
-
def get_video_sizes(video_id, params = {})
|
483
|
-
response = client.get_media_sizes(video_id, params)
|
484
|
-
Video.from_sizes(response.body['sizes'].merge('id' => video_id.to_s))
|
485
|
-
end
|
486
|
-
|
487
|
-
# Fetches photos and videos from the authenticated user that have no
|
488
|
-
# tags.
|
489
|
-
#
|
490
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
491
|
-
# @api_method [flickr.photos.getUntagged](http://www.flickr.com/services/api/flickr.photos.getUntagged.html)
|
492
|
-
#
|
493
|
-
# @note This method requires authentication with "read" permissions.
|
494
|
-
def get_untagged_media(params = {})
|
495
|
-
response = client.get_untagged_media({:media => 'all'}.merge(params))
|
496
|
-
Media.from_untagged(response.body['photos'])
|
497
|
-
end
|
498
|
-
# Fetches photos from the authenticated user that have no tags.
|
499
|
-
#
|
500
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
501
|
-
# @api_method [flickr.photos.getUntagged](http://www.flickr.com/services/api/flickr.photos.getUntagged.html)
|
502
|
-
#
|
503
|
-
# @note This method requires authentication with "read" permissions.
|
504
|
-
def get_untagged_photos(params = {})
|
505
|
-
get_untagged_media({:media => 'photos'}.merge(params))
|
506
|
-
end
|
507
|
-
# Fetches videos from the authenticated user that have no tags.
|
508
|
-
#
|
509
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
510
|
-
# @api_method [flickr.photos.getUntagged](http://www.flickr.com/services/api/flickr.photos.getUntagged.html)
|
511
|
-
#
|
512
|
-
# @note This method requires authentication with "read" permissions.
|
513
|
-
def get_untagged_videos(params = {})
|
514
|
-
get_untagged_media({:media => 'videos'}.merge(params))
|
515
|
-
end
|
516
|
-
|
517
|
-
# Fetches geo-tagged photos and videos from the authenticated user.
|
518
|
-
#
|
519
|
-
# @return [Flickrie:Collection<Flickrie:Photo, Flickrie::Video>]
|
520
|
-
# @api_method [flickr.photos.getWithGeoData](http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html)
|
521
|
-
#
|
522
|
-
# @note This method requires authentication with "read" permissions.
|
523
|
-
def get_media_with_geo_data(params = {})
|
524
|
-
response = client.get_media_with_geo_data({:media => 'all'}.merge(params))
|
525
|
-
Media.from_geo_data(response.body['photos'])
|
526
|
-
end
|
527
|
-
# Fetches geo-tagged photos from the authenticated user.
|
528
|
-
#
|
529
|
-
# @return [Flickrie:Collection<Flickrie:Photo>]
|
530
|
-
# @api_method [flickr.photos.getWithGeoData](http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html)
|
531
|
-
#
|
532
|
-
# @note This method requires authentication with "read" permissions.
|
533
|
-
def get_photos_with_geo_data(params = {})
|
534
|
-
get_media_with_geo_data({:media => 'photos'}.merge(params))
|
535
|
-
end
|
536
|
-
# Fetches geo-tagged videos from the authenticated user.
|
537
|
-
#
|
538
|
-
# @return [Flickrie:Collection<Flickrie::Video>]
|
539
|
-
# @api_method [flickr.photos.getWithGeoData](http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html)
|
540
|
-
#
|
541
|
-
# @note This method requires authentication with "read" permissions.
|
542
|
-
def get_videos_with_geo_data(params = {})
|
543
|
-
get_media_with_geo_data({:media => 'videos'}.merge(params))
|
544
|
-
end
|
545
|
-
|
546
|
-
# Fetches photos and videos from the authenticated user that are not
|
547
|
-
# geo-tagged.
|
548
|
-
#
|
549
|
-
# @return [Flickrie:Collection<Flickrie:Photo, Flickrie::Video>]
|
550
|
-
# @api_method [flickr.photos.getWithoutGeoData](http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html)
|
551
|
-
#
|
552
|
-
# @note This method requires authentication with "read" permissions.
|
553
|
-
def get_media_without_geo_data(params = {})
|
554
|
-
response = client.get_media_with_geo_data({:media => 'all'}.merge(params))
|
555
|
-
Media.from_geo_data(response.body['photos'])
|
556
|
-
end
|
557
|
-
# Fetches photos from the authenticated user that are not geo-tagged.
|
558
|
-
#
|
559
|
-
# @return [Flickrie:Collection<Flickrie:Photo>]
|
560
|
-
# @api_method [flickr.photos.getWithoutGeoData](http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html)
|
561
|
-
#
|
562
|
-
# @note This method requires authentication with "read" permissions.
|
563
|
-
def get_photos_without_geo_data(params = {})
|
564
|
-
get_media_with_geo_data({:media => 'photos'}.merge(params))
|
565
|
-
end
|
566
|
-
# Fetches videos from the authenticated user that are not geo-tagged.
|
567
|
-
#
|
568
|
-
# @return [Flickrie:Collection<Flickrie::Video>]
|
569
|
-
# @api_method [flickr.photos.getWithoutGeoData](http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html)
|
570
|
-
#
|
571
|
-
# @note This method requires authentication with "read" permissions.
|
572
|
-
def get_videos_without_geo_data(params = {})
|
573
|
-
get_media_with_geo_data({:media => 'videos'}.merge(params))
|
574
|
-
end
|
575
|
-
|
576
|
-
# Fetches photos and videos from the authenticated user that have
|
577
|
-
# recently been updated.
|
578
|
-
#
|
579
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
580
|
-
# @api_method [flickr.photos.recentlyUpdated](http://www.flickr.com/services/api/flickr.photos.recentlyUpdated.html)
|
581
|
-
#
|
582
|
-
# @note This method requires authentication with "read" permissions.
|
583
|
-
def recently_updated_media(params = {})
|
584
|
-
response = client.recently_updated_media(params)
|
585
|
-
Media.from_recently_updated(response.body['photos'])
|
586
|
-
end
|
587
|
-
# Fetches photos from the authenticated user that have recently been updated.
|
588
|
-
#
|
589
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
590
|
-
# @api_method [flickr.photos.recentlyUpdated](http://www.flickr.com/services/api/flickr.photos.recentlyUpdated.html)
|
591
|
-
#
|
592
|
-
# @note This method requires authentication with "read" permissions.
|
593
|
-
def recently_updated_photos(params = {})
|
594
|
-
recently_updated_media(params).select { |media| media.is_a?(Photo) }
|
595
|
-
end
|
596
|
-
# Fetches videos from the authenticated user that have recently been updated.
|
597
|
-
#
|
598
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
599
|
-
# @api_method [flickr.photos.recentlyUpdated](http://www.flickr.com/services/api/flickr.photos.recentlyUpdated.html)
|
600
|
-
#
|
601
|
-
# @note This method requires authentication with "read" permissions.
|
602
|
-
def recently_updated_videos(params = {})
|
603
|
-
recently_updated_media(params).select { |media| media.is_a?(Video) }
|
604
|
-
end
|
605
|
-
|
606
|
-
# Remove the tag with the given ID
|
607
|
-
#
|
608
|
-
# @param tag_id [String]
|
609
|
-
# @return [nil]
|
610
|
-
# @api_method [flickr.photos.removeTag](http://www.flickr.com/services/api/flickr.photos.removeTag.html)
|
611
|
-
#
|
612
|
-
# @note This method requires authentication with "write" permissions.
|
613
|
-
def remove_media_tag(tag_id, params = {})
|
614
|
-
client.remove_media_tag(tag_id, params)
|
615
|
-
nil
|
616
|
-
end
|
617
|
-
alias remove_photo_tag remove_media_tag
|
618
|
-
alias remove_video_tag remove_media_tag
|
619
|
-
|
620
|
-
# Fetches photos and videos matching a certain criteria.
|
621
|
-
#
|
622
|
-
# @param search_params [Hash] Options for searching (see the link below under "Flickr API method")
|
623
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
624
|
-
# @api_method [flickr.photos.search](http://www.flickr.com/services/api/flickr.photos.search.html)
|
625
|
-
def search_media(params = {})
|
626
|
-
response = client.search_media({:media => 'all'}.merge(params))
|
627
|
-
Media.from_search(response.body['photos'])
|
628
|
-
end
|
629
|
-
# Fetches photos matching a certain criteria.
|
630
|
-
#
|
631
|
-
# @param search_params [Hash] Options for searching (see the link below under "Flickr API method")
|
632
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
633
|
-
# @api_method [flickr.photos.search](http://www.flickr.com/services/api/flickr.photos.search.html)
|
634
|
-
def search_photos(params = {})
|
635
|
-
search_media({:media => 'photos'}.merge(params))
|
636
|
-
end
|
637
|
-
# Fetches videos matching a certain criteria.
|
638
|
-
#
|
639
|
-
# @param search_params [Hash] Options for searching (see the link below under "Flickr API method")
|
640
|
-
# @return [Flickrie::Collection<Flickrie::Video>]
|
641
|
-
# @api_method [flickr.photos.search](http://www.flickr.com/services/api/flickr.photos.search.html)
|
642
|
-
def search_videos(params = {})
|
643
|
-
search_media({:media => 'videos'}.merge(params))
|
644
|
-
end
|
645
|
-
|
646
|
-
# Sets the content type of a photo/video.
|
647
|
-
#
|
648
|
-
# @param media_id [String, Fixnum]
|
649
|
-
# @param content_type [String, Fixnum]
|
650
|
-
# @return [nil]
|
651
|
-
# @api_method [flickr.photos.setContentType](http://www.flickr.com/services/api/flickr.photos.setContentType.html)
|
652
|
-
#
|
653
|
-
# @note This method requires authentication with "write" permissions.
|
654
|
-
def set_media_content_type(media_id, content_type, params = {})
|
655
|
-
client.set_media_content_type(media_id, content_type, params)
|
656
|
-
nil
|
657
|
-
end
|
658
|
-
alias set_photo_content_type set_media_content_type
|
659
|
-
alias set_video_content_type set_media_content_type
|
660
|
-
|
661
|
-
# Sets dates for a photo/video.
|
662
|
-
#
|
663
|
-
# @param media_id [String, Fixnum]
|
664
|
-
# @return [nil]
|
665
|
-
# @api_method [flickr.photos.setDates](http://www.flickr.com/services/api/flickr.photos.setDates.html)
|
666
|
-
#
|
667
|
-
# @note This method requires authentication with "write" permissions.
|
668
|
-
def set_media_dates(media_id, params = {})
|
669
|
-
client.set_media_dates(media_id, params)
|
670
|
-
nil
|
671
|
-
end
|
672
|
-
alias set_photo_dates set_media_dates
|
673
|
-
alias set_video_dates set_media_dates
|
674
|
-
|
675
|
-
# Sets meta information for a photo/video.
|
676
|
-
#
|
677
|
-
# @param media_id [String, Fixnum]
|
678
|
-
# @return [nil]
|
679
|
-
# @api_method [flickr.photos.setMeta](http://www.flickr.com/services/api/flickr.photos.setMeta.html)
|
680
|
-
#
|
681
|
-
# @note This method requires authentication with "write" permissions.
|
682
|
-
def set_media_meta(media_id, params = {})
|
683
|
-
client.set_media_meta(media_id, params)
|
684
|
-
nil
|
685
|
-
end
|
686
|
-
alias set_photo_meta set_media_meta
|
687
|
-
alias set_video_meta set_media_meta
|
688
|
-
|
689
|
-
# Sets permissions for a photo/video.
|
690
|
-
#
|
691
|
-
# @param media_id [String, Fixnum]
|
692
|
-
# @return [nil]
|
693
|
-
# @api_method [flickr.photos.setPerms](http://www.flickr.com/services/api/flickr.photos.setPerms.html)
|
694
|
-
#
|
695
|
-
# @note This method requires authentication with "write" permissions.
|
696
|
-
def set_media_permissions(media_id, params = {})
|
697
|
-
client.set_media_permissions(media_id, params)
|
698
|
-
nil
|
699
|
-
end
|
700
|
-
alias set_photo_permissions set_media_permissions
|
701
|
-
alias set_video_permissions set_media_permissions
|
702
|
-
|
703
|
-
# Sets the safety level of a photo/video.
|
704
|
-
#
|
705
|
-
# @param media_id [String, Fixnum]
|
706
|
-
# @return [nil]
|
707
|
-
# @api_method [flickr.photos.setSafetyLevel](http://www.flickr.com/services/api/flickr.photos.setSafetyLevel.html)
|
708
|
-
#
|
709
|
-
# @note This method requires authentication with "write" permissions.
|
710
|
-
def set_media_safety_level(media_id, params = {})
|
711
|
-
client.set_media_safety_level(media_id, params)
|
712
|
-
nil
|
713
|
-
end
|
714
|
-
alias set_photo_safety_level set_media_safety_level
|
715
|
-
alias set_video_safety_level set_media_safety_level
|
716
|
-
|
717
|
-
# Sets tags for a photo/video.
|
718
|
-
#
|
719
|
-
# @params media_id [String, Fixnum]
|
720
|
-
# @return [nil]
|
721
|
-
# @api_method [flickr.photos.setTags](http://www.flickr.com/services/api/flickr.photos.setTags.html)
|
722
|
-
#
|
723
|
-
# @note This method requires authentication with "write" permissions.
|
724
|
-
def set_media_tags(media_id, tags, params = {})
|
725
|
-
client.set_media_tags(media_id, tags, params)
|
726
|
-
nil
|
727
|
-
end
|
728
|
-
alias set_photo_tags set_media_tags
|
729
|
-
alias set_video_tags set_media_tags
|
730
|
-
|
731
|
-
# Fetches all available types of licenses.
|
732
|
-
#
|
733
|
-
# @return [Array<Flickrie::License>]
|
734
|
-
# @api_method [flickr.photos.licenses.getInfo](http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html)
|
735
|
-
def get_licenses(params = {})
|
736
|
-
response = client.get_licenses(params)
|
737
|
-
License.from_hash(response.body['licenses']['license'])
|
738
|
-
end
|
739
|
-
|
740
53
|
# Fetches upload tickets with given IDs. Example:
|
741
54
|
#
|
742
55
|
# photo = File.open("...")
|
@@ -758,53 +71,13 @@ module Flickrie
|
|
758
71
|
map { |info| Ticket.new(info) }
|
759
72
|
end
|
760
73
|
|
761
|
-
# Fetches
|
762
|
-
#
|
763
|
-
# @param set_id [String, Fixnum]
|
764
|
-
# @return [Flickrie::Set]
|
765
|
-
# @api_method [flickr.photosets.getInfo](http://www.flickr.com/services/api/flickr.photosets.getInfo.html)
|
766
|
-
def get_set_info(set_id, params = {})
|
767
|
-
response = client.get_set_info(set_id, params)
|
768
|
-
Set.from_info(response.body['photoset'])
|
769
|
-
end
|
770
|
-
|
771
|
-
# Fetches sets from a user with the given NSID.
|
772
|
-
#
|
773
|
-
# @param nsid [String]
|
774
|
-
# @return [Flickrie::Collection<Flickrie::Set>]
|
775
|
-
# @api_method [flickr.photosets.getList](http://www.flickr.com/services/api/flickr.photosets.getList.html)
|
776
|
-
def sets_from_user(nsid, params = {})
|
777
|
-
response = client.sets_from_user(nsid, params)
|
778
|
-
Set.from_user(response.body['photosets'], nsid)
|
779
|
-
end
|
780
|
-
|
781
|
-
# Fetches photos and videos from a set with the given ID.
|
782
|
-
#
|
783
|
-
# @param set_id [String]
|
784
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
785
|
-
# @return [Flickrie::Collection<Flickrie::Photo, Flickrie::Video>]
|
786
|
-
# @api_method [flickr.photosets.getPhotos](http://www.flickr.com/services/api/flickr.photosets.getPhotos.html)
|
787
|
-
def media_from_set(set_id, params = {})
|
788
|
-
response = client.media_from_set(set_id, {:media => 'all'}.merge(params))
|
789
|
-
Media.from_set(response.body['photoset'])
|
790
|
-
end
|
791
|
-
# Fetches photos from a set with the given ID.
|
792
|
-
#
|
793
|
-
# @param set_id [String]
|
794
|
-
# @param params [Hash] Options for this API method (see the link below under "Flickr API method")
|
795
|
-
# @return [Flickrie::Collection<Flickrie::Photo>]
|
796
|
-
# @api_method [flickr.photosets.getPhotos](http://www.flickr.com/services/api/flickr.photosets.getPhotos.html)
|
797
|
-
def photos_from_set(set_id, params = {})
|
798
|
-
media_from_set(set_id, {:media => 'photos'}.merge(params))
|
799
|
-
end
|
800
|
-
# Fetches videos from a set with the given ID.
|
74
|
+
# Fetches all available types of licenses.
|
801
75
|
#
|
802
|
-
# @
|
803
|
-
# @
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
media_from_set(set_id, {:media => 'videos'}.merge(params))
|
76
|
+
# @return [Array<Flickrie::License>]
|
77
|
+
# @api_method [flickr.photos.licenses.getInfo](http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html)
|
78
|
+
def get_licenses(params = {})
|
79
|
+
response = client.get_licenses(params)
|
80
|
+
License.from_hash(response.body['licenses']['license'])
|
808
81
|
end
|
809
82
|
|
810
83
|
# Tests if the authentication was successful. If it was, it
|