nokaya 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +19 -5
- data/lib/nokaya/app.rb +51 -45
- data/lib/nokaya/getter.rb +17 -12
- data/lib/nokaya/image.rb +9 -1
- 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: 3a3dcc28605b1fb6c28e8d8bd198c0aacbf58d2c
|
4
|
+
data.tar.gz: 38f1f67e0b46b162860c1f221ccd9be4a115926c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c32b568b79340c2063de1ff6f21ebf6affee813d874c5aeed2e8ba07f27358ce06707440b6ffdc283cd95b88311035a6c7a9863af9ef2f6b0094fa7f7ec4721
|
7
|
+
data.tar.gz: fd25392b2b1e9250769c4366ead047ac529a9f5e1691f422125e14b6d8e71df992e68d9781d22a45b60680741d7154d7957940a4c72f5bea0e65261d479bcdd1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,17 +28,31 @@ Example:
|
|
28
28
|
|
29
29
|
`nokaya -i http://ift.tt/1m2Nvz8 -n pasta`
|
30
30
|
|
31
|
-
### Tumblr
|
31
|
+
### Tumblr post
|
32
32
|
|
33
|
-
`nokaya -
|
33
|
+
`nokaya -tu url`
|
34
34
|
|
35
|
-
`nokaya -
|
35
|
+
`nokaya -tu url -n file_name`
|
36
36
|
|
37
37
|
Example:
|
38
38
|
|
39
|
-
`nokaya -
|
39
|
+
`nokaya -tu http://spacequest.tumblr.com/post/83560738152/sexycomics-carlos-valenzuela`
|
40
40
|
|
41
|
-
`nokaya -
|
41
|
+
`nokaya -tu http://spacequest.tumblr.com/post/83560738152/sexycomics-carlos-valenzuela -n 'girl and monster'`
|
42
|
+
|
43
|
+
### Tumblr page
|
44
|
+
|
45
|
+
Due to the various themes and layouts existing for Tumblr galleries, this feature may not work perfectly...
|
46
|
+
|
47
|
+
Nokaya will try several techniques to extract the image links, then will fallback to scraping all available links if failing at properly detecting photos.
|
48
|
+
|
49
|
+
`nokaya -tal url`
|
50
|
+
|
51
|
+
Example:
|
52
|
+
|
53
|
+
`nokaya -tal http://brekninger.tumblr.com`
|
54
|
+
|
55
|
+
Downloads all images in the page.
|
42
56
|
|
43
57
|
### Imgur album
|
44
58
|
|
data/lib/nokaya/app.rb
CHANGED
@@ -10,94 +10,84 @@ module Nokaya
|
|
10
10
|
map "-i" => :instagram
|
11
11
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
12
12
|
def instagram *args
|
13
|
-
|
13
|
+
check_args args
|
14
14
|
nokaya = Getter.new options, :instagram, args
|
15
|
-
|
16
|
-
img_link = nokaya.get_basic page
|
17
|
-
begin
|
18
|
-
download_and_save img_link, nokaya
|
19
|
-
rescue Interrupt
|
20
|
-
abort Status.canceled
|
21
|
-
end
|
15
|
+
basic nokaya
|
22
16
|
end
|
23
17
|
|
24
18
|
desc "favd", 'Get the photo from a Favd page (nokaya favd url)'
|
25
19
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
26
20
|
def favd *args
|
27
|
-
|
21
|
+
check_args args
|
28
22
|
nokaya = Getter.new options, :favd, args
|
29
23
|
page = nokaya.parse_page
|
30
24
|
img_link = nokaya.get_favd page
|
31
|
-
|
32
|
-
download_and_save img_link, nokaya
|
33
|
-
rescue Interrupt
|
34
|
-
abort Status.canceled
|
35
|
-
end
|
25
|
+
save_pic img_link, nokaya
|
36
26
|
end
|
37
27
|
|
38
28
|
desc "adn", "Get the photo from a photos.app.net page (nokaya adn url)"
|
39
29
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
40
30
|
def adn *args
|
41
|
-
|
31
|
+
check_args args
|
42
32
|
nokaya = Getter.new options, :adn, args
|
43
|
-
|
44
|
-
img_link = nokaya.get_basic page
|
45
|
-
begin
|
46
|
-
download_and_save img_link, nokaya
|
47
|
-
rescue Interrupt
|
48
|
-
abort Status.canceled
|
49
|
-
end
|
33
|
+
basic nokaya
|
50
34
|
end
|
51
35
|
|
52
|
-
desc "tumblr", "Get the photo from a Tumblr
|
53
|
-
map "-
|
36
|
+
desc "tumblr", "Get the photo from a Tumblr post (nokaya -tu url)"
|
37
|
+
map "-tu" => :tumblr
|
54
38
|
option :name, aliases: "-n", type: :string, desc: "Specify a file name without extension"
|
55
39
|
def tumblr *args
|
56
|
-
|
40
|
+
check_args args
|
57
41
|
nokaya = Getter.new options, :tumblr, args
|
42
|
+
basic nokaya
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "tumblr_album", "Get all images from a Tumblr page (nokaya -tal url)"
|
46
|
+
map "-tal" => :tumblr_album
|
47
|
+
def tumblr_album *args
|
48
|
+
check_args args
|
49
|
+
nokaya = Getter.new options, :tumblr_album, args
|
58
50
|
page = nokaya.parse_page
|
59
|
-
|
60
|
-
|
61
|
-
download_and_save img_link, nokaya
|
62
|
-
rescue Interrupt
|
63
|
-
abort Status.canceled
|
64
|
-
end
|
51
|
+
img_links = nokaya.get_tumblr_album page
|
52
|
+
save_album img_links, nokaya
|
65
53
|
end
|
66
54
|
|
67
55
|
desc "imgur_album", "Get all images from an Imgur album (nokaya -ial url)"
|
68
56
|
map "-ial" => :imgur_album
|
69
57
|
def imgur_album *args
|
70
|
-
|
58
|
+
check_args args
|
71
59
|
nokaya = Getter.new options, :imgur_album, args
|
72
60
|
page = nokaya.parse_page
|
73
61
|
img_links = nokaya.get_imgur_album page
|
74
|
-
|
75
|
-
download_album img_links, nokaya
|
76
|
-
rescue Interrupt
|
77
|
-
abort Status.canceled
|
78
|
-
end
|
62
|
+
save_album img_links, nokaya
|
79
63
|
end
|
80
64
|
|
81
65
|
desc "flickr_album", "Get all images from a Flickr album (nokaya -fal url)"
|
82
66
|
map "-fal" => :flickr_album
|
83
67
|
def flickr_album *args
|
84
|
-
|
68
|
+
check_args args
|
85
69
|
nokaya = Getter.new options, :flickr_album, args
|
86
70
|
page = nokaya.parse_page
|
87
71
|
img_links = nokaya.get_flickr_album page
|
88
|
-
|
89
|
-
download_album img_links, nokaya
|
90
|
-
rescue Interrupt
|
91
|
-
abort Status.canceled
|
92
|
-
end
|
72
|
+
save_album img_links, nokaya
|
93
73
|
end
|
94
74
|
|
95
75
|
private
|
96
76
|
|
77
|
+
def basic nokaya
|
78
|
+
page = nokaya.parse_page
|
79
|
+
img_link = nokaya.get_basic page
|
80
|
+
save_pic img_link, nokaya
|
81
|
+
end
|
82
|
+
|
83
|
+
def check_args args
|
84
|
+
abort Status.no_url if args.empty?
|
85
|
+
end
|
86
|
+
|
97
87
|
def download_and_save img_link, nokaya
|
98
88
|
puts Status.downloading img_link
|
99
89
|
path = Image.photo_name nokaya
|
100
|
-
Image.save_image(path,
|
90
|
+
Image.save_image(path, img_link)
|
101
91
|
puts Status.saved path
|
102
92
|
end
|
103
93
|
|
@@ -107,10 +97,26 @@ module Nokaya
|
|
107
97
|
parsed = URI.parse link
|
108
98
|
file = "#{Dir.home}/Downloads/#{parsed.path.split("/").last}"
|
109
99
|
puts Status.saving file
|
110
|
-
Image.save_image(file,
|
100
|
+
Image.save_image(file, link)
|
111
101
|
end
|
112
102
|
puts Status.done
|
113
103
|
end
|
114
104
|
|
105
|
+
def save_pic img_link, nokaya
|
106
|
+
begin
|
107
|
+
download_and_save img_link, nokaya
|
108
|
+
rescue Interrupt
|
109
|
+
abort Status.canceled
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def save_album img_links, nokaya
|
114
|
+
begin
|
115
|
+
download_album img_links, nokaya
|
116
|
+
rescue Interrupt
|
117
|
+
abort Status.canceled
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
115
121
|
end
|
116
122
|
end
|
data/lib/nokaya/getter.rb
CHANGED
@@ -16,13 +16,6 @@ module Nokaya
|
|
16
16
|
def url
|
17
17
|
@args.url
|
18
18
|
end
|
19
|
-
def get_image img_link
|
20
|
-
begin
|
21
|
-
open(img_link).read
|
22
|
-
rescue
|
23
|
-
abort Status.no_can_do
|
24
|
-
end
|
25
|
-
end
|
26
19
|
def get_basic page
|
27
20
|
page.xpath("//meta[@property='og:image']/@content").first
|
28
21
|
end
|
@@ -35,6 +28,22 @@ module Nokaya
|
|
35
28
|
refs.each {|l| links << "http:#{l['href']}"}
|
36
29
|
links
|
37
30
|
end
|
31
|
+
def get_tumblr_album page
|
32
|
+
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', 'img']
|
33
|
+
queries.each do |query|
|
34
|
+
@refs = page.css query
|
35
|
+
next if @refs.empty?
|
36
|
+
break
|
37
|
+
end
|
38
|
+
links = []
|
39
|
+
@refs.each do |l|
|
40
|
+
target = l['src']
|
41
|
+
unless (target == 'reblog.png' || target =~ /statcounter/ || target =~ /impixu/ || target =~ /quantserve/ || target == 'like.png')
|
42
|
+
links << target
|
43
|
+
end
|
44
|
+
end
|
45
|
+
links
|
46
|
+
end
|
38
47
|
def get_flickr_album page
|
39
48
|
refs = page.css('.pc_img')
|
40
49
|
links = []
|
@@ -42,11 +51,7 @@ module Nokaya
|
|
42
51
|
links
|
43
52
|
end
|
44
53
|
def parse_page
|
45
|
-
Nokogiri::HTML
|
46
|
-
end
|
47
|
-
private
|
48
|
-
def get_page_content
|
49
|
-
open @args.url
|
54
|
+
Nokogiri::HTML(open @args.url)
|
50
55
|
end
|
51
56
|
end
|
52
57
|
end
|
data/lib/nokaya/image.rb
CHANGED
@@ -8,10 +8,18 @@ module Nokaya
|
|
8
8
|
Dir.home + "/Downloads/#{nokaya.type.to_s}-#{nokaya.options[:name]}.jpg"
|
9
9
|
end
|
10
10
|
end
|
11
|
-
def self.save_image path,
|
11
|
+
def self.save_image path, link
|
12
|
+
content = self.get_image link
|
12
13
|
f = File.new(path, "wb")
|
13
14
|
f.puts(content)
|
14
15
|
f.close
|
15
16
|
end
|
17
|
+
def self.get_image img_link
|
18
|
+
begin
|
19
|
+
open(img_link).read
|
20
|
+
rescue
|
21
|
+
abort Status.no_can_do
|
22
|
+
end
|
23
|
+
end
|
16
24
|
end
|
17
25
|
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.6
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|