Module: PicFisher::FishingBoat
- Defined in:
- lib/picfisher/fishing_boat.rb
Overview
Extracts the image urls from the given file and download them to the given directory
Class Method Summary collapse
-
.fish(images_file_path, output_directory_path) ⇒ nil
Extracts the image urls from the given file and download them to the given directory.
Class Method Details
.fish(images_file_path, output_directory_path) ⇒ nil
Extracts the image urls from the given file and download them to the given directory
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/picfisher/fishing_boat.rb', line 13 def self.fish(images_file_path, output_directory_path) PicFisher::Log.info("Fishing from #{images_file_path} to #{output_directory_path}") file_to_string = File.read(images_file_path) urls = PicFisher::URLExtractor.extract(file_to_string) urls.each do |url| sanitized_url = PicFisher::Sanitizer.sanitize_image_url(url) begin PicFisher::Downloader.download(url, "#{output_directory_path}/#{sanitized_url}") rescue PicFisher::Error PicFisher::Log.error("Failed to fish #{url}. Skipping...") end end end |