nokaya 0.0.8 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f31b2704253ab50e0843244c13b03c6c0610a20
4
- data.tar.gz: 5813f6bf4336a993604b8bcdb3e3ae7d1b0ed173
3
+ metadata.gz: 9d3963d242f5b924de763a5549f26a2c23ff480e
4
+ data.tar.gz: 01129dc6b118913ba2452adba063a25247133481
5
5
  SHA512:
6
- metadata.gz: 993d92e4409efc6f832109092737213023ae367a4fc5c969de362c8db2101bf70a3828ea29119149118f9623e1479eb0cf59abfb95106271ede1805e64f5e0af
7
- data.tar.gz: 7d64dac6459b889d3e2dbeeda91f9466dd00b3ccc2a6a4e9768490bb14e16cba5c506ce0c01ffdc0b26cfb9a0cac7d29bd86df34f4bd9c5fb286aaa451a0a1ca
6
+ metadata.gz: 6019e2867b567f8586d22b09ca1a3a887d1cc46a4d211676f84a6ac3c0e4a98dc2e47ef543e41d46d90f71a23be246512b01d8f718ba212f681d7ba2752c4eaa
7
+ data.tar.gz: 354ebc4eb8dee9d2c28bfd286fc89a4d9e29cc441dd8161f9c8f658ec57e73444ae879e2fe17cb6cff2036101419e2d7aeeaad2da499bf776abdde72cb39ef45
@@ -1,3 +1,8 @@
1
+ # 0.1.0
2
+
3
+ - Major internal refactoring
4
+ - New: download movie poster from movie title
5
+
1
6
  # 0.0.8
2
7
 
3
8
  - Option: specify an output path
