kinopoisk_parser 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTMzMDliZjMxMmM0M2UzOTM4MDlmM2IwZDI0Yzg3NTY4MTYxZTlmMw==
4
+ NDFiMTk5NjRlZjk2Mjk1NjIyMzhkYWFmYzI2NWQyODgzNTkwOGUxNA==
5
5
  data.tar.gz: !binary |-
6
- YWJmY2Y0YjU0NjdkZTEwZjVlMjI0ODM2NWM4OTAzNDM1NzBhMWQ5NQ==
6
+ NzRmYzQxNjRhODRlNTFlNWQ0ZDE1ZTNiMDA2MzA0NjZhZGM1MGUwZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NmYzMzAwMjM0YTNiMjgxZDhkOGMzYWVjNjU2MTU5ZTFlOWExODA3M2NlNjg3
10
- YmRkOWU4OWYwNDc4NGZjNjYzNDc0NWM5NTZiMDg2NmZlNmZjYTg5YWY1Y2E5
11
- NmVkMDdjYWM1ZTlhMjUwZDMyYjU2MjVkN2Y1YmUwMmQ1NDU4NGY=
9
+ ZTFhZDJlMDY5MTdlMjY3NDE2YjIxMGE0MDc5NDkzYjlhN2NkOTNlYWQxNjBj
10
+ MWJjMDA3MDdhMjFlZjMwZmU1ODk5MzdjMzUwNzgyNTAxZDM1MTU0YzM4MmNi
11
+ MTExZDdmMjFlZTdiYjRlMDViMWNkYTQ3M2Q5YWEyZDQzYzE1NzQ=
12
12
  data.tar.gz: !binary |-
13
- NTBmMzFhZGUxYjk0ZjNkNGIxZjJlNDgxNGZmNWZhNDEwMmFmZTdiOWU3YTA2
14
- YmI1NjYzZDU3NjE1NGFhYTdkYzhlYjhiZmJmMTdkNDJiNmI2ZDcxMTQ1NzJl
15
- NmI4NjU3ZmZiMmRjY2RhY2JlYzNkMjg3ZjFiZDcwYTViYmI0ZTg=
13
+ MjBhNWFiZGQ2MjRiZDE5MGUwYTk5ZjFlMDZlMThkYTJjMjcyNWZjNTRjZDY3
14
+ MTc0NDhmNzkwNjAzYTFhNGJhMzA5ZDllMWE3YjhiMTk1NTY2MWIxM2NhNDhj
15
+ NDljZDZhYjBjOTM0NzU0OTVhNzJmYzk5ODZkNThlYWUzYmU1NjQ=
data/README.md CHANGED
@@ -3,8 +3,9 @@
3
3
  Easily search and access information on kinopoisk.ru
4
4
 
