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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5646a3638227e1b696661c58537f21f48926e7e0
4
- data.tar.gz: 1ea10251f189d22034f22211356c8c967d1accb9
3
+ metadata.gz: 6985d09e755b7294192bd3fb1d9cce5bebbd52dd
4
+ data.tar.gz: f676103539dd16afdf05b19f4eb49e1eb0de0842
5
5
  SHA512:
6
- metadata.gz: 81b81cb5ecab76f20eeceb06023edfdecd3bec4853ae6a8cac79431ae5007905d8932965886e1f6893a6a9aea73c331ff55120d505fcc1b0687f528de31599de
7
- data.tar.gz: 7cc6227bf90507711dfaf9db744b13955660db29e5f405bc619e6e62dee190e90a561f630b364f868c28acfefc89d019bd644387038a189e20bab9342aa62369
6
+ metadata.gz: f7e328b236b8122cffa290b034ddc3d32fecae9910b61013e1e3b95a79775fd9386d4caa369254d75a12284236da86ac2f4e75ca1b4e84ef867a98cc90af9831
7
+ data.tar.gz: 1d5b06cd7ca6a5208e3ae6ba3d4c17a0ca42b383b19a342a9d9473bb3c9eea37109af94c456d80300231d74c134ffb35a8cb280085e198c8344257dd13cec473
@@ -1,6 +1,5 @@
1
1
  require 'nokogiri'
2
- require 'net/http'
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
- chapter = @uri.to_s[/\/([^\/]*)\/?$/, 1]
15
- doc = Nokogiri::HTML(Net::HTTP.get(@uri))
16
- @js_uri = URI.join(@uri, doc.at_css("script[src*=\"#{chapter}.js\"]")['src'])
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
- cxt = V8::Context.new
22
- cxt.eval(Net::HTTP.get(js_uri))
23
- @hosts = cxt['hosts']
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 &:join
43
+ threads.each(&:join)
46
44
  end
47
45
  end
48
46
  end
@@ -4,14 +4,22 @@ require 'thor'
4
4
 
5
5
  module Sfacg
6
6
  class Cli < Thor
7
- desc 'comic URL', 'Download a comic, ex: http://comic.sfacg.com/HTML/JJDJR/'
8
- option :to, default: '.'
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, ex: http://comic.sfacg.com/HTML/JJDJR/056/'
14
- option :to, default: '.'
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
@@ -1,3 +1,3 @@
1
1
  module Sfacg
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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.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-06-26 00:00:00.000000000 Z
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.3.0
74
+ rubygems_version: 2.4.1
89
75
  signing_key:
90
76
  specification_version: 4
91
77
  summary: sfacg comic downloader