data/README.md CHANGED
@@ -1,47 +1,39 @@
1
+ [![Gem Version](https://badge.fury.io/rb/nokaya.svg)](http://badge.fury.io/rb/nokaya)
2
+
1
3
  # Nokaya
2
4
 
3
5
  CLI to download photos from several online services including Instagram, Imgur albums, Flickr albums, App.net, Tumblr pages, Photo.net, Deviantart, etc.
4
6
 
5
7
  Mac OS X only for the time being.
6
8
 
7
- ## Installation
9
+ ## Installation
8
10
 
9
11
  `gem install nokaya`
10
12
 
11
- ## Usage
12
-
13
- ### Instagram
14
-
13
+ ## Usage
14
+
15
+ ### Instagram
16
+
15
17
  `nokaya -i url`
16
18
 
17
- `nokaya -i url -n file_name`
18
-
19
- `nokaya -i url -n 'file name'`
20
-
21
19
  Also accepts the IFTTT format (like 'http://ift.tt/1m2Nvz8').
22
20
 
23
21
  Example:
24
22
 
25
23
  `nokaya -i http://instagram.com/p/noANAfjJ7B/`
26
24
 
27
- `nokaya -i http://instagram.com/p/noANAfjJ7B/ -n happydog`
28
-
29
- `nokaya -i http://ift.tt/1m2Nvz8 -n pasta`
30
-
31
- ### Tumblr post
25
+ `nokaya -i http://ift.tt/1m2Nvz8`
32
26
 
27
+ ### Tumblr post
28
+
33
29
  `nokaya -tu url`
34
30
 
35
- `nokaya -tu url -n file_name`
36
-
37
31
  Example:
38
32
 
39
33
  `nokaya -tu http://spacequest.tumblr.com/post/83560738152/sexycomics-carlos-valenzuela`
40
34
 
41
- `nokaya -tu http://spacequest.tumblr.com/post/83560738152/sexycomics-carlos-valenzuela -n 'girl and monster'`
42
-
43
- ### Tumblr page
44
-
35
+ ### Tumblr page
36
+
45
37
  Due to the various themes and layouts existing for Tumblr galleries, this feature may not work perfectly...
46
38
 
47
39
  Nokaya will try several techniques to extract the image links, then will fallback to scraping all available links if failing at properly detecting photos.
@@ -52,30 +44,30 @@ Example:
52
44
 
53
45
  `nokaya -tal http://brekninger.tumblr.com`
54
46
 
55
- Downloads all images in the page.
56
-
57
- ### Imgur album
47
+ Downloads all images in the visible page.
58
48
 
49
+ ### Imgur album
50
+
59
51
  `nokaya -ial url`
60
52
 
61
53
  Example:
62
54
 
63
55
  `nokaya -ial http://imgur.com/a/JNzjB\#0`
64
56
 
65
- Downloads all images in the album.
66
-
67
- ### Flickr album
57
+ Downloads all images in the album (visible page).
68
58
 
59
+ ### Flickr album
60
+
69
61
  `nokaya -fal url`
70
62
 
71
63
  Example:
72
64
 
73
65
  `nokaya -fal https://www.flickr.com/photos/ericdke/sets/72157644556227302/`
74
66
 
75
- Downloads all images in the album.
76
-
77
- ### Photo.net page
67
+ Downloads all images in the album (visible page).
78
68
 
69
+ ### Photo.net page
70
+
79
71
  `nokaya -pnet url`
80
72
 
81
73
  Example:
@@ -84,62 +76,78 @@ Example:
84
76
 
85
77
  Downloads all images in the page.
86
78
 
87
- ### Deviantart gallery
88
-
79
+ ### Deviantart gallery
80
+
89
81
  `nokaya -dart url`
90
82
 
91
83
  Example:
92
84
 
93
85
  `nokaya -dart http://www.deviantart.com/photography/nature/waterscapes/`
94
86
 
95
- Downloads all images in the gallery.
96
-
97
- ### Imageshack user gallery
87
+ Downloads all images in the gallery (visible page).
98
88
 
89
+ ### Imageshack user gallery
90
+
99
91
  `nokaya -ishu url`
100
92
 
101
93
  Example:
102
94
 
103
95
  `nokaya -ishu https://imageshack.com/user/ToddGilbert`
104
96
 
105
- Downloads all images in the user gallery.
106
-
107
- ### Favd
97
+ Downloads all images in the user gallery (visible page).
108
98
 
99
+ ### Favd
100
+
109
101
  `nokaya favd url`
110
102
 
111
- `nokaya favd url -n file_name`
112
-
113
103
  Example:
114
104
 
115
105
  `nokaya favd http://pic.favd.net/29987710`
116
106
 
117
- `nokaya favd http://pic.favd.net/29987710 -n feet`
107
+ ### App.net
108
+
109
+ `nokaya adn url`
118
110
 
119
- ### App.net
111
+ Example:
120
112
 
121
- `nokaya adn url`
113
+ `nokaya adn https://photos.app.net/30055986/1`
114
+
115
+ ### Movie
116
+
117
+ Downloads a movie poster given (part of) a movie title.
122
118
 
123
- `nokaya adn url -n file_name`
119
+ `nokaya movie title`
124
120
 
125
121
  Example:
126
122
 
127
- `nokaya adn https://photos.app.net/30055986/1`
123
+ `nokaya movie the dark knight`
124
+
125
+ Use option `-a` to get an alternative.
128
126
 
129
- `nokaya adn https://photos.app.net/30055986/1 -n random`
127
+ This is useful for remakes:
130
128
 
131
- ## Options
129
+ `nokaya movie solaris`
132
130
 
133
- ### Name
131
+ (gives the 2002 version)
134
132
 
133
+ `nokaya movie -a solaris`
134
+
135
+ (gives the 1972 version)
136
+
137
+ ## Options
138
+
139
+ ### Name
140
+
135
141
  `--name` or `-n`
136
142
 
137
143
  Specify a name (without extension).
138
144
 
139
145
  `nokaya -i http://instagram.com/p/noANAfjJ7B/ -n happy_dog`
140
146
 
141
- ### Output
147
+ `nokaya -i http://instagram.com/p/noANAfjJ7B/ -n 'happy dog'`
142
148
 
149
+ ### Output
150
+
143
151
  `--output` or `-o`
144
152
 
145
153
  Specify an output path.
@@ -148,8 +156,8 @@ Specify an output path.
148
156
 
149
157
  The picture(s) will be downloaded in '~/Downloads' if no output specified.
150
158
 
151
- ### Both
152
-
159
+ ### Both
160
+
153
161
  Specify both.
154
162
 
155
163
  `nokaya -i http://instagram.com/p/noANAfjJ7B/ -o ~/Pics -n happy_dog`
data/bin/nokaya CHANGED
File without changes
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
- require 'ostruct'
3
2
  require 'thor'
4
- require 'terminal-table/import'
5
3
  require 'open-uri'
6
4
  require 'nokogiri'
7
5
  require_relative 'nokaya/version'
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+ class ADN < Basic
4
+
5
+ attr_reader :author
6
+
7
+ def initialize args, options
8
+ super(args, options)
9
+ @type = :adn
10
+ parsed = self.parse(args[0])
11
+ @image_url = [self.get_basic(parsed)]
12
+ @author = author(parsed)
13
+ @file_name = [name()]
14
+ end
15
+
16
+ private
17
+
18
+ def author page
19
+ page.css('.p-nickname')[0].text
20
+ end
21
+
22
+ def post_id args
23
+ /\d+{2}/.match(args[0])
24
+ end
25
+
26
+ def name
27
+ unless @name.nil?
28
+ "#{@type.to_s}-#{@name}"
29
+ else
30
+ "#{@type.to_s}-#{@workers.sanitize(@author)}-#{post_id(args)}.jpg"
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -1,168 +1,132 @@
1
1
  # encoding: utf-8
2
2
  module Nokaya
3
3
  class App < Thor
4
+
4
5
  package_name "Nokaya"
5
- require_relative 'getter'
6
- require_relative 'image'
7
- require_relative 'status'
8
6
 
9
- desc "instagram", "Get the original picture from an Instagram page (nokaya -i url)"
7
+ %w{basic status movie workers instagram favd adn tumblr tumblr_album imgur_album flickr_album photonet deviantart imageshack_user}.each {|file| require_relative "#{file}"}
8
+
9
+ desc "movie TITLE", "Get the movie poster from IMDb (nokaya -m url)"
10
+ map "-m" => :movie
11
+ option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
12
+ option :output, aliases: "-o", type: :string, desc: "Specify an output path"
13
+ option :alt, aliases: "-a", type: :boolean, desc: "Find an alternative response"
14
+ def movie *args
15
+ puts Status.wait
16
+ image = Movie.new(args, options)
17
+ image.save
18
+ puts Status.saved(image)
19
+ end
20
+
21
+ desc "instagram URL", "Get the original picture from an Instagram page (nokaya -i url)"
10
22
  map "-i" => :instagram
11
23
  option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
12
24
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
13
25
  def instagram *args
14
- check_args args
15
- nokaya = Getter.new options, :instagram, args
16
- basic nokaya
26
+ puts Status.wait
27
+ image = Instagram.new(args, options)
28
+ image.save
29
+ puts Status.saved(image)
17
30
  end
18
31
 
19
- desc "favd", 'Get the picture from a Favd page (nokaya favd url)'
32
+ desc "favd URL", 'Get the picture from a Favd page (nokaya favd url)'
20
33
  option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
21
34
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
22
35
  def favd *args
23
- check_args args
24
- nokaya = Getter.new options, :favd, args
25
- page = nokaya.parse_page
26
- img_link = nokaya.get_favd page
27
- save_pic img_link, nokaya
36
+ puts Status.wait
37
+ image = Favd.new(args, options)
38
+ image.save
39
+ puts Status.saved(image)
28
40
  end
29
41
 
30
- desc "adn", "Get the picture from a photos.app.net page (nokaya adn url)"
42
+ desc "adn URL", "Get the picture from a photos.app.net page (nokaya adn url)"
31
43
  option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
32
44
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
33
45
  def adn *args
34
- check_args args
35
- nokaya = Getter.new options, :adn, args
36
- basic nokaya
46
+ puts Status.wait
47
+ image = ADN.new(args, options)
48
+ image.save
49
+ puts Status.saved(image)
37
50
  end
38
51
 
39
- desc "tumblr", "Get the picture from a Tumblr post (nokaya -tu url)"
52
+ desc "tumblr URL", "Get the picture from a Tumblr post (nokaya -tu url)"
40
53
  map "-tu" => :tumblr
41
54
  option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
42
55
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
43
56
  def tumblr *args
44
- check_args args
45
- nokaya = Getter.new options, :tumblr, args
46
- basic nokaya
57
+ puts Status.wait
58
+ image = Tumblr.new(args, options)
59
+ image.save
60
+ puts Status.saved(image)
47
61
  end
48
62
 
49
- desc "tumblr_album", "Get all pictures from a Tumblr page (nokaya -tal url)"
63
+ desc "tumblr_album URL", "Get all pictures from a Tumblr page (nokaya -tal url)"
50
64
  map "-tal" => :tumblr_album
51
65
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
52
66
  def tumblr_album *args
53
- check_args args
54
- nokaya = Getter.new options, :tumblr_album, args
55
- page = nokaya.parse_page
56
- img_links = nokaya.get_tumblr_album page
57
- save_album img_links, nokaya
67
+ puts Status.wait
68
+ image = TumblrAlbum.new(args, options)
69
+ image.save
70
+ puts Status.saved_album(image)
58
71
  end
59
72
 
60
- desc "imgur_album", "Get all pictures from an Imgur album (nokaya -ial url)"
73
+ desc "imgur_album URL", "Get all pictures from an Imgur album (nokaya -ial url)"
61
74
  map "-ial" => :imgur_album
62
75
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
63
76
  def imgur_album *args
64
- check_args args
65
- nokaya = Getter.new options, :imgur_album, args
66
- page = nokaya.parse_page
67
- img_links = nokaya.get_imgur_album page
68
- save_album img_links, nokaya
77
+ puts Status.wait
78
+ image = ImgurAlbum.new(args, options)
79
+ image.save
80
+ puts Status.saved_album(image)
69
81
  end
70
82
 
71
- desc "flickr_album", "Get all pictures from a Flickr album (nokaya -fal url)"
83
+ desc "flickr_album URL", "Get all pictures from a Flickr album (nokaya -fal url)"
72
84
  map "-fal" => :flickr_album
73
85
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
74
86
  def flickr_album *args
75
- check_args args
76
- nokaya = Getter.new options, :flickr_album, args
77
- page = nokaya.parse_page
78
- img_links = nokaya.get_flickr_album page
79
- save_album img_links, nokaya
87
+ puts Status.wait
88
+ image = FlickrAlbum.new(args, options)
89
+ image.save
90
+ puts Status.saved_album(image)
80
91
  end
81
92
 
82
- desc "photonet", "Get all pictures from a Photo.net page (nokaya -pnet url)"
93
+ desc "photonet URL", "Get all pictures from a Photo.net page (nokaya -pnet url)"
83
94
  map "-pnet" => :photonet
84
95
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
85
96
  def photonet *args
86
- check_args args
87
- nokaya = Getter.new options, :photonet, args
88
- page = nokaya.parse_page
89
- img_links = nokaya.get_photonet_album page
90
- save_album img_links, nokaya
97
+ puts Status.wait
98
+ image = Photonet.new(args, options)
99
+ image.save
100
+ puts Status.saved_album(image)
91
101
  end
92
102
 
93
- desc "deviantart", "Get all pictures from a Deviantart gallery (nokaya -dart url)"
103
+ desc "deviantart URL", "Get all pictures from a Deviantart gallery (nokaya -dart url)"
94
104
  map "-dart" => :deviantart
95
105
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
96
106
  def deviantart *args
97
- check_args args
98
- nokaya = Getter.new options, :deviantart, args
99
- page = nokaya.parse_page
100
- img_links = nokaya.get_deviantart page
101
- save_album img_links, nokaya
107
+ puts Status.wait
108
+ image = Deviantart.new(args, options)
109
+ image.save
110
+ puts Status.saved_album(image)
102
111
  end
103
112
 
104
- desc "imageshack_user", "Get all pictures from an Imageshack user gallery (nokaya -ishu url)"
113
+ desc "imageshack_user URL", "Get all pictures from an Imageshack user gallery (nokaya -ishu url)"
105
114
  map "-ishu" => :imageshack_user
106
115
  option :output, aliases: "-o", type: :string, desc: "Specify an output path"
107
116
  def imageshack_user *args
108
- check_args args
109
- nokaya = Getter.new({name: "#{args[0].split("/").last}"}, :imageshack_user, args)
110
- page = nokaya.parse_page
111
- img_links = nokaya.get_imageshack_user page
112
- save_album img_links, nokaya
113
- end
114
-
115
- private
116
-
117
- def basic nokaya
118
- page = nokaya.parse_page
119
- img_link = nokaya.get_basic page
120
- save_pic img_link, nokaya
121
- end
122
-
123
- def check_args args
124
- abort Status.no_url if args.empty?
125
- end
126
-
127
- def download_and_save img_link, nokaya
128
- puts Status.downloading img_link
129
- path = Image.photo_name nokaya
130
- Image.save_image(path, img_link)
131
- puts Status.saved path
132
- end
133
-
134
- def download_album img_links, nokaya
135
- if nokaya.options[:name]
136
- dir = "#{Dir.home}/Downloads/#{nokaya.type}-#{nokaya.options[:name]}"
137
- else
138
- dir = "#{Dir.home}/Downloads/#{nokaya.type}-#{Time.now.to_i}"
139
- end
140
- puts Status.downloading_album dir
141
- Dir.mkdir dir
142
- img_links.each do |link|
143
- parsed = URI.parse link
144
- file = "#{dir}/#{parsed.path.split("/").last}"
145
- puts Status.saving file
146
- Image.save_image(file, link)
147
- end
148
- puts Status.done
149
- end
150
-
151
- def save_pic img_link, nokaya
152
- begin
153
- download_and_save img_link, nokaya
154
- rescue Interrupt
155
- abort Status.canceled
156
- end
157
- end
158
-
159
- def save_album img_links, nokaya
160
- begin
161
- abort Status.no_can_do if img_links.empty?
162
- download_album img_links, nokaya
163
- rescue Interrupt
164
- abort Status.canceled
165
- end
117
+ puts Status.wait
118
+ image = ImageshackUser.new(args, options)
119
+ image.save
120
+ puts Status.saved_album(image)
121
+ end
122
+
123
+ desc "version", "Displays version number and informations"
124
+ map "-v" => :version
125
+ def version
126
+ puts "\nNOKAYA\n\n"
127
+ puts "Version:\t#{VERSION}\n\n"
128
+ puts "Changelog:\thttps://github.com/ericdke/nokaya/blob/master/CHANGELOG.md\n"
129
+ puts "Help:\t\thttps://github.com/ericdke/nokaya/blob/master/README.md\n\n"
166
130
  end
167
131
 
168
132
  end