Class: FlickrTools::GetSet
Instance Method Summary
collapse
Methods inherited from Command
find_config_dir, #initialize
Instance Method Details
#get_set(id, size = :original) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/flickr-tools/get_set.rb', line 31
def get_set(id, size = :original)
if set = find_set(id)
puts "getting set #{set_description set}"
dir = set.title.to_filename
FileUtils.mkdir_p dir
puts "downloading to #{dir}/"
per_page = 200
@queue = Queue.new
1.upto((set.num_photos.to_i / per_page) + 1) do |page|
puts "."
set.get_photos(:page => page, :per_page => per_page).each do |p|
@queue.enq({ :url => p.url(size), :filename => "#{dir}/#{p.title.to_filename}.jpg" })
end
end
puts "found #{@queue.size} photos"
spawn_workers
wait_for_workers
else
puts "no set matching #{id} found."
end
end
|
#run ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/flickr-tools/get_set.rb', line 13
def run
set = @args.shift
if set.nil? || set.blank?
show_sets
else
get_set set
end
end
|
#show_sets ⇒ Object
24
25
26
27
28
29
|
# File 'lib/flickr-tools/get_set.rb', line 24
def show_sets
puts "getting sets for #{@name}"
flickr.photosets.get_list.each do |set|
puts set_description(set)
end
end
|