sfacg 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sfacg/chapter.rb +8 -10
- data/lib/sfacg/cli.rb +12 -4
- data/lib/sfacg/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6985d09e755b7294192bd3fb1d9cce5bebbd52dd
|
4
|
+
data.tar.gz: f676103539dd16afdf05b19f4eb49e1eb0de0842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7e328b236b8122cffa290b034ddc3d32fecae9910b61013e1e3b95a79775fd9386d4caa369254d75a12284236da86ac2f4e75ca1b4e84ef867a98cc90af9831
|
7
|
+
data.tar.gz: 1d5b06cd7ca6a5208e3ae6ba3d4c17a0ca42b383b19a342a9d9473bb3c9eea37109af94c456d80300231d74c134ffb35a8cb280085e198c8344257dd13cec473
|
data/lib/sfacg/chapter.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
-
require '
|
3
|
-
require 'therubyracer'
|
2
|
+
require 'open-uri'
|
4
3
|
require 'fileutils'
|
5
4
|
|
6
5
|
module Sfacg
|
@@ -11,17 +10,16 @@ module Sfacg
|
|
11
10
|
|
12
11
|
def js_uri
|
13
12
|
return @js_uri if @js_uri
|
14
|
-
|
15
|
-
doc = Nokogiri::HTML(
|
16
|
-
@js_uri =
|
13
|
+
chapter_number = @uri.to_s[/\/([^\/]*)\/?$/, 1]
|
14
|
+
doc = Nokogiri::HTML(open(@uri))
|
15
|
+
@js_uri = @uri.merge(doc.at_css("script[src*=\"#{chapter_number}.js\"]")['src'])
|
17
16
|
end
|
18
17
|
|
19
18
|
def images
|
20
19
|
return @images if @images
|
21
|
-
|
22
|
-
|
23
|
-
@
|
24
|
-
@images = cxt['picAy'].map{|path| URI.join(@hosts.first, path)}
|
20
|
+
js = open(js_uri).read
|
21
|
+
@hosts = js[/hosts\s*=\s*\[([^\]]*)\]/, 1].gsub(/[\s"']/, '').split(',')
|
22
|
+
@images = js.scan(/picAy\[\d+\]\s*=\s*"([^"]*)"/).map{|pattern| URI.join(@hosts.first, pattern.first)}
|
25
23
|
end
|
26
24
|
|
27
25
|
def download to: '.'
|
@@ -42,7 +40,7 @@ module Sfacg
|
|
42
40
|
end
|
43
41
|
}
|
44
42
|
end
|
45
|
-
threads.each
|
43
|
+
threads.each(&:join)
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
data/lib/sfacg/cli.rb
CHANGED
@@ -4,14 +4,22 @@ require 'thor'
|
|
4
4
|
|
5
5
|
module Sfacg
|
6
6
|
class Cli < Thor
|
7
|
-
desc 'comic URL', 'Download a comic
|
8
|
-
|
7
|
+
desc 'comic URL', 'Download a comic'
|
8
|
+
long_desc <<-EOS
|
9
|
+
Download a comic:
|
10
|
+
\x5 $ sfacg chapter http://comic.sfacg.com/HTML/JJDJR/ --to /tmp
|
11
|
+
EOS
|
12
|
+
option :to, default: '.', banner: '<dir>', desc: 'Where to save.'
|
9
13
|
def comic url
|
10
14
|
Comic.new(url).download to: options[:to]
|
11
15
|
end
|
12
16
|
|
13
|
-
desc 'chapter URL', 'Download a chapter
|
14
|
-
|
17
|
+
desc 'chapter URL', 'Download a chapter'
|
18
|
+
long_desc <<-EOS
|
19
|
+
Download a chapter:
|
20
|
+
\x5 $ sfacg chapter http://comic.sfacg.com/HTML/JJDJR/056/ --to /tmp
|
21
|
+
EOS
|
22
|
+
option :to, default: '.', banner: '<dir>', desc: 'Where to save.'
|
15
23
|
def chapter url
|
16
24
|
Chapter.new(url).download to: options[:to]
|
17
25
|
end
|
data/lib/sfacg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfacg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Jian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: therubyracer
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: nokogiri
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
71
|
version: '0'
|
86
72
|
requirements: []
|
87
73
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
74
|
+
rubygems_version: 2.4.1
|
89
75
|
signing_key:
|
90
76
|
specification_version: 4
|
91
77
|
summary: sfacg comic downloader
|