Sha256: 03485bd8f28ef55c2d38ca4759d40d7fdf97501f3362b787dee3061c27c7c2dd

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby
require 'thor'
require 'netrc'
require 'scrapers/manning_books'
require 'awesome_print'

################################################################################
#
# Scraper for Manning Books I've purchased
#
# (Note: you need to log into Manning and have acutally purchased e-books.
# They will appear on your dashboard.)
#
################################################################################

class ManningBooks < Thor

  MANNING = 'manning'

  desc "download", "Downloads all the editions of all the books on your dashboard"
  method_option :destination, :aliases => %w{-d --dest}, :desc => "Destination to store the downloads", :default => "."
  method_option :user, :aliases => %w{-u -U}, :desc => "Manning user. Default is read from $HOME/.netrc"
  method_option :password, :aliases => %w{-p -pw}, :desc => "Manning password. Default is read from $HOME/.netrc"

  def download
    netrc = Netrc.read
    user, pw = netrc[MANNING]
    user = options.fetch("user", user)
    pw = options.fetch("password", pw)
    destination = options.fetch("destination", nil)
    STDERR.puts "destination: #{destination}, user: #{user}, pw: #{pw.length}"
    Signal.trap('INT', proc { STDERR.puts "Download Interrupted"; exit(-1)})
    results = Scrapers::ManningBooks.scrape destination, user, pw
    ap results
  end

end

ManningBooks.start

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scrapers-2.0.2 bin/manning_books
scrapers-2.0.1 bin/manning_books
scrapers-2.0.0 bin/manning_books
scrapers-1.5.6 bin/manning_books
scrapers-1.5.5 bin/manning_books