KinopoiskAPI 0.9.0 → 0.9.9
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/.gitignore +2 -1
- data/Gemfile +2 -1
- data/KinopoiskAPI.gemspec +14 -8
- data/README.md +17 -0
- data/lib/KinopoiskAPI.rb +0 -185
- data/lib/KinopoiskAPI/version.rb +1 -1
- metadata +7 -20
- data/lib/KinopoiskAPI/agent.rb +0 -252
- data/lib/KinopoiskAPI/api_error.rb +0 -21
- data/lib/KinopoiskAPI/category.rb +0 -31
- data/lib/KinopoiskAPI/film.rb +0 -103
- data/lib/KinopoiskAPI/film_search.rb +0 -53
- data/lib/KinopoiskAPI/global_search.rb +0 -37
- data/lib/KinopoiskAPI/people.rb +0 -61
- data/lib/KinopoiskAPI/people_search.rb +0 -53
- data/lib/KinopoiskAPI/today.rb +0 -47
- data/lib/KinopoiskAPI/top.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 433e24c1289e6f34aa3be71e473ddeddd740a8fa
|
4
|
+
data.tar.gz: ddfa9a7c0c528538a62d1acb20448a79e041921b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc2b8eedfe814ee98262df2fb09be0cbf3aac77624d153fad06015685492954b445286332e3e66c47a2068a21a269a2472ecc0c8e046169d791fa56a7c44e778
|
7
|
+
data.tar.gz: 2c61cd34fe1fa5af9bc00ea1d57e51a08e3aecfed179554b6f86bdb34d94efa2a1ab203e082c5b73608ad26808c34e06228950286874de2ce14b4559fbca4372
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/KinopoiskAPI.gemspec
CHANGED
@@ -4,15 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'KinopoiskAPI/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
7
|
+
spec.name = 'KinopoiskAPI'
|
8
|
+
spec.version = KinopoiskAPI::VERSION
|
9
|
+
spec.authors = ['Alexey Vildyaev']
|
10
|
+
spec.email = ['hav0k@me.com']
|
11
11
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
|
15
|
-
|
12
|
+
spec.summary = %q{Gem for operation with Kinopoisk API.[Deleted]}
|
13
|
+
spec.description =
|
14
|
+
|
15
|
+
<<-EOF
|
16
|
+
Используйте https://github.com/groverz/kp_api
|
17
|
+
EOF
|
18
|
+
|
19
|
+
spec.homepage = 'https://github.com/groverz/kp_api'
|
20
|
+
spec.license = 'MIT'
|
21
|
+
spec.post_install_message = "Данный гем больше не работает!!! Используйте https://github.com/groverz/kp_api"
|
16
22
|
|
17
23
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
24
|
# spec.bindir = "exe"
|
data/README.md
CHANGED
@@ -252,6 +252,23 @@ search.next_page
|
|
252
252
|
# > false [Достигли конца пагинации]
|
253
253
|
```
|
254
254
|
|
255
|
+
## Возвращаеммые данные
|
256
|
+
|
257
|
+
###Фильм
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
## Баги
|
263
|
+
|
264
|
+
### Дата
|
265
|
+
|
266
|
+
Иногда кинопоиск отдаёт неправильную дату релиза такого вида. "00.00.2005". соответсветно возникает эксепшен ArgumentError: invalid date. Если такое поризойдёт то дата будет сконвертированна "00.00.2005" -> "01.01.2005".
|
267
|
+
|
268
|
+
_______________________________________________________________________________
|
269
|
+
|
270
|
+
|
271
|
+
|
255
272
|
## License
|
256
273
|
|
257
274
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/KinopoiskAPI.rb
CHANGED
@@ -1,189 +1,4 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'KinopoiskAPI/api_error'
|
3
|
-
require 'KinopoiskAPI/agent'
|
4
|
-
require 'KinopoiskAPI/film'
|
5
|
-
require 'KinopoiskAPI/people'
|
6
|
-
require 'KinopoiskAPI/category'
|
7
|
-
require 'KinopoiskAPI/today'
|
8
|
-
require 'KinopoiskAPI/top'
|
9
|
-
require 'KinopoiskAPI/global_search'
|
10
|
-
require 'KinopoiskAPI/film_search'
|
11
|
-
require 'KinopoiskAPI/people_search'
|
12
|
-
|
13
|
-
|
14
|
-
#require 'KinopoiskAPI/reviews'
|
15
|
-
#require 'KinopoiskAPI/gallery'
|
16
|
-
#require 'KinopoiskAPI/similar'
|
17
|
-
|
18
1
|
require 'KinopoiskAPI/version'
|
19
2
|
|
20
|
-
|
21
3
|
module KinopoiskAPI
|
22
|
-
DOMAINS = {
|
23
|
-
api: 'https://ext.kinopoisk.ru/ios/3.11.0',
|
24
|
-
salt: 'a17qbcw1du0aedm',
|
25
|
-
headers: {
|
26
|
-
'Android-Api-Version' => '19',
|
27
|
-
'User-Agent' => 'Android client (4.4 / api19), ru.kinopoisk/4.0.2 (52)',
|
28
|
-
'device' => 'android'
|
29
|
-
},
|
30
|
-
kinopoisk: {
|
31
|
-
main: 'https://www.kinopoisk.ru',
|
32
|
-
poster: {
|
33
|
-
film: 'https://st.kp.yandex.net/images/film_iphone/iphone360',
|
34
|
-
name: 'https://st.kp.yandex.net/images/actor_iphone/iphone360',
|
35
|
-
gallery: 'https://st.kp.yandex.net/images'
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
METHODS = {
|
41
|
-
get_film: {
|
42
|
-
method: 'getKPFilmDetailView',
|
43
|
-
id: 'filmID'
|
44
|
-
},
|
45
|
-
get_staff: {
|
46
|
-
method: 'getStaffList',
|
47
|
-
id: 'filmID'
|
48
|
-
},
|
49
|
-
get_gallery: {
|
50
|
-
method: 'getGallery',
|
51
|
-
id: 'filmID'
|
52
|
-
},
|
53
|
-
get_similar: {
|
54
|
-
method: 'getKPFilmsList',
|
55
|
-
type: 'kp_similar_films',
|
56
|
-
id: 'filmID'
|
57
|
-
},
|
58
|
-
|
59
|
-
navigator_filters:{
|
60
|
-
method: 'navigatorFilters'
|
61
|
-
},
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
get_top_100_popular: {
|
66
|
-
method: 'getKPTop',
|
67
|
-
type: 'kp_item_top_popular_films'
|
68
|
-
},
|
69
|
-
|
70
|
-
get_top_100_await: {
|
71
|
-
method: 'getKPTop',
|
72
|
-
type: 'kp_item_top_await'
|
73
|
-
},
|
74
|
-
|
75
|
-
get_top_100_people: {
|
76
|
-
method: 'getKPTop',
|
77
|
-
type: 'kp_item_top_popular_people'
|
78
|
-
},
|
79
|
-
|
80
|
-
get_top_250_best:{
|
81
|
-
method: 'getKPTop',
|
82
|
-
type: 'kp_item_top_best_film'
|
83
|
-
},
|
84
|
-
|
85
|
-
get_top_100_gross:{
|
86
|
-
method: 'getKPTop',
|
87
|
-
type: 'kp_item_most_box_office',
|
88
|
-
},
|
89
|
-
|
90
|
-
|
91
|
-
get_reviews: {
|
92
|
-
method: 'getKPReviews',
|
93
|
-
id: 'filmID'
|
94
|
-
},
|
95
|
-
get_review_detail: {
|
96
|
-
method: 'getReviewDetail',
|
97
|
-
id: 'reviewID'
|
98
|
-
},
|
99
|
-
|
100
|
-
get_people: {
|
101
|
-
method: 'getKPPeopleDetailView',
|
102
|
-
id: 'peopleID'
|
103
|
-
|
104
|
-
},
|
105
|
-
get_today_films: {
|
106
|
-
method: 'getKPTodayFilms'
|
107
|
-
},
|
108
|
-
get_cinemas: {
|
109
|
-
method: 'getCinemas'
|
110
|
-
},
|
111
|
-
get_cinema_detail: {
|
112
|
-
method: 'getCinemaDetail',
|
113
|
-
id: 'cinemaID'
|
114
|
-
},
|
115
|
-
get_seance: {
|
116
|
-
method: 'getSeance',
|
117
|
-
id: 'filmID'
|
118
|
-
},
|
119
|
-
get_dates_for_detail_cinema: {
|
120
|
-
method: 'getDatesForDetailCinema',
|
121
|
-
id: 'filmID'
|
122
|
-
},
|
123
|
-
get_soon_films: {
|
124
|
-
method: 'getSoonFilms'
|
125
|
-
},
|
126
|
-
get_soon_dvd: {
|
127
|
-
method: 'getSoonDVD'
|
128
|
-
},
|
129
|
-
get_dates_for_soon_films: {
|
130
|
-
method: 'getDatesForSoonFilms'
|
131
|
-
},
|
132
|
-
get_dates_for_soon_dvd: {
|
133
|
-
method: 'getDatesForSoonDVD'
|
134
|
-
},
|
135
|
-
|
136
|
-
get_best_films: {
|
137
|
-
method: 'getBestFilms'
|
138
|
-
},
|
139
|
-
|
140
|
-
search_global: {
|
141
|
-
method: 'getKPGlobalSearch',
|
142
|
-
keyword: 'keyword'
|
143
|
-
},
|
144
|
-
search_film: {
|
145
|
-
method: 'getKPSearchInFilms',
|
146
|
-
keyword: 'keyword',
|
147
|
-
page: 'page'
|
148
|
-
},
|
149
|
-
search_people: {
|
150
|
-
method: 'getKPSearchInPeople',
|
151
|
-
keyword: 'keyword',
|
152
|
-
page: 'page'
|
153
|
-
},
|
154
|
-
|
155
|
-
search_cinemas: {
|
156
|
-
method: 'searchCinemas',
|
157
|
-
keyword: 'keyword'
|
158
|
-
},
|
159
|
-
news: {
|
160
|
-
method: 'getNews'
|
161
|
-
},
|
162
|
-
get_news_detail: {
|
163
|
-
method: 'getNewsDetail'
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
def self.api_access(url)
|
168
|
-
#uri = URI.parse(url)
|
169
|
-
#http = Net::HTTP.new(uri.host, uri.port)
|
170
|
-
#response = http.request_head(uri.path)
|
171
|
-
#
|
172
|
-
#if response.code == '200'
|
173
|
-
# true
|
174
|
-
#else
|
175
|
-
# false
|
176
|
-
#end
|
177
|
-
raise ToDo
|
178
|
-
end
|
179
|
-
|
180
|
-
def self.valid_json?(j)
|
181
|
-
begin
|
182
|
-
JSON.parse(j)
|
183
|
-
return true
|
184
|
-
rescue JSON::ParserError => e
|
185
|
-
return false
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
4
|
end
|
data/lib/KinopoiskAPI/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: KinopoiskAPI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Vildyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: " Используйте https://github.com/groverz/kp_api\n"
|
56
56
|
email:
|
57
57
|
- hav0k@me.com
|
58
58
|
executables:
|
@@ -73,25 +73,12 @@ files:
|
|
73
73
|
- bin/console
|
74
74
|
- bin/setup
|
75
75
|
- lib/KinopoiskAPI.rb
|
76
|
-
- lib/KinopoiskAPI/agent.rb
|
77
|
-
- lib/KinopoiskAPI/api_error.rb
|
78
|
-
- lib/KinopoiskAPI/category.rb
|
79
|
-
- lib/KinopoiskAPI/film.rb
|
80
|
-
- lib/KinopoiskAPI/film_search.rb
|
81
|
-
- lib/KinopoiskAPI/gallery.rb.old
|
82
|
-
- lib/KinopoiskAPI/global_search.rb
|
83
|
-
- lib/KinopoiskAPI/people.rb
|
84
|
-
- lib/KinopoiskAPI/people_search.rb
|
85
|
-
- lib/KinopoiskAPI/reviews.rb.old
|
86
|
-
- lib/KinopoiskAPI/similar.rb.old
|
87
|
-
- lib/KinopoiskAPI/today.rb
|
88
|
-
- lib/KinopoiskAPI/top.rb
|
89
76
|
- lib/KinopoiskAPI/version.rb
|
90
|
-
homepage: https://github.com/
|
77
|
+
homepage: https://github.com/groverz/kp_api
|
91
78
|
licenses:
|
92
79
|
- MIT
|
93
80
|
metadata: {}
|
94
|
-
post_install_message:
|
81
|
+
post_install_message: Данный гем больше не работает!!! Используйте https://github.com/groverz/kp_api
|
95
82
|
rdoc_options: []
|
96
83
|
require_paths:
|
97
84
|
- lib
|
@@ -107,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
94
|
version: '0'
|
108
95
|
requirements: []
|
109
96
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.6.
|
97
|
+
rubygems_version: 2.6.13
|
111
98
|
signing_key:
|
112
99
|
specification_version: 4
|
113
|
-
summary: Gem for operation with Kinopoisk API
|
100
|
+
summary: Gem for operation with Kinopoisk API.[Deleted]
|
114
101
|
test_files: []
|
data/lib/KinopoiskAPI/agent.rb
DELETED
@@ -1,252 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class Agent
|
3
|
-
|
4
|
-
def status
|
5
|
-
@json[:resultCode].nil? ? true : false
|
6
|
-
end
|
7
|
-
|
8
|
-
def status2
|
9
|
-
@json[:resultCode].nil? ? true : false
|
10
|
-
end
|
11
|
-
|
12
|
-
def data
|
13
|
-
@json
|
14
|
-
end
|
15
|
-
|
16
|
-
def data2
|
17
|
-
@json2
|
18
|
-
end
|
19
|
-
|
20
|
-
####
|
21
|
-
####
|
22
|
-
####
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def json(url=nil)
|
27
|
-
if url.nil?
|
28
|
-
uri = URI(@url)
|
29
|
-
else
|
30
|
-
uri = URI(url)
|
31
|
-
end
|
32
|
-
|
33
|
-
uuid = Digest::MD5.hexdigest("--#{rand(10000)}--#{Time.now}--")
|
34
|
-
query = URI.decode_www_form(String(uri.query)) << ["uuid", uuid]
|
35
|
-
uri.query = URI.encode_www_form(query)
|
36
|
-
|
37
|
-
path = uri.to_s.gsub("#{DOMAINS[:api]}/","") + DOMAINS[:salt]
|
38
|
-
key = Digest::MD5.hexdigest(path)
|
39
|
-
|
40
|
-
query = URI.decode_www_form(String(uri.query)) << ["key", key]
|
41
|
-
uri.query = URI.encode_www_form(query)
|
42
|
-
|
43
|
-
print "[GET] -> " + uri.to_s
|
44
|
-
get_time = Time.now
|
45
|
-
|
46
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
47
|
-
http.read_timeout = 10
|
48
|
-
http.use_ssl = true
|
49
|
-
response = http.get(uri.request_uri, DOMAINS[:headers])
|
50
|
-
|
51
|
-
print " <- [#{(Time.now-get_time).round 3}s]\n"
|
52
|
-
|
53
|
-
if KinopoiskAPI::valid_json?(response.body)
|
54
|
-
j = JSON.parse(response.body)
|
55
|
-
if j['resultCode'] == 0
|
56
|
-
j['data']
|
57
|
-
else
|
58
|
-
j
|
59
|
-
end
|
60
|
-
else
|
61
|
-
{:resultCode => -1, :message=> "Error method require", :data => { :code => response.code, :body => response.body} }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def json2
|
66
|
-
if @json2.nil?
|
67
|
-
@json2 = json(@url2)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def s2a(str)
|
73
|
-
if str.nil?
|
74
|
-
[]
|
75
|
-
else
|
76
|
-
str.split(',').map { |i| i.strip }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def int_data(data, name, none=0, type=Integer)
|
81
|
-
s = dn(data, name)
|
82
|
-
|
83
|
-
if s.nil?
|
84
|
-
none
|
85
|
-
else
|
86
|
-
r = s
|
87
|
-
if r.class == String
|
88
|
-
r = s.gsub(/[\ \%\$]/i, '')
|
89
|
-
end
|
90
|
-
|
91
|
-
if type == Integer
|
92
|
-
r.to_i == 0 ? none : r.to_i
|
93
|
-
elsif type == Float
|
94
|
-
r.to_f == 0 ? none : r.to_f
|
95
|
-
else
|
96
|
-
r
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def year_data(data, name, point=:start)
|
102
|
-
s = dn(data, name)
|
103
|
-
|
104
|
-
if s.nil?
|
105
|
-
nil
|
106
|
-
else
|
107
|
-
if s.size == 4 && point == :start
|
108
|
-
s.to_i
|
109
|
-
else s.size == 9
|
110
|
-
arr = s.scan(/(\d{4})/).flatten
|
111
|
-
if point == :start
|
112
|
-
arr[0].to_i
|
113
|
-
elsif point == :end
|
114
|
-
arr[1].to_i
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def time_data(data, name)
|
121
|
-
s = dn(data, name)
|
122
|
-
if !s.nil?
|
123
|
-
|
124
|
-
if s.size == 10
|
125
|
-
d=Date.parse(s) rescue nil
|
126
|
-
if d.nil?
|
127
|
-
s=s.gsub('00.', '01.')
|
128
|
-
d=Date.parse(s) rescue nil
|
129
|
-
end
|
130
|
-
d
|
131
|
-
else
|
132
|
-
year = s.scan(/\d{4}/)[0]
|
133
|
-
if !year.nil?
|
134
|
-
Date.parse("01.01.#{year}") #only year???
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def arr_data(data, name)
|
142
|
-
s = dn(data, name)
|
143
|
-
if s.nil?
|
144
|
-
[]
|
145
|
-
else
|
146
|
-
s.split(',').map { |genre| genre.strip }
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def str_data(data, name)
|
151
|
-
s = dn(data, name)
|
152
|
-
|
153
|
-
if s.class == String
|
154
|
-
s
|
155
|
-
elsif s.class == NilClass
|
156
|
-
nil
|
157
|
-
else
|
158
|
-
s.to_s
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def bool_data(data, name)
|
163
|
-
s = dn(data, name)
|
164
|
-
|
165
|
-
if s.class == String
|
166
|
-
s = s.to_i
|
167
|
-
end
|
168
|
-
|
169
|
-
if s.class == TrueClass || s.class == FalseClass
|
170
|
-
s
|
171
|
-
else
|
172
|
-
s.present? && s == 1 ? true : false
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def min_data(data, name)
|
177
|
-
s = dn(data, name)
|
178
|
-
s.present? ? Time.parse(s).seconds_since_midnight.to_i / 60 : 0
|
179
|
-
end
|
180
|
-
|
181
|
-
def url_data(data, name, id, poster_name)
|
182
|
-
s = dn(data, name)
|
183
|
-
s.nil? ? nil : "#{DOMAINS[:kinopoisk][:poster][poster_name]}_#{id}.jpg"
|
184
|
-
end
|
185
|
-
|
186
|
-
|
187
|
-
def film_hash(h, id='filmID')
|
188
|
-
{
|
189
|
-
id: int_data(String, h[id ]),
|
190
|
-
kp_type: str_data(String, h['type' ]),
|
191
|
-
name_ru: str_data(String, h['nameRU' ]),
|
192
|
-
name_en: str_data(String, h['nameEN' ]),
|
193
|
-
slogan: str_data(String, h['slogan' ]),
|
194
|
-
description: str_data(String, h['description' ]),
|
195
|
-
poster_url: url_data(String, h['posterURL' ], h[id], :film),
|
196
|
-
year: year_data(String, h['year' ], :start),
|
197
|
-
year_end: year_data(String, h['year' ], :end),
|
198
|
-
reviews_count: int_data(String, h['reviewsCount']),
|
199
|
-
duration: min_data(String, h['filmLength' ]),
|
200
|
-
countries: arr_data(String, h['country' ]),
|
201
|
-
genres: arr_data(String, h['genre' ]),
|
202
|
-
video: h['videoURL'],
|
203
|
-
is_sequel_or_prequel: bool_data(String, h['hasSequelsAndPrequelsFilms']),
|
204
|
-
is_similar_films: bool_data(String, h['hasRelatedFilms' ]),
|
205
|
-
is_imax: bool_data(String, h['isIMAX' ]),
|
206
|
-
is_3d: bool_data(String, h['is3D' ]),
|
207
|
-
rating_mpaa: str_data(String, h['ratingMPAA' ]),
|
208
|
-
minimal_age: int_data(String, h['ratingAgeLimits' ])
|
209
|
-
}
|
210
|
-
end
|
211
|
-
|
212
|
-
def people_hash(h)
|
213
|
-
{
|
214
|
-
:id => int_data(String, h['id' ]),
|
215
|
-
:kp_type => str_data(String, h['type' ]),
|
216
|
-
:name_ru => str_data(String, h['nameRU' ]),
|
217
|
-
:name_en => str_data(String, h['nameEN' ]),
|
218
|
-
:poster_url => url_data(String, h['posterURL' ], @id, :name),
|
219
|
-
:sex => str_data(String, h['sex' ]),
|
220
|
-
:growth => int_data(String, h['growth' ]),
|
221
|
-
:birthday => time_data(String, h['birthday' ]),
|
222
|
-
:birthplace => str_data(String, h['sex' ]),
|
223
|
-
:has_awards => bool_data(String, h['has_awards']),
|
224
|
-
:profession => s2a(str_data(String, h['profession']))
|
225
|
-
}
|
226
|
-
end
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
def dn(data, name)
|
234
|
-
if data.nil?
|
235
|
-
r = @json[name]
|
236
|
-
elsif data == String
|
237
|
-
r = name
|
238
|
-
else
|
239
|
-
if @json[data].nil?
|
240
|
-
r = nil
|
241
|
-
else
|
242
|
-
r = @json[data][name]
|
243
|
-
end
|
244
|
-
end
|
245
|
-
r
|
246
|
-
end
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
end
|
252
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class APIerror < StandardError
|
3
|
-
|
4
|
-
def initialize(message, data)
|
5
|
-
super(message)
|
6
|
-
@data = data
|
7
|
-
end
|
8
|
-
attr_reader :data
|
9
|
-
|
10
|
-
|
11
|
-
def code
|
12
|
-
@data[:code]
|
13
|
-
end
|
14
|
-
|
15
|
-
def body
|
16
|
-
@data[:body]
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class Category < Agent
|
3
|
-
attr_accessor :url
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@url = "#{DOMAINS[:api]}/#{METHODS[:navigator_filters][:method]}"
|
7
|
-
@json = json
|
8
|
-
end
|
9
|
-
|
10
|
-
def genres
|
11
|
-
h(@json['genre'])
|
12
|
-
end
|
13
|
-
|
14
|
-
def countries
|
15
|
-
h(@json['country'])
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def h(j)
|
20
|
-
j.map do |item|
|
21
|
-
{
|
22
|
-
id: int_data(String, item["id" ]),
|
23
|
-
name: str_data(String, item["name" ]),
|
24
|
-
popular: bool_data(String, item["popular" ])
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
#private end
|
30
|
-
end
|
31
|
-
end
|
data/lib/KinopoiskAPI/film.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class Film < Agent
|
3
|
-
attr_accessor :id, :url
|
4
|
-
|
5
|
-
def initialize(id)
|
6
|
-
@id = id.to_i
|
7
|
-
@url = "#{DOMAINS[:api]}/#{METHODS[:get_film][:method]}?#{METHODS[:get_film][:id]}=#{id}"
|
8
|
-
@url2 = "#{DOMAINS[:api]}/#{METHODS[:get_staff][:method]}?#{METHODS[:get_staff][:id]}=#{id}"
|
9
|
-
@json = json
|
10
|
-
|
11
|
-
unless status
|
12
|
-
raise APIerror.new(@json[:message], @json[:data])
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def view
|
18
|
-
film_hash(@json).merge(rating).merge(rent).merge(budget)
|
19
|
-
end
|
20
|
-
|
21
|
-
def rating
|
22
|
-
{
|
23
|
-
:rating_good_review => int_data('ratingData', 'ratingGoodReview', nil),
|
24
|
-
:rating_good_review_vote_count => int_data('ratingData', 'ratingGoodReviewVoteCount'),
|
25
|
-
:rating => int_data('ratingData', 'rating', nil, Float),
|
26
|
-
:rating_vote_count => int_data('ratingData', 'ratingVoteCount'),
|
27
|
-
:rating_await => int_data('ratingData', 'ratingAwait', nil),
|
28
|
-
:rating_await_count => int_data('ratingData', 'ratingAwaitCount'),
|
29
|
-
:rating_imdb => int_data('ratingData', 'ratingIMDb', nil, Float),
|
30
|
-
:rating_imdb_vote_count => int_data('ratingData', 'ratingIMDbVoteCount'),
|
31
|
-
:rating_film_critics => int_data('ratingData', 'ratingFilmCritics', nil),
|
32
|
-
:rating_film_critics_vote_count => int_data('ratingData', 'ratingFilmCriticsVoteCount'),
|
33
|
-
:rating_rf_critics => int_data('ratingData', 'ratingRFCritics', nil),
|
34
|
-
:rating_fr_critics_vote_count => int_data('ratingData', 'ratingRFCriticsVoteCount')
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
def rent
|
39
|
-
{
|
40
|
-
:distributors => str_data('rentData', 'Distributors'),
|
41
|
-
:premiere_world_country => str_data('rentData', 'premiereWorldCountry'),
|
42
|
-
:distributor_release => str_data('rentData', 'distributorRelease'),
|
43
|
-
:premiere_ru => time_data('rentData', 'premiereRU'),
|
44
|
-
:premiere_world => time_data('rentData', 'premiereWorld'),
|
45
|
-
:premiere_dvd => time_data('rentData', 'premiereDVD'),
|
46
|
-
:premiere_blu_ray => time_data('rentData', 'premiereBluRay')
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
def budget
|
51
|
-
{
|
52
|
-
:gross_ru => int_data('budgetData', 'grossRU', nil),
|
53
|
-
:gross_usa => int_data('budgetData', 'grossUSA', nil),
|
54
|
-
:gross_world => int_data('budgetData', 'grossWorld', nil),
|
55
|
-
:budget => int_data('budgetData', 'budget', nil)
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
def peoples
|
60
|
-
unless @json['creators'].nil?
|
61
|
-
@json['creators'].map { |items|
|
62
|
-
items.map do |item|
|
63
|
-
people_hash_old(item)
|
64
|
-
end
|
65
|
-
}.flatten
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def peoples_full
|
70
|
-
json2
|
71
|
-
unless @json2['creators'].nil?
|
72
|
-
@json2['creators'].map { |items|
|
73
|
-
items.map do |item|
|
74
|
-
people_hash_old(item)
|
75
|
-
end
|
76
|
-
}.flatten
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
##########################
|
81
|
-
##########################
|
82
|
-
##########################
|
83
|
-
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def people_hash_old(item)
|
88
|
-
Hash[
|
89
|
-
[
|
90
|
-
[:id, item['id'].to_i ],
|
91
|
-
[:kp_type, item['type'] ],
|
92
|
-
[:poster_url, item['posterURL'].present? ? "#{DOMAINS[:kinopoisk][:poster][:name]}_#{item['id']}.jpg" : nil],
|
93
|
-
[:name_ru, item['nameRU'] ],
|
94
|
-
[:name_en, item['nameEN'] ],
|
95
|
-
[:description, item['description'] ],
|
96
|
-
[:profession_text, item['professionText']],
|
97
|
-
[:profession_key, item['professionKey'] ]
|
98
|
-
]
|
99
|
-
]
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class FilmSearch < Agent
|
3
|
-
attr_accessor :keyword, :url
|
4
|
-
|
5
|
-
def initialize(keyword)
|
6
|
-
@keyword = URI.encode(keyword)
|
7
|
-
@page = 1
|
8
|
-
gen_url
|
9
|
-
@json = json
|
10
|
-
@page_count = @json['pagesCount']
|
11
|
-
end
|
12
|
-
|
13
|
-
def films_count
|
14
|
-
@json['searchFilmsCountResult']
|
15
|
-
end
|
16
|
-
|
17
|
-
def page_count
|
18
|
-
@page_count
|
19
|
-
end
|
20
|
-
|
21
|
-
def current_page
|
22
|
-
@current_page
|
23
|
-
end
|
24
|
-
|
25
|
-
def view
|
26
|
-
@json['searchFilms'].map do |film|
|
27
|
-
film_hash(film)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def next_page
|
32
|
-
if @page < @page_count
|
33
|
-
@page += 1
|
34
|
-
gen_url
|
35
|
-
@json = json
|
36
|
-
true
|
37
|
-
else
|
38
|
-
false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def gen_url
|
45
|
-
@url = [
|
46
|
-
"#{DOMAINS[:api]}/#{METHODS[:search_film][:method]}",
|
47
|
-
"?#{METHODS[:search_film][:keyword]}=#{@keyword}",
|
48
|
-
"&#{METHODS[:search_film][:page]}=#{@page}"
|
49
|
-
].join('')
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class GlobalSearch < Agent
|
3
|
-
attr_accessor :keyword, :url
|
4
|
-
|
5
|
-
def initialize(keyword)
|
6
|
-
@keyword = URI.encode(keyword)
|
7
|
-
@url = "#{DOMAINS[:api]}/#{METHODS[:search_global][:method]}?#{METHODS[:search_global][:keyword]}=#{@keyword}"
|
8
|
-
@json = json
|
9
|
-
end
|
10
|
-
|
11
|
-
def films_count
|
12
|
-
@json['searchFilmsCountResult']
|
13
|
-
end
|
14
|
-
|
15
|
-
def names_count
|
16
|
-
@json['searchPeoplesCountResult']
|
17
|
-
end
|
18
|
-
|
19
|
-
def youmean
|
20
|
-
film_hash(@json['youmean'])
|
21
|
-
end
|
22
|
-
|
23
|
-
def films
|
24
|
-
@json['searchFilms'].map do |film|
|
25
|
-
film_hash(film)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def peoples
|
30
|
-
json['searchPeople'].map do |name|
|
31
|
-
people_hash(name)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
data/lib/KinopoiskAPI/people.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class People < Agent
|
3
|
-
attr_accessor :id, :url
|
4
|
-
|
5
|
-
def initialize(id)
|
6
|
-
@id = id.to_i
|
7
|
-
@url = "#{DOMAINS[:api]}/#{METHODS[:get_people][:method]}?#{METHODS[:get_people][:id]}=#{id}"
|
8
|
-
@json = json
|
9
|
-
|
10
|
-
unless status
|
11
|
-
raise APIerror.new(@json[:mesage], @json[:data])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def view
|
16
|
-
{
|
17
|
-
:id => @id,
|
18
|
-
:kp_type => str_data(nil, 'class'),
|
19
|
-
:name_ru => str_data(nil, 'nameRU'),
|
20
|
-
:name_en => str_data(nil, 'nameEN'),
|
21
|
-
:poster_url => url_data(nil, 'posterURL', @id, :name),
|
22
|
-
:sex => str_data(nil, 'sex'),
|
23
|
-
:growth => int_data(nil, 'growth'),
|
24
|
-
:birthday => time_data(nil, 'birthday'),
|
25
|
-
:birthplace => str_data(nil, 'birthplace'),
|
26
|
-
:has_awards => bool_data(nil, 'has_awards'),
|
27
|
-
:profession => s2a(str_data(nil, 'profession'))
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
def films
|
32
|
-
filmography.map do |film|
|
33
|
-
{
|
34
|
-
:id => int_data(String, film['filmID' ]),
|
35
|
-
:rating => int_data(String, film['rating' ], nil, Float),
|
36
|
-
:rating_vote_count => int_data(String, film['ratingVoteCount']),
|
37
|
-
:description => str_data(String, film['description' ]),
|
38
|
-
:profession_text => str_data(String, film['professionText ']),
|
39
|
-
:profession_key => str_data(String, film['professionKey' ]),
|
40
|
-
:name_ru => str_data(String, film['nameRU' ]),
|
41
|
-
:name_en => str_data(String, film['nameEN' ]),
|
42
|
-
:year => time_data(String, film['year' ])
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def film_ids
|
48
|
-
filmography.map {|film| int_data(String, film['filmID']) }
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def filmography
|
54
|
-
@json['filmography'].flatten
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class PeopleSearch < Agent
|
3
|
-
attr_accessor :keyword, :url
|
4
|
-
|
5
|
-
def initialize(keyword)
|
6
|
-
@keyword = URI.encode(keyword)
|
7
|
-
@page = 1
|
8
|
-
gen_url
|
9
|
-
@json = json
|
10
|
-
@page_count = @json['pagesCount']
|
11
|
-
end
|
12
|
-
|
13
|
-
def peoples_count
|
14
|
-
@json['searchPeoplesCountResult']
|
15
|
-
end
|
16
|
-
|
17
|
-
def page_count
|
18
|
-
@page_count
|
19
|
-
end
|
20
|
-
|
21
|
-
def current_page
|
22
|
-
@current_page
|
23
|
-
end
|
24
|
-
|
25
|
-
def view
|
26
|
-
@json['searchPeople'].map do |film|
|
27
|
-
people_hash(film)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def next_page
|
32
|
-
if @page < @page_count
|
33
|
-
@page += 1
|
34
|
-
gen_url
|
35
|
-
@json = json
|
36
|
-
true
|
37
|
-
else
|
38
|
-
false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def gen_url
|
45
|
-
@url = [
|
46
|
-
"#{DOMAINS[:api]}/#{METHODS[:search_people][:method]}",
|
47
|
-
"?#{METHODS[:search_people][:keyword]}=#{@keyword}",
|
48
|
-
"&#{METHODS[:search_people][:page]}=#{@page}"
|
49
|
-
].join('')
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
data/lib/KinopoiskAPI/today.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class Today < Agent
|
3
|
-
attr_accessor :url
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@url = "#{DOMAINS[:api]}/#{METHODS[:get_today_films][:method]}"
|
7
|
-
@json = json
|
8
|
-
end
|
9
|
-
|
10
|
-
def view
|
11
|
-
films.map do |film|
|
12
|
-
{
|
13
|
-
id: int_data(String, film['id' ]),
|
14
|
-
kp_type: str_data(String, film['type' ]),
|
15
|
-
name_ru: str_data(String, film['nameRU' ]),
|
16
|
-
name_en: str_data(String, film['nameEN' ]),
|
17
|
-
slogan: str_data(String, film['slogan' ]),
|
18
|
-
description: str_data(String, film['description' ]),
|
19
|
-
poster_url: url_data(String, film['posterURL' ], film["id"], :film),
|
20
|
-
year: int_data(String, film['year' ]),
|
21
|
-
reviews_count: int_data(String, film['reviewsCount']),
|
22
|
-
duration: min_data(String, film['filmLength' ]),
|
23
|
-
countries: arr_data(String, film['country' ]),
|
24
|
-
genres: arr_data(String, film['genre' ]),
|
25
|
-
video: film['videoURL'],
|
26
|
-
is_sequel_or_prequel: bool_data(String, film['hasSequelsAndPrequelsFilms']),
|
27
|
-
is_similar_films: bool_data(String, film['hasRelatedFilms' ]),
|
28
|
-
is_imax: bool_data(String, film['isIMAX' ]),
|
29
|
-
is_3d: bool_data(String, film['is3D' ]),
|
30
|
-
rating_mpaa: str_data(String, film['ratingMPAA' ]),
|
31
|
-
minimal_age: int_data(String, film['ratingAgeLimits' ])
|
32
|
-
}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def film_ids
|
37
|
-
films.map{|film| int_data(String, film['id'], nil) }.compact
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def films
|
43
|
-
@json['filmsData']
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
data/lib/KinopoiskAPI/top.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module KinopoiskAPI
|
2
|
-
class Top < Agent
|
3
|
-
attr_accessor :url
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@url = "#{DOMAINS[:api]}/#{METHODS[:get_today_films][:method]}"
|
7
|
-
@json = json
|
8
|
-
raise todo
|
9
|
-
end
|
10
|
-
|
11
|
-
def films_view
|
12
|
-
films.map do |film|
|
13
|
-
{
|
14
|
-
id: int_data(String, film['id' ]),
|
15
|
-
kp_type: str_data(String, film['type' ]),
|
16
|
-
name_ru: str_data(String, film['nameRU' ]),
|
17
|
-
name_en: str_data(String, film['nameEN' ]),
|
18
|
-
slogan: str_data(String, film['slogan' ]),
|
19
|
-
description: str_data(String, film['description' ]),
|
20
|
-
poster_url: url_data(String, film['posterURL' ], film["id"], :film),
|
21
|
-
year: int_data(String, film['year' ]),
|
22
|
-
reviews_count: int_data(String, film['reviewsCount']),
|
23
|
-
duration: min_data(String, film['filmLength' ]),
|
24
|
-
countries: arr_data(String, film['country' ]),
|
25
|
-
genres: arr_data(String, film['genre' ]),
|
26
|
-
video: film['videoURL'],
|
27
|
-
is_sequel_or_prequel: bool_data(String, film['hasSequelsAndPrequelsFilms']),
|
28
|
-
is_similar_films: bool_data(String, film['hasRelatedFilms' ]),
|
29
|
-
is_imax: bool_data(String, film['isIMAX' ]),
|
30
|
-
is_3d: bool_data(String, film['is3D' ]),
|
31
|
-
rating_mpaa: str_data(String, film['ratingMPAA' ]),
|
32
|
-
minimal_age: int_data(String, film['ratingAgeLimits' ])
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|