Skip to content

Commit

Permalink
feature: replace current api with https://kinopoiskapiunofficial.tech/ (
Browse files Browse the repository at this point in the history
#83)

* feature: replace current api with https://kinopoiskapiunofficial.tech/

* chore: update deps, add docs

* feature: add staff api
  • Loading branch information
TrueDevProfile authored Dec 19, 2020
1 parent 416792c commit c07f85c
Show file tree
Hide file tree
Showing 126 changed files with 594 additions and 1,689 deletions.
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'org.jetbrains.kotlin.jvm' version '1.4.20'
}

group 'com.truedev'
Expand All @@ -16,13 +16,12 @@ configurations {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "com.google.guava:guava:29.0-jre"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.2"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.2"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.2"
implementation "com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.2"
implementation 'com.github.kittinunf.fuel:fuel:2.2.2'
implementation 'com.github.kittinunf.fuel:fuel-jackson:2.2.2'
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.0"
implementation "com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.0"
implementation 'com.github.kittinunf.fuel:fuel:2.3.1'
implementation 'com.github.kittinunf.fuel:fuel-jackson:2.3.1'

ktlint "com.pinterest:ktlint:0.36.0"

Expand All @@ -44,6 +43,7 @@ task ktlintFormat(type: JavaExec, group: "formatting") {
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Expand Down
110 changes: 63 additions & 47 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,81 @@
# Kinopoisk Api

A library for easy access to the Kinopoisk data.

## How to use
* Add the JitPack repository to your build file

build.gradle

allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}

or pom.xml

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://www.jitpack.io</url>
</repository>
</repositories>
## Installation

* Add the dependency
* Add the JitPack repository to your build file

build.gradle

dependencies {
implementation 'com.github.TrueDevProfile:kinopoisk-api:0.2.0'
```groovy
allprojects {
repositories {
maven { url 'https://www.jitpack.io' }
}
or pom.xml
}
```

or pom.xml

```xml

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://www.jitpack.io</url>
</ repository>
</ repositories>
```

* Add the dependency

<dependency>
<groupId>com.github.TrueDevProfile</groupId>
<artifactId>kinopoisk-api</artifactId>
<version>0.2.0</version>
</dependency>
* After that you can use library's methods. E.g. to get film by kinopoisk id:
build.gradle

```groovy
dependencies {
implementation 'com.github.TrueDevProfile:kinopoisk-api:0.2.0'
}
```

or pom.xml

KinopoiskApiService kinopoiskExtApiService = new KinopoiskApiService();
FilmExt filmInfo = kinopoiskExtApiService.getFilmInfo(1234);
```xml

<dependency>
<groupId>com.github.TrueDevProfile</groupId>
<artifactId>kinopoisk-api</artifactId>
<version>0.2.0</ version>
</dependency>
```

## How to use

You should sign up and get an access token here https://kinopoiskapiunofficial.tech/. Then you can use token to use api:

## Api methods
* Kotlin

* `kinopoiskExtApiService.getFilmInfo(filmId)` retrieves all data about the film by id.
* `kinopoiskExtApiService.getStaffList(filmId)` retrieves data about the staff (actors, producers and so on) by film id.
* `kinopoiskExtApiService.getGallery(filmId)` retrieves gallery(posters, footage for the film and so no) by film id.
* `kinopoiskExtApiService.getKPReviews(filmId)` retrieves reviews by film id. It does not contain full review text.
* `kinopoiskExtApiService.getReviewDetail(reviewId)` retrieves review full data by particular review id.
* `kinopoiskExtApiService.getKPPeopleDetailView(peopleId)` retrieves detail info of staff person(actor, producer and so on).
* `kinopoiskExtApiService.getKPTop()` retrieves top of films according the params.
* `kinopoiskExtApiService.getKPSearchInFilms()`does a search in films by keyword.
* `kinopoiskExtApiService.getKPSearchInPeople()`does a search in people by keyword.
* `kinopoiskExtApiService.getNavigator()` does an advanced search of films by filters.
* `kinopoiskExtApiService.getDigital()` retrieves digital releases for particular month/year.
```kotlin
val kinopoiskApiService = KinopoiskApiService("api token")
val result = kinopoiskApiService.getFilm(301)
when (result) {
is Result.Success -> result.getOrNull() /*actually null is possible only for Failure*/
is Result.Failure -> /*handle somehow*/
}
```

## WEB Api
or

All these methods and more are available via web API https://kinopoiskapiunofficial.tech
```kotlin
val kinopoiskApiService = KinopoiskApiService("api token")
// if success it will return value otherwise it will be null
val result = kinopoiskApiService.getFilm(301).getOrNull()
```

* Java

```java
KinopoiskApiService kinopoiskApiService = new KinopoiskApiService("api token",15000);
// if success it will return value otherwise it will be null
Film film = kinopoiskApiService.getFilm(301,new ArrayList<>()).getOrNull();
```

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/kotlin/com/truedev/kinoposk/api/model/ResponseExt.kt

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/kotlin/com/truedev/kinoposk/api/model/Result.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.truedev.kinoposk.api.model

sealed class Result<T> {
abstract fun getOrThrowException(): T
abstract fun getOrNull(): T?

data class Success<T>(val httpStatus: Int, val result: T) : Result<T>() {
override fun getOrThrowException(): T = result
override fun getOrNull(): T = result
}

data class Failure<T>(val httpStatus: Int, val error: String) : Result<T>() {
override fun getOrThrowException(): T = throw UnsupportedOperationException()
override fun getOrNull(): T? = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.truedev.kinoposk.api.model.common

data class Country(val id: Int, val country: String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.truedev.kinoposk.api.model.common

data class Genre(val id: Int, val genre: String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.truedev.kinoposk.api.model.common

enum class KinopoiskItemType {
FILM, TV_SHOW, UNKNOWN;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit c07f85c

Please sign in to comment.