Sha256: 69ccb697bc6e563551da8077752e0849ae5bd67bcee4bfd548184dee4b3df170

Contents?: true

Size: 992 Bytes

Versions: 6

Compression:

Stored size: 992 Bytes

Contents

# -*- coding: utf-8 -*-
module Kindai::Interface
  def self.download_url(url, config = { })
    book = Kindai::Book.new_from_permalink(url)
    download_book(book, config)
  end

  def self.download_book(book, config = { })
    downloader = Kindai::BookDownloader.new_from_book(book)
    downloader.base_path = config[:base_path] if config[:base_path]
    downloader.retry_count = config[:retry_count] if config[:retry_count]
    Kindai::Util.logger.info "download #{book.title}(#{book.total_spread} spreads) to #{downloader.book_path}"
    downloader.download

    publisher = Kindai::Publisher.new_from_path downloader.book_path
    publisher.publish_auto
  end

  def self.download_keyword(keyword, config = { })
    searcher = Kindai::Searcher.search(keyword)
    searcher.each_with_index { |book, index|
      begin
        Kindai::Util.logger.info "book #{index+1} / #{searcher.length}"
        download_book book, config
      rescue => error
        p error
      end
    }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kindai-1.5.1 lib/kindai/interface.rb
kindai-1.5.0 lib/kindai/interface.rb
kindai-1.4.0 lib/kindai/interface.rb
kindai-1.3.0 lib/kindai/interface.rb
kindai-1.1.0 lib/kindai/interface.rb
kindai-1.0.0 lib/kindai/interface.rb