Sha256: 792e244898c4ebfc625163dd5eb734f3faf6c32a1f5976b3e9e6cb837a0d67ce

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8
module Nokaya
  class App < Thor
    package_name "Nokaya"
    require_relative 'getter'
    require_relative 'image'
    require_relative 'status'

    desc "instagram", "Get the main photo from an Instagram page (nokaya -i url)"
    map "-i" => :instagram
    option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
    def instagram *args
      abort Status.no_url if args.empty?
      nokaya = Getter.new options, :instagram, args
      page = nokaya.parse_page
      img_link = nokaya.get_basic page
      download_and_save img_link, nokaya
    end

    desc "favd", 'Get the photo from a Favd page (nokaya favd url)'
    option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
    def favd *args
      abort Status.no_url if args.empty?
      nokaya = Getter.new options, :favd, args
      page = nokaya.parse_page
      img_link = nokaya.get_favd page
      download_and_save img_link, nokaya
    end

    desc "adn", "Get the photo from a photos.app.net page (nokaya adn url)"
    option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
    def adn *args
      abort Status.no_url if args.empty?
      nokaya = Getter.new options, :adn, args
      page = nokaya.parse_page
      img_link = nokaya.get_basic page
      download_and_save img_link, nokaya
    end

    private

    def download_and_save img_link, nokaya
      puts Status.downloading img_link
      path = Image.photo_name nokaya
      Image.save_image(path, nokaya.get_image(img_link))
      puts Status.saved path
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.0.3 lib/nokaya/app.rb