nokaya 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +26 -0
- data/lib/nokaya/app.rb +10 -0
- data/lib/nokaya/getter.rb +15 -0
- data/lib/nokaya/image.rb +18 -3
- data/lib/nokaya/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f31b2704253ab50e0843244c13b03c6c0610a20
|
4
|
+
data.tar.gz: 5813f6bf4336a993604b8bcdb3e3ae7d1b0ed173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 993d92e4409efc6f832109092737213023ae367a4fc5c969de362c8db2101bf70a3828ea29119149118f9623e1479eb0cf59abfb95106271ede1805e64f5e0af
|
7
|
+
data.tar.gz: 7d64dac6459b889d3e2dbeeda91f9466dd00b3ccc2a6a4e9768490bb14e16cba5c506ce0c01ffdc0b26cfb9a0cac7d29bd86df34f4bd9c5fb286aaa451a0a1ca
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -127,3 +127,29 @@ Example:
|
|
127
127
|
`nokaya adn https://photos.app.net/30055986/1`
|
128
128
|
|
129
129
|
`nokaya adn https://photos.app.net/30055986/1 -n random`
|
130
|
+
|
131
|
+
## Options
|
132
|
+
|
133
|
+
### Name
|
134
|
+
|
135
|
+
`--name` or `-n`
|
136
|
+
|
137
|
+
Specify a name (without extension).
|
138
|
+
|
139
|
+
`nokaya -i http://instagram.com/p/noANAfjJ7B/ -n happy_dog`
|
140
|
+
|
141
|
+
### Output
|
142
|
+
|
143
|
+
`--output` or `-o`
|
144
|
+
|
145
|
+
Specify an output path.
|
146
|
+
|
147
|
+
`nokaya -i http://instagram.com/p/noANAfjJ7B/ -o ~/Pics`
|
148
|
+
|
149
|
+
The picture(s) will be downloaded in '~/Downloads' if no output specified.
|
150
|
+
|
151
|
+
### Both
|
152
|
+
|
153
|
+
Specify both.
|
154
|
+
|
155
|
+
`nokaya -i http://instagram.com/p/noANAfjJ7B/ -o ~/Pics -n happy_dog`
|
data/lib/nokaya/app.rb
CHANGED
@@ -9,6 +9,7 @@ module Nokaya
|
|
9
9
|
desc "instagram", "Get the original picture from an Instagram page (nokaya -i url)"
|
10
10
|
map "-i" => :instagram
|
11
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"
|
12
13
|
def instagram *args
|
13
14
|
check_args args
|
14
15
|
nokaya = Getter.new options, :instagram, args
|
@@ -17,6 +18,7 @@ module Nokaya
|
|
17
18
|
|
18
19
|
desc "favd", 'Get the picture from a Favd page (nokaya favd url)'
|
19
20
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
21
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
20
22
|
def favd *args
|
21
23
|
check_args args
|
22
24
|
nokaya = Getter.new options, :favd, args
|
@@ -27,6 +29,7 @@ module Nokaya
|
|
27
29
|
|
28
30
|
desc "adn", "Get the picture from a photos.app.net page (nokaya adn url)"
|
29
31
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
32
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
30
33
|
def adn *args
|
31
34
|
check_args args
|
32
35
|
nokaya = Getter.new options, :adn, args
|
@@ -36,6 +39,7 @@ module Nokaya
|
|
36
39
|
desc "tumblr", "Get the picture from a Tumblr post (nokaya -tu url)"
|
37
40
|
map "-tu" => :tumblr
|
38
41
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
42
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
39
43
|
def tumblr *args
|
40
44
|
check_args args
|
41
45
|
nokaya = Getter.new options, :tumblr, args
|
@@ -44,6 +48,7 @@ module Nokaya
|
|
44
48
|
|
45
49
|
desc "tumblr_album", "Get all pictures from a Tumblr page (nokaya -tal url)"
|
46
50
|
map "-tal" => :tumblr_album
|
51
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
47
52
|
def tumblr_album *args
|
48
53
|
check_args args
|
49
54
|
nokaya = Getter.new options, :tumblr_album, args
|
@@ -54,6 +59,7 @@ module Nokaya
|
|
54
59
|
|
55
60
|
desc "imgur_album", "Get all pictures from an Imgur album (nokaya -ial url)"
|
56
61
|
map "-ial" => :imgur_album
|
62
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
57
63
|
def imgur_album *args
|
58
64
|
check_args args
|
59
65
|
nokaya = Getter.new options, :imgur_album, args
|
@@ -64,6 +70,7 @@ module Nokaya
|
|
64
70
|
|
65
71
|
desc "flickr_album", "Get all pictures from a Flickr album (nokaya -fal url)"
|
66
72
|
map "-fal" => :flickr_album
|
73
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
67
74
|
def flickr_album *args
|
68
75
|
check_args args
|
69
76
|
nokaya = Getter.new options, :flickr_album, args
|
@@ -74,6 +81,7 @@ module Nokaya
|
|
74
81
|
|
75
82
|
desc "photonet", "Get all pictures from a Photo.net page (nokaya -pnet url)"
|
76
83
|
map "-pnet" => :photonet
|
84
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
77
85
|
def photonet *args
|
78
86
|
check_args args
|
79
87
|
nokaya = Getter.new options, :photonet, args
|
@@ -84,6 +92,7 @@ module Nokaya
|
|
84
92
|
|
85
93
|
desc "deviantart", "Get all pictures from a Deviantart gallery (nokaya -dart url)"
|
86
94
|
map "-dart" => :deviantart
|
95
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
87
96
|
def deviantart *args
|
88
97
|
check_args args
|
89
98
|
nokaya = Getter.new options, :deviantart, args
|
@@ -94,6 +103,7 @@ module Nokaya
|
|
94
103
|
|
95
104
|
desc "imageshack_user", "Get all pictures from an Imageshack user gallery (nokaya -ishu url)"
|
96
105
|
map "-ishu" => :imageshack_user
|
106
|
+
option :output, aliases: "-o", type: :string, desc: "Specify an output path"
|
97
107
|
def imageshack_user *args
|
98
108
|
check_args args
|
99
109
|
nokaya = Getter.new({name: "#{args[0].split("/").last}"}, :imageshack_user, args)
|
data/lib/nokaya/getter.rb
CHANGED
@@ -1,33 +1,42 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Nokaya
|
3
3
|
class Getter
|
4
|
+
|
4
5
|
def initialize *args
|
5
6
|
@args = OpenStruct.new options: args[0], type: args[1], url: args[2][0]
|
6
7
|
end
|
8
|
+
|
7
9
|
def args
|
8
10
|
@args.inspect
|
9
11
|
end
|
12
|
+
|
10
13
|
def options
|
11
14
|
@args.options
|
12
15
|
end
|
16
|
+
|
13
17
|
def type
|
14
18
|
@args.type
|
15
19
|
end
|
20
|
+
|
16
21
|
def url
|
17
22
|
@args.url
|
18
23
|
end
|
24
|
+
|
19
25
|
def get_basic page
|
20
26
|
page.xpath("//meta[@property='og:image']/@content").first
|
21
27
|
end
|
28
|
+
|
22
29
|
def get_favd page
|
23
30
|
page.css('#largeImage')[0]['src']
|
24
31
|
end
|
32
|
+
|
25
33
|
def get_deviantart page
|
26
34
|
refs = page.css('a.thumb')
|
27
35
|
links = []
|
28
36
|
refs.each {|li| links << li['data-super-img']}
|
29
37
|
links
|
30
38
|
end
|
39
|
+
|
31
40
|
def get_imageshack_user page
|
32
41
|
refs = page.css('a.hero-wrapper')
|
33
42
|
temp = []
|
@@ -42,12 +51,14 @@ module Nokaya
|
|
42
51
|
end
|
43
52
|
links
|
44
53
|
end
|
54
|
+
|
45
55
|
def get_imgur_album page
|
46
56
|
refs = page.css('#imagelist .posts .post a')
|
47
57
|
links = []
|
48
58
|
refs.each {|l| links << "http:#{l['href']}"}
|
49
59
|
links
|
50
60
|
end
|
61
|
+
|
51
62
|
def get_tumblr_album page
|
52
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']
|
53
64
|
queries.each do |query|
|
@@ -64,12 +75,14 @@ module Nokaya
|
|
64
75
|
end
|
65
76
|
links
|
66
77
|
end
|
78
|
+
|
67
79
|
def get_flickr_album page
|
68
80
|
refs = page.css('.pc_img')
|
69
81
|
links = []
|
70
82
|
refs.each {|l| links << l['data-defer-src']}
|
71
83
|
links
|
72
84
|
end
|
85
|
+
|
73
86
|
def get_photonet_album page
|
74
87
|
refs = page.css '.trp-top a'
|
75
88
|
links = []
|
@@ -78,8 +91,10 @@ module Nokaya
|
|
78
91
|
end
|
79
92
|
links
|
80
93
|
end
|
94
|
+
|
81
95
|
def parse_page
|
82
96
|
Nokogiri::HTML(open @args.url)
|
83
97
|
end
|
98
|
+
|
84
99
|
end
|
85
100
|
end
|
data/lib/nokaya/image.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Nokaya
|
3
3
|
class Image
|
4
|
+
|
4
5
|
def self.photo_name nokaya
|
5
|
-
|
6
|
-
|
6
|
+
path = self.out nokaya
|
7
|
+
if nokaya.options[:name]
|
8
|
+
"#{path}/#{nokaya.type.to_s}-#{nokaya.options[:name]}.jpg"
|
7
9
|
else
|
8
|
-
|
10
|
+
"#{path}/#{nokaya.type.to_s}-#{Time.now.to_i}.jpg"
|
9
11
|
end
|
10
12
|
end
|
13
|
+
|
11
14
|
def self.save_image path, link
|
12
15
|
content = self.get_image link
|
13
16
|
f = File.new(path, "wb")
|
14
17
|
f.puts(content)
|
15
18
|
f.close
|
16
19
|
end
|
20
|
+
|
17
21
|
def self.get_image img_link
|
18
22
|
begin
|
19
23
|
open(img_link).read
|
@@ -21,5 +25,16 @@ module Nokaya
|
|
21
25
|
abort Status.no_can_do
|
22
26
|
end
|
23
27
|
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def self.out nokaya
|
32
|
+
if nokaya.options[:output]
|
33
|
+
nokaya.options[:output]
|
34
|
+
else
|
35
|
+
Dir.home + "/Downloads"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
24
39
|
end
|
25
40
|
end
|
data/lib/nokaya/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.8
|
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-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|