5
5
  [![Build Status](https://secure.travis-ci.org/RavWar/kinopoisk_parser.png)](http://travis-ci.org/RavWar/kinopoisk_parser)
6
- [![Code Climate](https://codeclimate.com/github/RavWar/kinopoisk_parser.png)](https://codeclimate.com/github/RavWar/kinopoisk_parser)
7
6
  [![Dependency Status](https://gemnasium.com/RavWar/kinopoisk_parser.png)](https://gemnasium.com/RavWar/kinopoisk_parser)
7
+ [![Gem Version](https://badge.fury.io/rb/kinopoisk_parser.png)](http://badge.fury.io/rb/kinopoisk_parser)
8
+ [![Code Climate](https://codeclimate.com/github/RavWar/kinopoisk_parser.png)](https://codeclimate.com/github/RavWar/kinopoisk_parser)
8
9
 
9
10
  ## Installation
10
11
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'kinopoisk_parser'
3
- gem.version = '1.0.2'
3
+ gem.version = '1.0.3'
4
4
  gem.authors = ['RavWar']
5
5
  gem.email = ['rav_war@mail.ru']
6
6
  gem.homepage = 'https://github.com/RavWar/kinopoisk_parser'
@@ -42,15 +42,31 @@ module Kinopoisk
42
42
  doc.search("table.info a[href*='/m_act%5Bcountry%5D/']").map(&:text)
43
43
  end
44
44
 
45
+ def budget
46
+ doc.search("//td[text()='бюджет']/following-sibling::*//a").text
47
+ end
48
+
49
+ def gross_ru
50
+ doc.search("td#div_rus_box_td2 a").text
51
+ end
52
+
53
+ def gross_us
54
+ doc.search("td#div_usa_box_td2 a").text
55
+ end
56
+
57
+ def gross_world
58
+ doc.search("td#div_world_box_td2 a").text
59
+ end
60
+
45
61
  def poster
46
62
  doc.search("img[itemprop='image']").first.attr 'src'
47
63
  end
48
64
 
49
- def world_premiere
65
+ def premiere_world
50
66
  doc.search('td#div_world_prem_td2 a:first').text
51
67
  end
52
68
 
53
- def ru_premiere
69
+ def premiere_ru
54
70
  doc.search('td#div_rus_prem_td2 a:first').text
55
71
  end
56
72
 
@@ -63,7 +79,7 @@ module Kinopoisk
63
79
  end
64
80
 
65
81
  def length
66
- doc.search('td#runtime').text
82
+ doc.search('td#runtime').text.to_i
67
83
  end
68
84
 
69
85
  def directors
@@ -132,7 +148,7 @@ module Kinopoisk
132
148
  end
133
149
 
134
150
  def search_by_text(name)
135
- doc.search("//td[text()='#{name}']").first.next.text
151
+ doc.search("//td[text()='#{name}']/following-sibling::*").text
136
152
  end
137
153
 
138
154
  def to_array(string)
@@ -22,7 +22,7 @@ module Kinopoisk
22
22
  end
23
23
 
24
24
  def partner
25
- doc.search("//td[@class='type'][contains(text(),'супруг')]").first.next.text
25
+ doc.search("//td[@class='type'][contains(text(),'супруг')]/following-sibling::*").text
26
26
  end
27
27
 
28
28
  def birthdate
@@ -68,7 +68,7 @@ module Kinopoisk
68
68
  end
69
69
 
70
70
  def search_by_text(name)
71
- doc.search("//td[@class='type'][text()='#{name}']").first.next.text
71
+ doc.search("//td[@class='type'][text()='#{name}']/following-sibling::*").text
72
72
  end
73
73
  end
74
74
  end
@@ -6,6 +6,7 @@ require 'kinopoisk/person'
6
6
 
7
7
  module Kinopoisk
8
8
  SEARCH_URL = "http://www.kinopoisk.ru/index.php?kp_query="
9
+ NotFound = Class.new StandardError
9
10
 
10
11
  # Headers are needed to mimic proper request so kinopoisk won't block it
11
12
  def self.fetch(url)
@@ -13,7 +14,7 @@ module Kinopoisk
13
14
  end
14
15
 
15
16
  def self.parse(url)
16
- page = fetch url
17
- page.status == 200 ? Nokogiri::HTML(page.body.encode('utf-8')) : raise
17
+ p = fetch url
18
+ p.status==200 ? Nokogiri::HTML(p.body.encode('utf-8')) : raise(NotFound)
18
19
  end
19
20
  end
@@ -1,39 +1,46 @@
1
1
  #coding: UTF-8
2
2
  require 'spec_helper'
3
3
 
4
- describe Kinopoisk::Movie, vcr: { cassette_name: 'movie' } do
5
- let(:movie) { Kinopoisk::Movie.new 277537 }
6
-
7
- it { movie.url.should eq('http://www.kinopoisk.ru/film/277537/') }
8
- it { movie.title.should eq('Правосудие Декстера') }
9
- it { movie.title_en.should eq('Dexter') }
10
- it { movie.countries.should eq(['США']) }
11
- it { movie.year.should eq(2006) }
12
- it { movie.poster.should eq('http://st.kinopoisk.ru/images/film/277537.jpg') }
13
- it { movie.poster_big.should eq('http://st.kinopoisk.ru/images/film_big/277537.jpg') }
14
- it { movie.producers.should eq(['Сара Коллетон','Джон Голдвин','Роберт Ллойд Льюис']) }
15
- it { movie.art_directors.should eq(['Джессика Кендер','Энтони Коули','Эрик Уейлер']) }
16
- it { movie.operators.should eq(['Ромео Тироне','Джеф Джёр','Мартин Дж. Лэйтон']) }
17
- it { movie.editors.should eq(['Луис Ф. Циоффи','Стюарт Шилл','Мэттью Колонна']) }
18
- it { movie.writers.should eq(['Джефф Линдсэй','Джеймс Манос мл.','Скотт Бак']) }
19
- it { movie.actors.should include('Майкл С. Холл', 'Дженнифер Карпентер') }
20
- it { movie.genres.should eq(['триллер','драма','криминал', 'детектив']) }
21
- it { movie.directors.should eq(['Джон Дал','Стив Шилл','Кит Гордон']) }
22
- it { movie.slogan.should eq('«Takes life. Seriously.»') }
23
- it { movie.description.should match('Декстер Морган.') }
24
- it { movie.world_premiere.should eq('1 октября 2006') }
25
- it { movie.ru_premiere.should eq('3 ноября 2008') }
26
- it { movie.composers.should eq(['Дэниэл Лихт']) }
27
- it { movie.imdb_rating_count.should be_a(Integer) }
28
- it { movie.imdb_rating.should be_a(Float) }
29
- it { movie.rating_count.should be_a(Integer) }
30
- it { movie.rating.should be_a(Float) }
31
- it { movie.length.should eq('55 мин.') }
4
+ describe Kinopoisk::Movie, vcr: { cassette_name: 'movies' } do
5
+ let(:dexter) { Kinopoisk::Movie.new 277537 }
6
+ let(:avatar) { Kinopoisk::Movie.new 251733 }
7
+
8
+ it { dexter.url.should eq('http://www.kinopoisk.ru/film/277537/') }
9
+ it { dexter.title.should eq('Правосудие Декстера') }
10
+ it { dexter.title_en.should eq('Dexter') }
11
+ it { dexter.countries.should eq(['США']) }
12
+ it { dexter.year.should eq(2006) }
13
+ it { dexter.poster.should eq('http://st.kinopoisk.ru/images/film/277537.jpg') }
14
+ it { dexter.poster_big.should eq('http://st.kinopoisk.ru/images/film_big/277537.jpg') }
15
+ it { dexter.producers.should eq(['Сара Коллетон','Джон Голдвин','Роберт Ллойд Льюис']) }
16
+ it { dexter.art_directors.should eq(['Джессика Кендер','Энтони Коули','Эрик Уейлер']) }
17
+ it { dexter.operators.should eq(['Ромео Тироне','Джеф Джёр','Мартин Дж. Лэйтон']) }
18
+ it { dexter.editors.should eq(['Луис Ф. Циоффи','Стюарт Шилл','Мэттью Колонна']) }
19
+ it { dexter.writers.should eq(['Джефф Линдсэй','Джеймс Манос мл.','Скотт Бак']) }
20
+ it { dexter.actors.should include('Майкл С. Холл', 'Дженнифер Карпентер') }
21
+ it { dexter.genres.should eq(['триллер','драма','криминал', 'детектив']) }
22
+ it { dexter.directors.should eq(['Джон Дал','Стив Шилл','Кит Гордон']) }
23
+ it { dexter.slogan.should eq('«Takes life. Seriously.»') }
24
+ it { dexter.description.should match('Декстер Морган.') }
25
+ it { dexter.premiere_world.should eq('1 октября 2006') }
26
+ it { dexter.premiere_ru.should eq('3 ноября 2008') }
27
+ it { dexter.composers.should eq(['Дэниэл Лихт']) }
28
+ it { dexter.imdb_rating_count.should be_a(Integer) }
29
+ it { dexter.imdb_rating.should be_a(Float) }
30
+ it { dexter.rating_count.should be_a(Integer) }
31
+ it { dexter.rating.should be_a(Float) }
32
+ it { dexter.gross_ru.should eq('') }
33
+
34
+ it { avatar.gross_world.should match('[$\d]') }
35
+ it { avatar.gross_ru.should match('[$\d]') }
36
+ it { avatar.gross_us.should match('[$\d]') }
37
+ it { avatar.budget.should eq("$237 000 000") }
38
+ it { avatar.length.should eq(162) }
32
39
 
33
40
  it 'should make only one request' do
34
- movie.title
35
- movie.countries
36
- a_request(:get, movie.url).should have_been_made.once
41
+ dexter.title
42
+ dexter.countries
43
+ a_request(:get, dexter.url).should have_been_made.once
37
44
  end
38
45
 
39
46
  it 'should raise error if nothing found' do
@@ -41,18 +48,18 @@ describe Kinopoisk::Movie, vcr: { cassette_name: 'movie' } do
41
48
  end
42
49
 
43
50
  context 'by title' do
44
- let(:movie_by_title) { Kinopoisk::Movie.new 'Dexter' }
51
+ let(:dexter_by_title) { Kinopoisk::Movie.new 'Dexter' }
45
52
 
46
- it { movie.url.should eq(movie_by_title.url) }
53
+ it { dexter.url.should eq(dexter_by_title.url) }
47
54
 
48
55
  it 'should make only one request to initialize' do
49
- movie_by_title
56
+ dexter_by_title
50
57
  a_request(:get, /.*/).should have_been_made.once
51
58
  end
52
59
 
53
60
  it 'should make max two requests' do
54
- movie_by_title.title
55
- movie_by_title.countries
61
+ dexter_by_title.title
62
+ dexter_by_title.countries
56
63
  a_request(:get, /.*/).should have_been_made.twice
57
64
  end
58
65
  end
@@ -1,7 +1,7 @@
1
1
  #coding: UTF-8
2
2
  require 'spec_helper'
3
3
 
4
- describe Kinopoisk::Person, vcr: { cassette_name: 'person' } do
4
+ describe Kinopoisk::Person, vcr: { cassette_name: 'people' } do
5
5
  let(:person) { Kinopoisk::Person.new 13180 }
6
6
 
7
7
  it 'should return right url' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kinopoisk_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - RavWar