Module: FlickrAirlift

Defined in:
lib/flickr_airlift.rb,
lib/flickr_airlift/version.rb,
lib/flickr_airlift/downloader.rb

Defined Under Namespace

Modules: Downloader

Constant Summary collapse

VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.downloadObject



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
# File 'lib/flickr_airlift.rb', line 10

def self.download
  begin

    establish_session

    # Prompt
    puts "Whose photos would you like to archive?:"

    scraped_user = STDIN.gets
    scraped_user = scraped_user.strip

    begin
      user    = flickr.people.findByUsername(:username => scraped_user)
      user_id = user.id
    rescue Exception => e
      puts "Hmmmm - unknown user - make sure to use the user's full handle - not the one in the URL. (example: 'Fast & Bulbous' not 'fastandbulbous')"
      self.download
    end

    # Grab sets
    photo_sets = flickr.photosets.getList(:user_id => user_id).sort_by(&:title)

    choose do |menu|
      menu.prompt = "What do you want to download?"

      menu.choice("~ Entire Photostream ~") do
        FlickrAirlift::Downloader.download(user)
        exit
      end

      photo_sets.each do |photoset|
        menu.choice(photoset.title) do
          FlickrAirlift::Downloader.download(user, photoset)
          exit
        end
      end

      menu.choice("Quit") { exit }
    end

  rescue FlickRaw::FailedResponse => e
    puts e.msg
  end
end

.establish_sessionObject



55
56
57
58
# File 'lib/flickr_airlift.rb', line 55

def self.establish_session
  fa = FlickrAuthentication.new(key: '3b2360cc04947af8cf59f51c47a6a8e4', shared_secret: '405549bcec106815', auth_file: File.join(Dir.home, ".flick_airliftrc"))
  fa.authenticate
end