opendmm 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opendmm.rb +4 -1
- data/lib/opendmm/maker.rb +7 -3
- data/lib/opendmm/search_engines/dmm.rb +62 -0
- data/lib/opendmm/search_engines/jav_library.rb +7 -3
- data/lib/opendmm/version.rb +1 -1
- data/test/fixtures/DMYJ-001.json +20 -0
- data/test/fixtures_test.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd69df580c19412e2d9e73e3cb76beaa9a5aed6c
|
4
|
+
data.tar.gz: 1503a5023206062b73c29cc4de822e68ea08fc38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec6daead86a2b9f0b4a5646ac96ca62acad326f59b39f4c883bfec168c98221e62c3a8276aa495c53c1c99492d3ff81238d50bcb904308e51f0b5bb873ced4d
|
7
|
+
data.tar.gz: 719b561ca21e542a1d64fb49923cbdbb0ef2105781f03fb104beae99730506514f6d2a9a9bb139306e64387c869ece4fea4261873f857e999721dc19c8c60351
|
data/lib/opendmm.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'opendmm/version'
|
2
2
|
require 'opendmm/maker'
|
3
3
|
require 'opendmm/search_engines/jav_library'
|
4
|
+
require 'opendmm/search_engines/dmm'
|
4
5
|
|
5
6
|
module OpenDMM
|
6
7
|
def self.search!(name)
|
7
|
-
details = Maker.search(name) ||
|
8
|
+
details = Maker.search(name) ||
|
9
|
+
SearchEngine::JavLibrary.search(name) ||
|
10
|
+
SearchEngine::Dmm.search(name)
|
8
11
|
return nil unless details
|
9
12
|
details = details.squish_hard
|
10
13
|
if !details[:cover_image].start_with?('http')
|
data/lib/opendmm/maker.rb
CHANGED
@@ -13,6 +13,13 @@ module OpenDMM
|
|
13
13
|
module Site
|
14
14
|
include HTTParty
|
15
15
|
follow_redirects false
|
16
|
+
|
17
|
+
def self.get(uri)
|
18
|
+
super(uri)
|
19
|
+
rescue Errno::ETIMEDOUT => e
|
20
|
+
tries++
|
21
|
+
tries <= 5 ? retry : raise
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
def self.search(name)
|
@@ -57,9 +64,6 @@ module OpenDMM
|
|
57
64
|
return result if result
|
58
65
|
end
|
59
66
|
nil
|
60
|
-
rescue Errno::ETIMEDOUT => e
|
61
|
-
tries++
|
62
|
-
tries <= 5 ? retry : raise
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'opendmm/utils'
|
2
|
+
|
3
|
+
module OpenDMM
|
4
|
+
module SearchEngine
|
5
|
+
module Dmm
|
6
|
+
module Site
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'www.dmm.co.jp'
|
9
|
+
follow_redirects false
|
10
|
+
|
11
|
+
def self.search(name)
|
12
|
+
name = name.split(/[-_\s]/).map do |token|
|
13
|
+
token =~ /\d{1,4}/ ? sprintf("%05d", token.to_i) : token
|
14
|
+
end.join(' ')
|
15
|
+
get("/search/=/searchstr=#{CGI::escape(name)}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get(uri)
|
19
|
+
super(uri)
|
20
|
+
rescue Errno::ETIMEDOUT => e
|
21
|
+
tries++
|
22
|
+
tries <= 5 ? retry : raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Parser
|
27
|
+
def self.parse_search_result(content)
|
28
|
+
html = Nokogiri::HTML(content)
|
29
|
+
first_result = html.css('#list > li > div > p.tmb > a').first
|
30
|
+
first_result['href'] if first_result
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.parse_item(content)
|
34
|
+
page_uri = content.request.last_uri
|
35
|
+
html = Nokogiri::HTML(content)
|
36
|
+
specs = Utils.hash_by_split(html.css('//*[@id="mu"]/div/table/tr/td[1]/table/tr').map(&:text))
|
37
|
+
return {
|
38
|
+
actresses: specs['出演者'].split,
|
39
|
+
code: specs['品番'],
|
40
|
+
cover_image: html.at_css('#sample-video > a')['href'],
|
41
|
+
directors: specs['監督'].split,
|
42
|
+
genres: specs['ジャンル'].split,
|
43
|
+
label: specs['レーベル'],
|
44
|
+
maker: specs['メーカー'],
|
45
|
+
movie_length: specs['収録時間'],
|
46
|
+
page: page_uri.to_s,
|
47
|
+
release_date: specs['商品発売日'],
|
48
|
+
series: specs['シリーズ'],
|
49
|
+
thumbnail_image: html.at_css('#sample-video > a > img')['src'],
|
50
|
+
title: html.css('#title').text,
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.search(name)
|
56
|
+
search_result = Site.search(name)
|
57
|
+
item_uri = Parser.parse_search_result(search_result)
|
58
|
+
Parser.parse_item(Site.get(item_uri)) if item_uri
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -15,6 +15,13 @@ module OpenDMM
|
|
15
15
|
def self.item(id)
|
16
16
|
get("/ja/?v=#{id}")
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.get(uri)
|
20
|
+
super(uri)
|
21
|
+
rescue Errno::ETIMEDOUT => e
|
22
|
+
tries++
|
23
|
+
tries <= 5 ? retry : raise
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
module Parser
|
@@ -52,9 +59,6 @@ module OpenDMM
|
|
52
59
|
jav_id = Parser.parse_search_result(search_result)
|
53
60
|
end
|
54
61
|
Parser.parse_item(Site.item(jav_id)) if jav_id
|
55
|
-
rescue Errno::ETIMEDOUT => e
|
56
|
-
tries++
|
57
|
-
tries <= 5 ? retry : raise
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|
data/lib/opendmm/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"code": "dmyj00001",
|
3
|
+
"cover_image": "http://pics.dmm.co.jp/digital/video/dmyj00001/dmyj00001pl.jpg",
|
4
|
+
"directors": [
|
5
|
+
"三谷任三郎"
|
6
|
+
],
|
7
|
+
"genres": [
|
8
|
+
"看護婦・ナース",
|
9
|
+
"素人",
|
10
|
+
"独占配信",
|
11
|
+
"ハイビジョン"
|
12
|
+
],
|
13
|
+
"maker": "ゲンエキ",
|
14
|
+
"movie_length": 7140,
|
15
|
+
"page": "http://www.dmm.co.jp/digital/videoa/-/detail/=/cid=dmyj00001/",
|
16
|
+
"release_date": "2012-10-12",
|
17
|
+
"series": "素人娘にお願いしました。",
|
18
|
+
"thumbnail_image": "http://pics.dmm.co.jp/digital/video/dmyj00001/dmyj00001ps.jpg",
|
19
|
+
"title": "素人娘にお願いしました 19歳介護士"
|
20
|
+
}
|
data/test/fixtures_test.rb
CHANGED
@@ -63,7 +63,7 @@ Dir[File.dirname(__FILE__) + '/fixtures/*.json'].each do |path|
|
|
63
63
|
class FixtureTest
|
64
64
|
def test_#{name.parameterize.underscore}
|
65
65
|
expected = load_product('#{path}')
|
66
|
-
actual = OpenDMM.search('#{name}')
|
66
|
+
actual = OpenDMM.search!('#{name}')
|
67
67
|
assert_has_basic_keys(actual)
|
68
68
|
assert_no_unknown_keys(actual)
|
69
69
|
assert_equal expected, actual, HashDiff.diff(expected, actual)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opendmm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun Zhou
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/opendmm/makers/tameikegoro.rb
|
156
156
|
- lib/opendmm/makers/to_satsu.rb
|
157
157
|
- lib/opendmm/makers/waap.rb
|
158
|
+
- lib/opendmm/search_engines/dmm.rb
|
158
159
|
- lib/opendmm/search_engines/jav_library.rb
|
159
160
|
- lib/opendmm/utils.rb
|
160
161
|
- lib/opendmm/version.rb
|
@@ -190,6 +191,7 @@ files:
|
|
190
191
|
- test/fixtures/Carib 021511-620.json
|
191
192
|
- test/fixtures/DCOL-017.json
|
192
193
|
- test/fixtures/DGL-007.json
|
194
|
+
- test/fixtures/DMYJ-001.json
|
193
195
|
- test/fixtures/DOM-045.json
|
194
196
|
- test/fixtures/EBOD-109.json
|
195
197
|
- test/fixtures/ECB-078.json
|
@@ -350,6 +352,7 @@ test_files:
|
|
350
352
|
- test/fixtures/Carib 021511-620.json
|
351
353
|
- test/fixtures/DCOL-017.json
|
352
354
|
- test/fixtures/DGL-007.json
|
355
|
+
- test/fixtures/DMYJ-001.json
|
353
356
|
- test/fixtures/DOM-045.json
|
354
357
|
- test/fixtures/EBOD-109.json
|
355
358
|
- test/fixtures/ECB-078.json
|