kp_api 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6fa496418a1f5b7a34159426acdbe37602e2e048
4
+ data.tar.gz: 8a615ed5fd17747e95dfc4f87dfa6e1fecf4745d
5
+ SHA512:
6
+ metadata.gz: c036fcba5866d3be6f5082dca0c8ec912ddbbf6fd036e8c35b3f07b76b593dc710a52b8d42c1619381b4df0fff644104d5025e89b5140bcf4553d327ff61f727
7
+ data.tar.gz: fa65c8f057a8e219c971b2ed31f092d6ee3619029ad68ec435ab7edf1bbe9da09f1491e456a5f9d69994cb5ec878c26203e5fae0181f0b3d1e3f32b9d6603cf1
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp/*
6
+ .yardoc/*
7
+ .idea/*
8
+ spec/support/credentials.yml
9
+ doc/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ya@hav0k.ru. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in KpApi.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Alexey Vilyaev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # КиноПоиск API (Gem) [![Build Status](https://travis-ci.org/groverz/kp_api.svg?branch=master)](https://travis-ci.org/groverz/kp_api)
2
+ Этот gem создан для упрощения работы с КиноПоиск API в проектах на Ruby.
3
+ Гем работает через API от кинопоиска.
4
+ Используется соответственно не официально, прикидываясь андроидом.
5
+
6
+ ### Что нового
7
+ * Изменено название гема.
8
+ * Восстановлена работа API использует последнюю версию подписи 5.0.0.
9
+ * Написаны тесты.
10
+ * Добавлен travis-ci
11
+
12
+ ## Установка
13
+ Добавьте эту строку в Gemfile вашего приложения:
14
+ ```ruby
15
+ gem 'kp_api'
16
+ ```
17
+
18
+ Затем выполните:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ ## Использование
24
+ ### Глобальные функции
25
+ ```ruby
26
+ api = KpApi::[Class]
27
+ ```
28
+ ```ruby
29
+ api.status
30
+ # > true [Получена следующая станица]
31
+ # > false [Достигли конца пагинации]
32
+ ```
33
+ ```ruby
34
+ # Оригинальный хеш кинопоиска
35
+ api.data
36
+ ```
37
+ ```ruby
38
+ # Оригинальный хеш кинопоиска (используется в некоторых классах для дополнительного запроса).
39
+ # Пример: film.peoples_full)
40
+ api.data2
41
+ ```
42
+ ```ruby
43
+ # Статус парсинга json
44
+ # Boolean
45
+ api.status
46
+ ```
47
+ ```ruby
48
+ # Статус парсинга json дополнительного запроса.
49
+ # Boolean
50
+ api.status2
51
+ ```
52
+ ### Исключения
53
+ При ошибке выбрасывается исключение __KpApi::ApiError__. Доступные методы.
54
+ ```ruby
55
+ # http код ответа
56
+ e.code
57
+ => "404"
58
+ ```
59
+ ```ruby
60
+ # Тело ответа
61
+ e.body
62
+ => [key:false]
63
+ ```
64
+ ### Классы
65
+ Практически каждый метод имеет отдельный класс. При инициализации класса
66
+ выполняется запрос к АПИ, возвращая текущий объект или исключение.
67
+ #### Фильм
68
+ ```ruby
69
+ film = KpApi::Film.new(film_id)
70
+ ```
71
+ ```ruby
72
+ # Вся информация о фильме(включая rating, rent, budget).
73
+ film.view
74
+ ```
75
+ ```ruby
76
+ # Рейтинги фильма и т.д.
77
+ film.rating
78
+ ```
79
+ ```ruby
80
+ # Даты премьер и т.д.
81
+ film.rent
82
+ ```
83
+ ```ruby
84
+ # Бюджет и сборы.
85
+ film.budget
86
+ ```
87
+ ```ruby
88
+ # Люди связанные с фильмом(Не полный список, смотрите ниже).
89
+ film.peoples
90
+ ```
91
+ ```ruby
92
+ # Люди связанные с фильмом(Полный список). Генерирует новый запрос к API.
93
+ film.peoples_full
94
+ ```
95
+ #### Люди(Режиссеры, актеры, операторы и т.д.).
96
+ Сервер не выдаёт __404__ на не существующего человека.
97
+ Исключение реализовано проверкой(NameRu, nameEn).
98
+ ```ruby
99
+ people = KpApi::People.new(people_id)
100
+ ```
101
+ ```ruby
102
+ # Детальная информация о человеке.
103
+ people.view
104
+ ```
105
+ ```ruby
106
+ # Фильмы связанные с конкретным человеком.
107
+ people.films
108
+ ```
109
+ ```ruby
110
+ # Массив id фильмов связанных с конкретным человеком.
111
+ people.films_ids
112
+ ```
113
+ #### Категории
114
+ Список категорий, не понятно для чего нужен параметр `country_id`, но без него не
115
+ проходит запрос. По умолчанию 2(Россия).
116
+ ```ruby
117
+ category = KpApi::Category.new(country_id=2)
118
+ ```
119
+ ```ruby
120
+ # Страны
121
+ category.countries
122
+ ```
123
+ ```ruby
124
+ # Страны (требует доп. запроса)
125
+ category.cities
126
+ ```
127
+ ```ruby
128
+ # Жанры
129
+ category.genres
130
+ ```
131
+ #### Сегодня в кино
132
+ Список фильмов идущих сегодня в кино.
133
+ Если города не существует возвращает пустой массив.
134
+
135
+ * Параметр `city_id` не обязательный, по умолчанию 1(Москва).
136
+ * Параметр `country_id` не обязательный, по умолчанию 2(Россия).
137
+ Возможно не используется, т.к. первый уникальный, но приложение передает его в заголовках.
138
+
139
+ Доступны только эти страны:
140
+ * 2 - Россия
141
+ * 62 - Украина
142
+ * 69 - Беларусь
143
+ * 122 - Казахстан
144
+ * 71 - Узбекистан
145
+ ```ruby
146
+ today = KpApi::Today.new(city_id=1, country_id=2)
147
+ ```
148
+ ```ruby
149
+ # Список фильмов
150
+ today.view
151
+ ```
152
+ ```ruby
153
+ # Массив id фильмов
154
+ today.film_ids
155
+ ```
156
+ ### Поиск
157
+ #### Глобальный поиск
158
+ ```ruby
159
+ search = KpApi::GlobalSearch.new('Бразилия')
160
+ ```
161
+ ```ruby
162
+ # Найдено ли что-нибудь
163
+ search.found?
164
+ ```
165
+ ```ruby
166
+ # Количество найденных фильмов
167
+ search.films_count
168
+ ```
169
+ ```ruby
170
+ # Количество найденных фильмов
171
+ search.peoples_count
172
+ ```
173
+ ```ruby
174
+ # Скорее всего вы искали этот фильм
175
+ search.youmean
176
+ ```
177
+ ```ruby
178
+ # Остальные найденные фильмы(лимит: 3)
179
+ search.films
180
+ ```
181
+ ```ruby
182
+ # Или даже этих людей
183
+ search.peoples
184
+ ```
185
+ #### Поиск по фильмам
186
+ ```ruby
187
+ search = KpApi::FilmSearch.new('Привет')
188
+ ```
189
+ ```ruby
190
+ # Найдено ли что-нибудь)
191
+ search.found?
192
+ ```
193
+ ```ruby
194
+ # Список фильмов (не более 20)
195
+ search.view
196
+ ```
197
+ ```ruby
198
+ # Количество найденных фильмов
199
+ search.films_count
200
+ ```
201
+ ```ruby
202
+ # Текущая страница
203
+ search.current_page
204
+ ```
205
+ ```ruby
206
+ # Количество страниц
207
+ search.page_count
208
+ ```
209
+ ```ruby
210
+ # Следующая страница(новый запрос к АПИ)
211
+ search.next_page
212
+ # > true [Получена следующая станица]
213
+ # > false [Достигли конца пагинации]
214
+ ```
215
+ #### Поиск по людям
216
+ ```ruby
217
+ search = KpApi::PeopleSearch.new('Андрей')
218
+ ```
219
+ ```ruby
220
+ # Список людей (не более 20)
221
+ search.view
222
+ ```
223
+ ```ruby
224
+ # Количество найденных фильмов
225
+ search.peoples_count
226
+ ```
227
+ ```ruby
228
+ # Текущая страница
229
+ search.current_page
230
+ ```
231
+ ```ruby
232
+ # Количество страниц
233
+ search.page_count
234
+ ```
235
+ ```ruby
236
+ # Следующая страница
237
+ search.next_page
238
+ # > true [Получена следующая станица]
239
+ # > false [Достигли конца пагинации]
240
+ ```
241
+ #### Живой поиск
242
+ @to-do
243
+ ### Топы
244
+ @to-do
245
+
246
+
247
+
248
+ ##Благодарность
249
+ Всем кто связывался со мной. (@to-do)
250
+
251
+
252
+ ## License
253
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ desc 'Fires up the console with preloaded vkontakte_api'
4
+ task :console do
5
+ sh 'pry -I ./lib -r ./lib/kp_api'
6
+ end
7
+
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.rspec_opts = '--color --format doc'
11
+ end
12
+
13
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "KpApi"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/earch.exactly ADDED
@@ -0,0 +1,56 @@
1
+ => #<KpApi::GlobalSearch:0x000055a21448aa60
2
+ @json=
3
+ {"class"=>"KPGlobalSearch",
4
+ "keyword"=>"Бразилия",
5
+ "youmean"=>
6
+ {"id"=>"483",
7
+ "type"=>"KPFilm",
8
+ "nameRU"=>"Бразилия",
9
+ "nameEN"=>"Brazil",
10
+ "description"=>"Великобритания, Терри Гиллиам(фантастика)",
11
+ "filmLength"=>"2:18",
12
+ "year"=>"1985",
13
+ "country"=>"Великобритания",
14
+ "genre"=>"фантастика, драма",
15
+ "rating"=>"7.8",
16
+ "ratingVoteCount"=>"22 873",
17
+ "videoURL"=>
18
+ {"hd"=>"https://www.kinopoisk.ru/gettrailer.php?from_src=android&quality=hd&trailer_id=87264",
19
+ "sd"=>"https://www.kinopoisk.ru/gettrailer.php?from_src=android&quality=sd&trailer_id=87264",
20
+ "low"=>"https://www.kinopoisk.ru/gettrailer.php?from_src=android&quality=low&trailer_id=87264"},
21
+ "posterURL"=>"film_iphone/iphone_483.jpg"},
22
+ "searchFilms"=>
23
+ [{"id"=>"16143",
24
+ "type"=>"KPFilm",
25
+ "nameRU"=>"Бразилия",
26
+ "nameEN"=>"Brazil",
27
+ "description"=>"США, Джозеф Сэнтли(мюзикл)",
28
+ "posterURL"=>"film_iphone/iphone_16143.jpg",
29
+ "filmLength"=>"1:00",
30
+ "year"=>"1944",
31
+ "country"=>"США",
32
+ "genre"=>"мюзикл, мелодрама, комедия"},
33
+ {"id"=>"122996",
34
+ "type"=>"KPFilm",
35
+ "nameRU"=>"Бразилия",
36
+ "nameEN"=>"Brasil",
37
+ "description"=>"Испания, Ф. Хавьер Гутьеррес(короткометражка)",
38
+ "posterURL"=>"film_iphone/iphone_122996.jpg",
39
+ "filmLength"=>"0:18",
40
+ "year"=>"2002",
41
+ "country"=>"Испания",
42
+ "genre"=>"короткометражка, фэнтези, триллер"},
43
+ {"id"=>"892287",
44
+ "type"=>"KPFilm",
45
+ "nameRU"=>"Дикая Бразилия (мини-сериал)",
46
+ "nameEN"=>"Wild Brazil",
47
+ "description"=>"Великобритания, Adam White(документальный)",
48
+ "filmLength"=>"3:00",
49
+ "year"=>"2014",
50
+ "country"=>"Великобритания",
51
+ "genre"=>"документальный"}],
52
+ "searchFilmsCountResult"=>44,
53
+ "searchPeople"=>[{"id"=>"897172", "type"=>"KPPeople", "nameRU"=>"Энцо Бразиль", "nameEN"=>"Enzo Brasil", "description"=>"Актер"}],
54
+ "searchPeoplesCountResult"=>1},
55
+ @keyword="%D0%91%D1%80%D0%B0%D0%B7%D0%B8%D0%BB%D0%B8%D1%8F",
56
+ @url="https://ext.kinopoisk.ru/ios/5.0.0/getKPGlobalSearch?keyword=%D0%91%D1%80%D0%B0%D0%B7%D0%B8%D0%BB%D0%B8%D1%8F">
data/kp_api.gemspec ADDED
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "kp_api/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kp_api"
8
+ spec.version = KpApi::VERSION
9
+ spec.authors = ["Alexey Vildyaev"]
10
+ spec.email = ["ya@hav0k.ru"]
11
+ spec.homepage = 'https://github.com/groverz/kp_api'
12
+
13
+ spec.summary = %q{Ruby wrapper for KinoPoisk API}
14
+ spec.description = %q{Gem is based on the mobile API. Search, details, films, people.}
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split("\n")
18
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 1.9.2'
22
+
23
+ spec.add_runtime_dependency 'hashie', '>= 2.0'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'awesome_print'
30
+
31
+ end