Module Systems::Flickr
In: lib/systems/flickr.rb

Methods

Public Instance methods

[Source]

    # File lib/systems/flickr.rb, line 2
 2:   def data_for_flickr_id(id, require_geo_info = false)
 3:     begin
 4:       info = flickr.photos.getInfo(:photo_id => id)
 5:     rescue FlickRaw::FailedResponse
 6:       return false
 7:     end
 8:     item = {
 9:       :description => info.description,
10:       :attribution => info.owner.username,
11:       :external_link => info.urls.detect { |el| el.type == 'photopage' }._content
12:     }
13: 
14:     flickr = {
15:       :title => info.title,
16:       :num_comments => info.comments,
17:       :license_id => info.license,
18:       :posted => info.dates.posted,
19:       :lastupdate => info.dates.lastupdate,
20:       :taken => info.dates.taken,
21:       :tags => info.tags.map(&:raw).join(';'),
22:       :description => info.description,
23:       :username => info.owner.username,
24:       :photo_id => id,
25:     }
26:     if info.respond_to?(:location)
27:       flickr.merge!(:longitude => info.location.longitude) if info.location.respond_to?(:longitude)
28:       flickr.merge!(:latitude => info.location.latitude) if info.location.respond_to?(:latitude)
29:       flickr.merge!(:accuracy => info.location.accuracy) if info.location.respond_to?(:accuracy)
30:       flickr.merge!(:country => info.location.country) if info.location.respond_to?(:country)
31:       flickr.merge!(:place_id => info.location.place_id) if info.location.respond_to?(:place_id)
32:       flickr.merge!(:region => info.location.region.to_s)  if info.location.respond_to?(:region)
33:     elsif require_geo_info
34:       return false
35:     end
36:     [item, flickr]
37:   end

flickr upload

[Source]

    # File lib/systems/flickr.rb, line 40
40:   def temp_file_for_flickr_id(id)
41:     sizes = flickr.photos.getSizes(:photo_id => id)
42:     url = (sizes.detect { |el| el.label == 'Medium' } || sizes.detect { |el| el.label == 'Original' }).source
43: #    path = "#{Constants::Config::DIR_PATH}/#{File.basename(url)}"
44: #    %x(curl -s -o #{path} #{url})
45:     temp_file_for_url(url)
46:   end

[Validate]