nokaya 0.0.8 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Nokaya
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ module Nokaya
3
+ class Workers
4
+
5
+ attr_accessor :options
6
+
7
+ def initialize options
8
+ @options = options
9
+ end
10
+
11
+ def save object
12
+ if object.image_url.empty?
13
+ abort(Status.no_can_do)
14
+ else
15
+ save_images(object)
16
+ end
17
+ end
18
+
19
+ def save_images object
20
+ # if object.file_name.empty?
21
+ # save_files(object)
22
+ # else
23
+ save_tuples(object)
24
+ # end
25
+ end
26
+
27
+ # def save_files object
28
+ # object.image_url.each do |url|
29
+ # f = File.new("#{object.path}/#{file_name(object)}", "wb")
30
+ # f.puts(get_image(url))
31
+ # f.close
32
+ # end
33
+ # end
34
+
35
+ def save_tuples object
36
+ begin
37
+ tuples = object.image_url.zip(object.file_name)
38
+ Dir.mkdir(object.path) unless Dir.exist?(object.path)
39
+ tuples.each do |url, name|
40
+ f = File.new("#{object.path}/#{name}", "wb")
41
+ f.puts(get_image(url))
42
+ f.close
43
+ end
44
+ rescue Errno::EACCES
45
+ abort(Status.no_access)
46
+ end
47
+ end
48
+
49
+ def get_image img_link
50
+ begin
51
+ open(img_link).read
52
+ rescue SocketError, SystemCallError
53
+ abort(Status.no_cnx)
54
+ rescue Exception
55
+ abort(Status.no_can_do)
56
+ end
57
+ end
58
+
59
+ def path
60
+ if options['output']
61
+ options['output']
62
+ else
63
+ Dir.home + "/Downloads"
64
+ end
65
+ end
66
+
67
+ def sanitize str
68
+ reg = /[~:-;,?!\'&`^=+<>*%()\/"“”’°£$€.…]/
69
+ str.downcase.strip.gsub(reg, '_').split(' ').join('_').squeeze('_')
70
+ end
71
+
72
+ def check_args args
73
+ abort Status.no_url if args.empty?
74
+ return args
75
+ end
76
+
77
+ def timed
78
+ t = Time.now
79
+ "#{t.year}#{'%02d' % t.month}#{'%02d' % t.day}#{'%02d' % t.hour}#{'%02d' % t.min}#{'%02d' % t.sec}"
80
+ end
81
+
82
+ end
83
+ end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Eric Dejonckheere"]
10
10
  spec.email = ["eric@aya.io"]
11
11
  spec.summary = %q{Download photos from several online services.}
12
- spec.description = %q{CLI to download photos from several online services including Instagram, Imgur albums, Flickr albums, Tumblr, App,net, etc. Mac OS X only for the time being.}
12
+ spec.description = %q{CLI to download photos from several online services including Instagram, Imgur albums, Flickr albums, Tumblr, App,net, etc.}
13
13
  spec.homepage = "http://github.com/ericdke/nokaya"
14
14
  spec.license = "MIT"
15
15
 
@@ -19,17 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "thor", "~> 0.18"
22
- spec.add_dependency "rest-client", "~> 1.6"
23
- spec.add_dependency "terminal-table", "~> 1.4"
24
- spec.add_dependency "nokogiri"
22
+ spec.add_dependency "nokogiri", '~> 1.6'
23
+ spec.add_dependency "spotlite", "~> 0.8"
25
24
 
26
25
  spec.add_development_dependency "bundler", "~> 1.6"
27
- spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec"
29
- spec.add_development_dependency "rspec-nc"
30
- spec.add_development_dependency "guard"
31
- spec.add_development_dependency "guard-rspec"
32
- spec.add_development_dependency "pry"
33
- spec.add_development_dependency "pry-remote"
34
- spec.add_development_dependency "pry-nav"
26
+ spec.add_development_dependency "rake", "~> 10.3"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "guard", "~> 2.6"
29
+ spec.add_development_dependency "guard-rspec", "~> 4.3"
35
30
  end
@@ -1,16 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Nokaya::Getter do
4
- describe "#args" do
5
- it 'shows the args' do
6
- obj = Nokaya::Getter.new({}, :instagram, ['http://instagram.com/p/nlUKF9TYEs/'])
7
- expect(obj.args).to eq '#<OpenStruct options={}, type=:instagram, url="http://instagram.com/p/nlUKF9TYEs/">'
8
- end
9
- end
10
- # describe "#get_page" do
11
- # it 'gets the page' do
12
- # obj = Nokaya::Getter.new({}, :instagram, ['http://instagram.com/p/nlUKF9TYEs/'])
13
- # expect(obj.get_page).to eq ''
14
- # end
15
- # end
16
- end
3
+ # describe Nokaya:: do
4
+ # describe "" do
5
+ # it '' do
6
+ # obj = ''
7
+ # expect(obj.args).to eq ''
8
+ # end
9
+ # end
10
+ # end
@@ -1,2 +1 @@
1
- require 'pry'
2
1
  require 'Nokaya'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-15 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rest-client
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
@@ -39,33 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
- name: terminal-table
42
+ name: spotlite
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.4'
47
+ version: '0.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.4'
55
- - !ruby/object:Gem::Dependency
56
- name: nokogiri
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '0.8'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: bundler
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,116 +70,60 @@ dependencies:
84
70
  name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '10.3'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '10.3'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: rspec
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec-nc
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
87
+ - - "~>"
116
88
  - !ruby/object:Gem::Version
117
- version: '0'
89
+ version: '3.0'
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
- - - ">="
94
+ - - "~>"
123
95
  - !ruby/object:Gem::Version
124
- version: '0'
96
+ version: '3.0'
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: guard
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
- - - ">="
101
+ - - "~>"
130
102
  - !ruby/object:Gem::Version
131
- version: '0'
103
+ version: '2.6'
132
104
  type: :development
133
105
  prerelease: false
134
106
  version_requirements: !ruby/object:Gem::Requirement
135
107
  requirements:
136
- - - ">="
108
+ - - "~>"
137
109
  - !ruby/object:Gem::Version
138
- version: '0'
110
+ version: '2.6'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: guard-rspec
141
113
  requirement: !ruby/object:Gem::Requirement
142
114
  requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: pry
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: pry-remote
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: pry-nav
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
115
+ - - "~>"
186
116
  - !ruby/object:Gem::Version
187
- version: '0'
117
+ version: '4.3'
188
118
  type: :development
189
119
  prerelease: false
190
120
  version_requirements: !ruby/object:Gem::Requirement
191
121
  requirements:
192
- - - ">="
122
+ - - "~>"
193
123
  - !ruby/object:Gem::Version
194
- version: '0'
124
+ version: '4.3'
195
125
  description: CLI to download photos from several online services including Instagram,
196
- Imgur albums, Flickr albums, Tumblr, App,net, etc. Mac OS X only for the time being.
126
+ Imgur albums, Flickr albums, Tumblr, App,net, etc.
197
127
  email:
198
128
  - eric@aya.io
199
129
  executables:
@@ -210,11 +140,22 @@ files:
210
140
  - Rakefile
211
141
  - bin/nokaya
212
142
  - lib/nokaya.rb
143
+ - lib/nokaya/adn.rb
213
144
  - lib/nokaya/app.rb
214
- - lib/nokaya/getter.rb
215
- - lib/nokaya/image.rb
145
+ - lib/nokaya/basic.rb
146
+ - lib/nokaya/deviantart.rb
147
+ - lib/nokaya/favd.rb
148
+ - lib/nokaya/flickr_album.rb
149
+ - lib/nokaya/imageshack_user.rb
150
+ - lib/nokaya/imgur_album.rb
151
+ - lib/nokaya/instagram.rb
152
+ - lib/nokaya/movie.rb
153
+ - lib/nokaya/photonet.rb
216
154
  - lib/nokaya/status.rb
155
+ - lib/nokaya/tumblr.rb
156
+ - lib/nokaya/tumblr_album.rb
217
157
  - lib/nokaya/version.rb
158
+ - lib/nokaya/workers.rb
218
159
  - nokaya.gemspec
219
160
  - spec/nokaya_spec.rb
220
161
  - spec/spec_helper.rb
@@ -238,11 +179,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
179
  version: '0'
239
180
  requirements: []
240
181
  rubyforge_project:
241
- rubygems_version: 2.2.2
182
+ rubygems_version: 2.4.1
242
183
  signing_key:
243
184
  specification_version: 4
244
185
  summary: Download photos from several online services.
245
186
  test_files:
246
187
  - spec/nokaya_spec.rb
247
188
  - spec/spec_helper.rb
248
- has_rdoc:
@@ -1,100 +0,0 @@
1
- # encoding: utf-8
2
- module Nokaya
3
- class Getter
4
-
5
- def initialize *args
6
- @args = OpenStruct.new options: args[0], type: args[1], url: args[2][0]
7
- end
8
-
9
- def args
10
- @args.inspect
11
- end
12
-
13
- def options
14
- @args.options
15
- end
16
-
17
- def type
18
- @args.type
19
- end
20
-
21
- def url
22
- @args.url
23
- end
24
-
25
- def get_basic page
26
- page.xpath("//meta[@property='og:image']/@content").first
27
- end
28
-
29
- def get_favd page
30
- page.css('#largeImage')[0]['src']
31
- end
32
-
33
- def get_deviantart page
34
- refs = page.css('a.thumb')
35
- links = []
36
- refs.each {|li| links << li['data-super-img']}
37
- links
38
- end
39
-
40
- def get_imageshack_user page
41
- refs = page.css('a.hero-wrapper')
42
- temp = []
43
- links = []
44
- refs.each {|li| temp << "https://imageshack.com#{li['href']}"}
45
- puts Status.toresolve temp.length
46
- temp.each do |p|
47
- puts Status.resolving p
48
- picpage = Nokogiri::HTML(open p)
49
- ref = picpage.css('figure.image img')
50
- links << "http:#{ref[0]['src']}"
51
- end
52
- links
53
- end
54
-
55
- def get_imgur_album page
56
- refs = page.css('#imagelist .posts .post a')
57
- links = []
58
- refs.each {|l| links << "http:#{l['href']}"}
59
- links
60
- end
61
-
62
- def get_tumblr_album page
63
- queries = ['img.photo', '.post .photo a img', '.entry img', 'article img', '.image img', '.item_content img', 'img.post-image', '.box img', '#allposts img', '.media img', '.wide img', '.big img', '.large img', '.gallery img', '.photos img', '.content img', 'img']
64
- queries.each do |query|
65
- @refs = page.css query
66
- next if @refs.empty?
67
- break
68
- end
69
- links = []
70
- @refs.each do |l|
71
- target = l['src']
72
- unless (target == 'reblog.png' || target =~ /statcounter/ || target =~ /impixu/ || target =~ /quantserve/ || target == 'like.png')
73
- links << target
74
- end
75
- end
76
- links
77
- end
78
-
79
- def get_flickr_album page
80
- refs = page.css('.pc_img')
81
- links = []
82
- refs.each {|l| links << l['data-defer-src']}
83
- links
84
- end
85
-
86
- def get_photonet_album page
87
- refs = page.css '.trp-top a'
88
- links = []
89
- refs.each do |lin|
90
- links << "http://gallery.photo.net/photo/#{lin['href'].split("=").last}-lg.jpg"
91
- end
92
- links
93
- end
94
-
95
- def parse_page
96
- Nokogiri::HTML(open @args.url)
97
- end
98
-
99
- end
100
- end