opendmm 0.0.3 → 0.0.4
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/.travis.yml +0 -1
- data/lib/opendmm/maker.rb +4 -2
- data/lib/opendmm/makers/candy.rb +8 -1
- data/lib/opendmm/search_engines/jav_library.rb +4 -3
- data/lib/opendmm/utils.rb +26 -44
- data/lib/opendmm/version.rb +1 -1
- data/lib/opendmm.rb +21 -1
- data/test/fixtures/CND-062.json +29 -0
- data/test/fixtures_test.rb +1 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807b507fdae159cc6e2ef1ad1e795944180ee9dd
|
4
|
+
data.tar.gz: 5f04d17817251b805f5fe671b865ef7de792cc84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b5802d38018ace981d8052f31789923a42cdc3ac94ed1caa1e8f26734739e9c1ecb8081f8c878e3b7957e1c4326d75cfaf36af0f8e642ca76f59e8239125552
|
7
|
+
data.tar.gz: bf1baf2b3b73676cf6b50a702561814d92175014408c7e24ad778151bef50416a05df3056355bcc085c2c3fc491f2c6270e302e50d217dddc9cc857109741f79
|
data/.travis.yml
CHANGED
data/lib/opendmm/maker.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/string/filters'
|
2
2
|
require 'httparty'
|
3
|
+
require 'logger'
|
3
4
|
require 'nokogiri'
|
4
5
|
require 'opendmm/utils'
|
5
6
|
|
@@ -51,8 +52,9 @@ module OpenDMM
|
|
51
52
|
return result if result
|
52
53
|
end
|
53
54
|
nil
|
54
|
-
rescue
|
55
|
-
|
55
|
+
rescue Errno::ETIMEDOUT => e
|
56
|
+
tries++
|
57
|
+
tries <= 5 ? retry : raise
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
data/lib/opendmm/makers/candy.rb
CHANGED
@@ -22,7 +22,7 @@ module OpenDMM
|
|
22
22
|
specs = Utils.hash_from_dl(html.css('#actress > div > dl'))
|
23
23
|
return {
|
24
24
|
actresses: specs['出演女優'].css('a').map(&:text),
|
25
|
-
code: specs['品番'].text,
|
25
|
+
code: parse_code(specs['品番'].text),
|
26
26
|
cover_image: html.at_xpath('//*[@id="thumbnail"]/a[1]')['href'],
|
27
27
|
description: html.css('#brand > p.p_actress_detail').text,
|
28
28
|
genres: specs['ジャンル'].css('a').map(&:text),
|
@@ -35,6 +35,13 @@ module OpenDMM
|
|
35
35
|
title: html.css('#brand > div.m_t_4 > h3').text,
|
36
36
|
}
|
37
37
|
end
|
38
|
+
|
39
|
+
def self.parse_code(text)
|
40
|
+
return text unless text.include? '⁄'
|
41
|
+
text.lines.map do |line|
|
42
|
+
line.split '⁄'
|
43
|
+
end.squish_hard.to_h['DVD']
|
44
|
+
end
|
38
45
|
end
|
39
46
|
end
|
40
47
|
end
|
@@ -9,7 +9,7 @@ module OpenDMM
|
|
9
9
|
follow_redirects false
|
10
10
|
|
11
11
|
def self.search(name)
|
12
|
-
get("/ja/vl_searchbyid.php?keyword=#{name}")
|
12
|
+
get("/ja/vl_searchbyid.php?keyword=#{CGI::escape(name)}")
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.item(id)
|
@@ -52,8 +52,9 @@ module OpenDMM
|
|
52
52
|
jav_id = Parser.parse_search_result(search_result)
|
53
53
|
end
|
54
54
|
Parser.parse_item(Site.item(jav_id)) if jav_id
|
55
|
-
rescue
|
56
|
-
|
55
|
+
rescue Errno::ETIMEDOUT => e
|
56
|
+
tries++
|
57
|
+
tries <= 5 ? retry : raise
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
data/lib/opendmm/utils.rb
CHANGED
@@ -69,51 +69,33 @@ module OpenDMM
|
|
69
69
|
$stderr = STDERR
|
70
70
|
content = content.encode('UTF-8', encoding, invalid: :replace, undef: :replace, replace: '')
|
71
71
|
end
|
72
|
+
end
|
73
|
+
end
|
72
74
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
if details[:page]
|
80
|
-
if details[:cover_image] && !details[:cover_image].start_with?('http')
|
81
|
-
details[:cover_image] = URI.join(details[:page], details[:cover_image]).to_s
|
82
|
-
end
|
83
|
-
if details[:sample_images]
|
84
|
-
details[:sample_images] = details[:sample_images].map do |uri|
|
85
|
-
uri.start_with?('http') ? uri : URI.join(details[:page], uri).to_s
|
86
|
-
end
|
87
|
-
end
|
88
|
-
if details[:thumbnail_image] && !details[:thumbnail_image].start_with?('http')
|
89
|
-
details[:thumbnail_image] = URI.join(details[:page], details[:thumbnail_image]).to_s
|
90
|
-
end
|
91
|
-
end
|
92
|
-
if details[:release_date].instance_of? String
|
93
|
-
details[:release_date] = Date.parse(details[:release_date])
|
94
|
-
end
|
95
|
-
details
|
96
|
-
end
|
75
|
+
class Object
|
76
|
+
def squish_hard
|
77
|
+
presence
|
78
|
+
end
|
79
|
+
end
|
97
80
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
81
|
+
class String
|
82
|
+
def squish_hard
|
83
|
+
squish.gsub(/^[\s-]*$/, '').presence
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class Hash
|
88
|
+
def squish_hard
|
89
|
+
map do |k, v|
|
90
|
+
[k, v.squish_hard]
|
91
|
+
end.select do |k_v|
|
92
|
+
k_v.second.present?
|
93
|
+
end.to_h.presence
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class Array
|
98
|
+
def squish_hard
|
99
|
+
map(&:squish_hard).select(&:present?).presence
|
118
100
|
end
|
119
101
|
end
|
data/lib/opendmm/version.rb
CHANGED
data/lib/opendmm.rb
CHANGED
@@ -4,6 +4,26 @@ require 'opendmm/search_engines/jav_library'
|
|
4
4
|
|
5
5
|
module OpenDMM
|
6
6
|
def self.search(name)
|
7
|
-
|
7
|
+
details = Maker.search(name) || SearchEngine::JavLibrary.search(name)
|
8
|
+
return nil unless details
|
9
|
+
details = details.squish_hard
|
10
|
+
if !details[:cover_image].start_with?('http')
|
11
|
+
details[:cover_image] = URI.join(details[:page], details[:cover_image]).to_s
|
12
|
+
end
|
13
|
+
if !details[:thumbnail_image].start_with?('http')
|
14
|
+
details[:thumbnail_image] = URI.join(details[:page], details[:thumbnail_image]).to_s
|
15
|
+
end
|
16
|
+
if details[:sample_images]
|
17
|
+
details[:sample_images] = details[:sample_images].map do |uri|
|
18
|
+
uri.start_with?('http') ? uri : URI.join(details[:page], uri).to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
if details[:movie_length].instance_of? String
|
22
|
+
details[:movie_length] = ChronicDuration.parse(details[:movie_length])
|
23
|
+
end
|
24
|
+
if details[:release_date].instance_of? String
|
25
|
+
details[:release_date] = Date.parse(details[:release_date])
|
26
|
+
end
|
27
|
+
details
|
8
28
|
end
|
9
29
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"actresses": [
|
3
|
+
"鈴木心湖"
|
4
|
+
],
|
5
|
+
"code": "CND-062",
|
6
|
+
"cover_image": "http://candy-av.com/images/works/cnd062/cnd062pl.jpg",
|
7
|
+
"description": "絶対美少女シリーズ、今月の新人は奇跡の透明感を持つ純白美肌の鈴木心湖!まさに容姿端麗、18歳とは思えない洗練された美しさの彼女は見た目の完成度だけでなく性格もとってもハートフル!時おり見せるあどけない表情や仕草と完成された容姿のギャップがたまりません!",
|
8
|
+
"genres": [
|
9
|
+
"デビュー作品"
|
10
|
+
],
|
11
|
+
"movie_length": 7200,
|
12
|
+
"page": "http://candy-av.com/works/-/detail/=/cid=cnd062",
|
13
|
+
"release_date": "2013-10-01",
|
14
|
+
"sample_images": [
|
15
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-01.jpg",
|
16
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-02.jpg",
|
17
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-03.jpg",
|
18
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-04.jpg",
|
19
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-05.jpg",
|
20
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-06.jpg",
|
21
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-07.jpg",
|
22
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-08.jpg",
|
23
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-09.jpg",
|
24
|
+
"http://candy-av.com/images/works/cnd062/cnd062jp-10.jpg"
|
25
|
+
],
|
26
|
+
"thumbnail_image": "http://candy-av.com/images/works/cnd062/cnd062pm.jpg",
|
27
|
+
"series": "絶・対・美・少・女",
|
28
|
+
"title": "絶・対・美・少・女 奇跡の純白透明感 AVデビュー 鈴木心湖(18歳)"
|
29
|
+
}
|
data/test/fixtures_test.rb
CHANGED
@@ -17,7 +17,7 @@ class FixtureTest < Minitest::Test
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def assert_has_basic_keys(product)
|
20
|
-
%i(code title thumbnail_image cover_image).each do |key|
|
20
|
+
%i(code title thumbnail_image cover_image page).each do |key|
|
21
21
|
assert product[key], "Key #{key} should not be absent"
|
22
22
|
end
|
23
23
|
end
|
@@ -67,8 +67,6 @@ class FixtureTest
|
|
67
67
|
assert_has_basic_keys(actual)
|
68
68
|
assert_no_unknown_keys(actual)
|
69
69
|
assert_equal expected, actual, HashDiff.diff(expected, actual)
|
70
|
-
rescue Errno::ETIMEDOUT => e
|
71
|
-
raise unless ENV['GFW_MODE']
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opendmm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun Zhou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- test/fixtures/CHS-015.json
|
186
186
|
- test/fixtures/CLUB-003.json
|
187
187
|
- test/fixtures/CND-012.json
|
188
|
+
- test/fixtures/CND-062.json
|
188
189
|
- test/fixtures/CWM-156.json
|
189
190
|
- test/fixtures/Carib 021511-620.json
|
190
191
|
- test/fixtures/DCOL-017.json
|
@@ -344,6 +345,7 @@ test_files:
|
|
344
345
|
- test/fixtures/CHS-015.json
|
345
346
|
- test/fixtures/CLUB-003.json
|
346
347
|
- test/fixtures/CND-012.json
|
348
|
+
- test/fixtures/CND-062.json
|
347
349
|
- test/fixtures/CWM-156.json
|
348
350
|
- test/fixtures/Carib 021511-620.json
|
349
351
|
- test/fixtures/DCOL-017.json
|