comic_walker 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -0
- data/lib/comic_walker/cli.rb +6 -2
- data/lib/comic_walker/client/license.rb +13 -2
- data/lib/comic_walker/item_decoder.rb +11 -4
- data/lib/comic_walker/version.rb +2 -2
- 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: 31c86d5ee6917c1d2443b444ad0af64ea30312b7
|
4
|
+
data.tar.gz: ad9a19cdaba4cc3ef9e78caaf4283e1024e25e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484678c62454decd50c4153b0f3b9f2ab5e018f4cf08d26ffa61196a3d3132968a1c6cf09df458aef884a179874936c90e4d3a5fdadcb18989eaee0b83d56034
|
7
|
+
data.tar.gz: 0265eec741fde6d0d8a647d4023ab5578e66d3e6917341295fa5fe53c8d414606965a12225da895d2dedb9bdad3c688555b2be4cf54f4d16c5358e368de2ccce
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# ComicWalker
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/comic_walker.svg)](http://badge.fury.io/rb/comic_walker)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/eagletmt/comic_walker.png)](https://codeclimate.com/github/eagletmt/comic_walker)
|
3
4
|
|
4
5
|
Client library for [ComicWalker](http://comic-walker.com/).
|
5
6
|
|
data/lib/comic_walker/cli.rb
CHANGED
@@ -101,11 +101,15 @@ module ComicWalker
|
|
101
101
|
img_dir = Pathname.new(title).join(cid).tap(&:mkpath)
|
102
102
|
decoder.pages.each.with_index do |file, i|
|
103
103
|
dat_path = Pathname.new(file).join('0.dat')
|
104
|
-
data = items[dat_path.to_s]
|
105
104
|
img_fname = dat_path.parent.basename.sub_ext('.jpg')
|
106
105
|
img_path = img_dir.join(sprintf('%03d_%s', i, img_fname))
|
106
|
+
|
107
|
+
if data = items[dat_path.to_s]
|
108
|
+
decoder.decode_b64(file, dat_path, img_path, data)
|
109
|
+
else
|
110
|
+
decoder.decode(file, dat_path, img_path, license.get_jpeg(file))
|
111
|
+
end
|
107
112
|
puts "#{dat_path} -> #{img_path}"
|
108
|
-
decoder.decode(file, dat_path, img_path, data)
|
109
113
|
end
|
110
114
|
end
|
111
115
|
end
|
@@ -15,11 +15,15 @@ module ComicWalker
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def jar_url
|
18
|
-
|
18
|
+
url_prefix + agreement['jar_file_name']
|
19
19
|
end
|
20
20
|
|
21
21
|
def info_url
|
22
|
-
|
22
|
+
url_prefix + agreement['info_file_name']
|
23
|
+
end
|
24
|
+
|
25
|
+
def url_prefix
|
26
|
+
agreement['url_prefix']
|
23
27
|
end
|
24
28
|
|
25
29
|
def key
|
@@ -41,6 +45,13 @@ module ComicWalker
|
|
41
45
|
end
|
42
46
|
JSON.parse(body)
|
43
47
|
end
|
48
|
+
|
49
|
+
def get_jpeg(file)
|
50
|
+
uri = Addressable::URI.parse(url_prefix + file + '/0.jpeg')
|
51
|
+
Net::HTTP.start(uri.host) do |http|
|
52
|
+
http.get(uri.request_uri).body
|
53
|
+
end
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
@@ -5,11 +5,15 @@ module ComicWalker
|
|
5
5
|
class ItemDecoder
|
6
6
|
attr_reader :pages
|
7
7
|
|
8
|
+
DEFAULT_CT = '20000101000000'
|
9
|
+
DEFAULT_ST = '20000101000000'
|
10
|
+
DEFAULT_ET = '99991231235959'
|
11
|
+
|
8
12
|
def initialize(configuration_pack)
|
9
13
|
fname = '0.dat'
|
10
|
-
ct = configuration_pack['ct']
|
11
|
-
st = configuration_pack['st']
|
12
|
-
et = configuration_pack['et']
|
14
|
+
ct = configuration_pack['ct'] || DEFAULT_CT
|
15
|
+
st = configuration_pack['st'] || DEFAULT_ST
|
16
|
+
et = configuration_pack['et'] || DEFAULT_ET
|
13
17
|
@key1 = (ct + st + fname).unpack('C*')
|
14
18
|
@key2 = (ct + fname + et).unpack('C*')
|
15
19
|
@key3 = (fname + st + et).unpack('C*')
|
@@ -23,7 +27,7 @@ module ComicWalker
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
def
|
30
|
+
def decode_b64(file, dat_path, img_path, b64data)
|
27
31
|
bs = 128
|
28
32
|
hs = 1024
|
29
33
|
blob = Unknown.finish(@key1, hs,
|
@@ -33,7 +37,10 @@ module ComicWalker
|
|
33
37
|
)
|
34
38
|
)
|
35
39
|
).pack('C*')
|
40
|
+
decode(file, dat_path, img_path, blob)
|
41
|
+
end
|
36
42
|
|
43
|
+
def decode(file, dat_path, img_path, blob)
|
37
44
|
src = Magick::Image.from_blob(blob).first
|
38
45
|
width = src.columns
|
39
46
|
height = src.rows
|
data/lib/comic_walker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comic_walker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|