nx-douban-movie 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/__tests__/index.rb +15 -0
- data/lib/nx/douban-movie.rb +50 -4
- data/lib/nx/version.rb +1 -1
- data/package.json +3 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1186bb7655526c736a939aeb00cfe94f190ea11925cad0f2c811fefbf975e999
|
4
|
+
data.tar.gz: fd7e144ab110317bd25ff906ec8ff123daaa8e8d0dc7d076832c1d21d1833f72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed44e62e644e8bbec16626375bc9e70ecec33d33f43a7c1003d7124a2e38187123a24650d4931c176e53d7e439b3dda39cdad5d95fae64108504ec22f1d4543e
|
7
|
+
data.tar.gz: d25f8220a262b0d57abe7ef40e8a3173355c5a424b13888da04ea63bc26a0d14c27d70e095951053b66d5b7a4327247aada1cc6da5a46dc53566299a256f1d1f
|
data/__tests__/index.rb
ADDED
data/lib/nx/douban-movie.rb
CHANGED
@@ -23,6 +23,43 @@ module Nx
|
|
23
23
|
el.text
|
24
24
|
end
|
25
25
|
|
26
|
+
# 豆瓣成员常用的标签
|
27
|
+
def tags
|
28
|
+
els = @doc.css(".tags .tags-body a")
|
29
|
+
els.map do |el|
|
30
|
+
el.text
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# 演职员
|
35
|
+
def celebrities
|
36
|
+
els = @doc.css("#celebrities .celebrity")
|
37
|
+
els.map do |el|
|
38
|
+
anchor = el.at_css("a")
|
39
|
+
info = el.at_css(".info")
|
40
|
+
|
41
|
+
{
|
42
|
+
title: anchor.attribute("title").value,
|
43
|
+
url: anchor.attribute("href").value,
|
44
|
+
avatar: style_bg(anchor.at_css(".avatar").attribute("style").value),
|
45
|
+
role: info.at_css(".role").text,
|
46
|
+
name: info.at_css(".name").text,
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# 电影评分
|
52
|
+
def rate
|
53
|
+
el = @doc.css('#interest_sectl [property="v:average"]')
|
54
|
+
el.text
|
55
|
+
end
|
56
|
+
|
57
|
+
# 剧情简介
|
58
|
+
def summary
|
59
|
+
el = @doc.css('#link-report [property="v:summary"]')
|
60
|
+
clean_string el.text
|
61
|
+
end
|
62
|
+
|
26
63
|
# 上映年份
|
27
64
|
def year
|
28
65
|
el = @doc.css('#content > h1 span[class="year"]')
|
@@ -37,10 +74,14 @@ module Nx
|
|
37
74
|
|
38
75
|
# 导演
|
39
76
|
def director
|
40
|
-
|
41
|
-
|
77
|
+
els = @doc.css('#info .attrs [rel="v:directedBy"]')
|
78
|
+
els.map do |el|
|
79
|
+
url = el.attribute("href").value
|
80
|
+
{
|
81
|
+
url: "https://movie.douban.com#{url}",
|
82
|
+
name: el.text,
|
83
|
+
}
|
42
84
|
end
|
43
|
-
clean_string el.nil? ? "" : el.next_element.text
|
44
85
|
end
|
45
86
|
|
46
87
|
# 编剧
|
@@ -118,10 +159,15 @@ module Nx
|
|
118
159
|
el.next_element.attribute("href").value
|
119
160
|
end
|
120
161
|
|
121
|
-
|
162
|
+
private
|
122
163
|
|
123
164
|
def clean_string(str)
|
124
165
|
str.strip
|
125
166
|
end
|
167
|
+
|
168
|
+
def style_bg(str)
|
169
|
+
matched = /url\((.*)\)/.match(str)
|
170
|
+
matched.nil? ? "" : matched[1]
|
171
|
+
end
|
126
172
|
end
|
127
173
|
end
|
data/lib/nx/version.rb
CHANGED
data/package.json
CHANGED
@@ -7,9 +7,10 @@
|
|
7
7
|
},
|
8
8
|
"scripts": {
|
9
9
|
"clean": "rm -rf *.gem",
|
10
|
+
"test": "ruby __tests__/index.rb",
|
10
11
|
"build": "gem build *.gemspec",
|
11
12
|
"pubpush": "gem push *.gem",
|
12
|
-
"unpublish":"gem yank nx-douban-movie -v '0.1.1'"
|
13
|
+
"unpublish": "gem yank nx-douban-movie -v '0.1.1'"
|
13
14
|
},
|
14
15
|
"repository": {
|
15
16
|
"type": "git",
|
@@ -21,4 +22,4 @@
|
|
21
22
|
"url": "https://github.com/aric-spider/nx-douban-movie/issues"
|
22
23
|
},
|
23
24
|
"homepage": "https://github.com/aric-spider/nx-douban-movie#readme"
|
24
|
-
}
|
25
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nx-douban-movie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- afeiship
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- Gemfile
|
70
70
|
- README.md
|
71
71
|
- Rakefile
|
72
|
+
- __tests__/index.rb
|
72
73
|
- bin/console
|
73
74
|
- bin/setup
|
74
75
|
- lib/nx-douban-movie.rb
|