Class: Booru::Downloader
- Inherits:
-
Object
- Object
- Booru::Downloader
- Includes:
- Utils
- Defined in:
- lib/booru/downloader.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(options = {}) ⇒ Downloader
constructor
A new instance of Downloader.
Methods included from Utils
#clean_filename, #curl, #get_md5_hash, #reduce_filename, #sanitize, #transfer, #wget, #which, #write
Constructor Details
#initialize(options = {}) ⇒ Downloader
Returns a new instance of Downloader.
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 |
# File 'lib/booru/downloader.rb', line 6 def initialize( = {}) board = [:board].downcase.to_sym user = [:user] pass = [:pass] limit = [:max] @tags = sanitize([:tags]) @pool = sanitize([:pool]) @store = [:output] @user_agent = 'Mozilla/5.0' @client = case board when :konachan Konachan.new(user,pass) when :behoimi Behoimi.new(user, pass) when :yandere Yandere.new(user, pass) when :danbooru Danbooru.new(user, pass) else puts "Image board unsupported. Exiting." exit 1 end @curr = 1 @page = 1 fetch_posts(@page) # TODO Figure out a way to get total count if limit @total = limit else @total = 100 end #@pages = @total.to_i/100 + 1 FileUtils.mkdir_p File.(@store) end |
Instance Method Details
#download ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/booru/downloader.rb', line 44 def download while @posts.length > 0 do download_posts paginate end puts "No more results for #{@tags}" end |