Sha256: bf1cccdd4f48cdf9dfc7a6ec389d85a2eb91b7f42700b90719ece2ea5dc58007

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 KB

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.book = book

    if config[:no_trimming]
      return
    elsif config[:publish_iphone] || config[:publish_ipad] || config[:publish_kindle]
      publisher.publish_for_iphone if config[:publish_iphone]
      publisher.publish_for_ipad   if config[:publish_ipad]
      publisher.publish_for_kindle if config[:publish_kindle]
    else
      publisher.publish_default
    end

  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

16 entries across 16 versions & 1 rubygems

Version Path
kindai-2.8.0 lib/kindai/interface.rb
kindai-2.7.0 lib/kindai/interface.rb
kindai-2.6.0 lib/kindai/interface.rb
kindai-2.5.1 lib/kindai/interface.rb
kindai-2.4.3 lib/kindai/interface.rb
kindai-2.4.2 lib/kindai/interface.rb
kindai-2.4.1 lib/kindai/interface.rb
kindai-2.4.0 lib/kindai/interface.rb
kindai-2.3.0 lib/kindai/interface.rb
kindai-2.2.1 lib/kindai/interface.rb
kindai-2.2.0 lib/kindai/interface.rb
kindai-2.1.2 lib/kindai/interface.rb
kindai-2.1.1 lib/kindai/interface.rb
kindai-2.1.0 lib/kindai/interface.rb
kindai-2.0.0 lib/kindai/interface.rb
kindai-1.9.0 lib/kindai/interface.rb