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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70f8a97358a21d14ebfa0cbcce2d4dd08e4c12223d394ead8174f6874bbeeb8c
4
- data.tar.gz: 9d0df9b68285aacc51c39aed01f0fd7487f785f12ec15bdef29da8112a4fecfa
3
+ metadata.gz: 1186bb7655526c736a939aeb00cfe94f190ea11925cad0f2c811fefbf975e999
4
+ data.tar.gz: fd7e144ab110317bd25ff906ec8ff123daaa8e8d0dc7d076832c1d21d1833f72
5
5
  SHA512:
6
- metadata.gz: 3b8319b43b3145760425f0dd9d8332ee4d3c07a56bea50a0c6c0c3886023e2dd29792f3c168bd41a1d245d5a335fae3fca071d26cd92bdabf1676c0ce098abdd
7
- data.tar.gz: aa6b08c01618600273470c1d2c689b68cd87dd61cc2be8806e2b35a6fe30709f547b907994d746bb4446415da911db6df65a71fea2b50bbed06525bc6ecb7df9
6
+ metadata.gz: ed44e62e644e8bbec16626375bc9e70ecec33d33f43a7c1003d7124a2e38187123a24650d4931c176e53d7e439b3dda39cdad5d95fae64108504ec22f1d4543e
7
+ data.tar.gz: d25f8220a262b0d57abe7ef40e8a3173355c5a424b13888da04ea63bc26a0d14c27d70e095951053b66d5b7a4327247aada1cc6da5a46dc53566299a256f1d1f
@@ -0,0 +1,15 @@
1
+ require_relative "../lib/nx-douban-movie"
2
+ require "pp"
3
+
4
+ class App
5
+ def initialize
6
+ @dbm = Nx::DoubanMovie.new "https://movie.douban.com/subject/30238963"
7
+ end
8
+
9
+ def start
10
+ pp @dbm.to_h
11
+ end
12
+ end
13
+
14
+ app = App.new
15
+ app.start
@@ -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
- el = @info_list.find do |item|
41
- item.text.include? "导演"
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
- protected
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
@@ -1,5 +1,5 @@
1
1
  module Nx
2
2
  class DoubanMovie
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -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.2
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-16 00:00:00.000000000 Z
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