lib/flickr/photos.rb in commonthread-flickr_fu-0.1.6 vs lib/flickr/photos.rb in commonthread-flickr_fu-0.2.0
- old
+ new
@@ -185,13 +185,31 @@
end if rsp.photos.photo
end
end
def licenses
- @licenses ||= get_licenses
+ @licenses ||= begin
+ rsp = @flickr.send_request('flickr.photos.licenses.getInfo')
+
+ returning Hash.new do |licenses|
+ rsp.licenses.license.each do |license|
+ licenses[license[:id].to_i] = Flickr::Photos::License.new(:id => license[:id].to_i, :name => license[:name], :url => license[:url])
+ end
+ end
+ end
end
+ # Returns a Flickr::Photos::Photo object of the given id.
+ # Raises an error if photo not found
+ def find_by_id(photo_id)
+ rsp = @flickr.send_request('flickr.photos.getInfo', :photo_id => photo_id)
+ Photo.new(@flickr, :id => rsp.photo[:id].to_i, :owner => rsp.photo.owner,
+ :secret => rsp.photo[:secret], :server => rsp.photo[:server].to_i, :farm => rsp.photo[:farm],
+ :title => rsp.photo.title,
+ :is_public => rsp.photo.visibility[:public], :is_friend => rsp.photo.visibility[:is_friend], :is_family => rsp.photo.visibility[:is_family])
+ end
+
protected
def create_attributes(photo)
{:id => photo[:id],
:owner => photo[:owner],
:secret => photo[:secret],
@@ -214,15 +232,6 @@
:o_dims => photo[:o_dims],
:views => photo[:views].to_i,
:media => photo[:media]}
end
- def get_licenses
- rsp = @flickr.send_request('flickr.photos.licenses.getInfo')
-
- returning Hash.new do |licenses|
- rsp.licenses.license.each do |license|
- licenses[license[:id].to_i] = Flickr::Photos::License.new(:id => license[:id].to_i, :name => license[:name], :url => license[:url])
- end
- end
- end
end