-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathmember-images.rb
More file actions
executable file
·47 lines (39 loc) · 1.39 KB
/
Copy pathmember-images.rb
File metadata and controls
executable file
·47 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
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
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
require "optparse"
require_relative "lib/configuration"
require_relative "lib/people"
class MemberImages
def initialize(args)
@args = args
@options = { limit: nil }
OptionParser.new do |opts|
opts.banner = "Usage: member-images.rb [--limit=N] [--output-dir=PATH]"
opts.on("--limit=N", Integer, "Cap the number of people whose images are downloaded") do |n|
@options[:limit] = n
end
opts.on("--output-dir=PATH", "Download images to PATH instead of conf.file_image_path") do |path|
@options[:output_dir] = path
end
end.parse!(@args)
end
def run
conf = Configuration.new
people = PeopleCSVReader.read_members
file_image_path = @options[:output_dir] || conf.file_image_path
FileUtils.mkdir_p ["#{file_image_path}/mps",
"#{file_image_path}/mpsL",
"#{file_image_path}/mpsXL"]
puts "Downloading person images to #{file_image_path}/{mps,mpsL,mpsXL}..."
people.download_images(
"#{file_image_path}/mps",
"#{file_image_path}/mpsL",
"#{file_image_path}/mpsXL",
limit: @options[:limit]
)
puts "Finished downloading person images!"
end
end
Configuration.report_errors { MemberImages.new(ARGV).run } if $PROGRAM_NAME == __FILE__