Skip to content

Commit

Permalink
Merge pull request #1 from masterWeber/feature/films-premieres
Browse files Browse the repository at this point in the history
Добавлен график кинопремьер
  • Loading branch information
masterWeber authored Dec 23, 2021
2 parents 1518b12 + 7bb4798 commit d13455b
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 7 deletions.
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ request = FilmFrameRequest(507)
response = api_client.films.send_film_frame_request(request)
```

### Получить трейлеры,тизеры,видео для фильма по kinopoisk film id
### Получить трейлеры, тизеры, видео для фильма по kinopoisk film id

Возвращает трейлеры,тизеры,видео для фильма по kinopoisk film id.
Возвращает трейлеры, тизеры, видео для фильма по kinopoisk film id.

* `Эндпоинт`: /api/v2.2/films/{id}/videos
* `Метод`: send_film_video_request(request: FilmVideoRequest) -> FilmVideoResponse
Expand Down Expand Up @@ -212,7 +212,7 @@ response = api_client.films.send_film_search_by_filters_request(request)
### Получить список фильмов из различных топов или коллекций

Возвращает список фильмов с пагинацией. Каждая страница содержит не более чем 20 фильмов.
Например https://www.kinopoisk.ru/top/lists/58/.
Например: https://www.kinopoisk.ru/top/lists/58/.

* `Эндпоинт`: /api/v2.2/films/top
* `Метод`: send_film_top_request(request: FilmTopRequest) -> FilmTopResponse
Expand Down Expand Up @@ -245,7 +245,7 @@ response = api_client.films.send_related_film_request(request)

### Получить список цифровых релизов

Возвращает список цифровых релизов. Например https://www.kinopoisk.ru/comingsoon/digital/
Возвращает список цифровых релизов. Например: https://www.kinopoisk.ru/comingsoon/digital/

* `Эндпоинт`: /api/v2.1/films/releases
* `Метод`: send_digital_release_request(request: DigitalReleaseRequest) -> DigitalReleaseResponse
Expand All @@ -260,6 +260,24 @@ request = DigitalReleaseRequest(2021, Month.SEPTEMBER)
response = api_client.films.send_digital_release_request(request)
```

### Получить график кинопремьер

Возвращает список кинопремьер. Например: https://www.kinopoisk.ru/premiere/

* `Эндпоинт`: /api/v2.2/films/premieres
* `Метод`: send_premiere_request(request: PremiereRequest) -> PremiereResponse

```python
from kinopoisk_unofficial.kinopoisk_api_client import KinopoiskApiClient
from kinopoisk_unofficial.model.dictonary.month import Month
from kinopoisk_unofficial.request.films.premiere_request import PremiereRequest

api_client = KinopoiskApiClient('<your_token>')

request = PremiereRequest(2021, Month.DECEMBER)
response = api_client.films.send_premiere_request(request)
```

## reviews

Набор методов для работы с ревью о фильмах
Expand Down Expand Up @@ -301,9 +319,9 @@ response = api_client.reviews.send_review_details_request(request)

Набор методов для работы с данными об актерах, режиссерах и т.д.

### Получить данные об актерах, режисерах и т.д. по kinopoisk film id
### Получить данные об актерах, режиссерах и т.д. по kinopoisk film id

Возвращает данные об актерах, режисерах и т.д. по kinopoisk film id
Возвращает данные об актерах, режиссерах и т.д. по kinopoisk film id

* `Эндпоинт`: /api/v1/staff
* `Метод`: send_staff_request(request: StaffRequest) -> StaffResponse
Expand Down
5 changes: 5 additions & 0 deletions kinopoisk_unofficial/client/films_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from kinopoisk_unofficial.request.films.film_top_request import FilmTopRequest
from kinopoisk_unofficial.request.films.film_video_request import FilmVideoRequest
from kinopoisk_unofficial.request.films.filters_request import FiltersRequest
from kinopoisk_unofficial.request.films.premiere_request import PremiereRequest
from kinopoisk_unofficial.request.films.related_film_request import RelatedFilmRequest
from kinopoisk_unofficial.request.films.search_by_keyword_request import SearchByKeywordRequest
from kinopoisk_unofficial.request.films.seasons_request import SeasonsRequest
Expand All @@ -24,6 +25,7 @@
from kinopoisk_unofficial.response.films.film_top_response import FilmTopResponse
from kinopoisk_unofficial.response.films.film_video_response import FilmVideoResponse
from kinopoisk_unofficial.response.films.filters_response import FiltersResponse
from kinopoisk_unofficial.response.films.premiere_response import PremiereResponse
from kinopoisk_unofficial.response.films.related_film_respons import RelatedFilmResponse
from kinopoisk_unofficial.response.films.search_by_keyword_response import SearchByKeywordResponse
from kinopoisk_unofficial.response.films.seasons_response import SeasonsResponse
Expand Down Expand Up @@ -74,3 +76,6 @@ def send_related_film_request(self, request: RelatedFilmRequest) -> RelatedFilmR

def send_digital_release_request(self, request: DigitalReleaseRequest) -> DigitalReleaseResponse:
return self._send_request(request)

def send_premiere_request(self, request: PremiereRequest) -> PremiereResponse:
return self._send_request(request)
2 changes: 2 additions & 0 deletions kinopoisk_unofficial/kinopoisk_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class KinopoiskApiClient:
__base_url: str = 'https://kinopoiskapiunofficial.tech'
__films: FilmsApiClient
__reviews: ReviewsApiClient
__staff: StaffApiClient

def __init__(self, token: str) -> None:
http_client = HttpClient(self.__base_url)
Expand Down
20 changes: 20 additions & 0 deletions kinopoisk_unofficial/model/premiere_film.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from datetime import datetime
from dataclasses import dataclass, field
from typing import List

from kinopoisk_unofficial.model.country import Country
from kinopoisk_unofficial.model.genre import Genre


@dataclass
class PremiereFilm:
kinopoisk_id: int
name_ru: str
name_en: str
year: int
poster_url: str
poster_url_preview: str
duration: int
premiereRu: datetime
countries: List[Country] = field(default_factory=list)
genres: List[Genre] = field(default_factory=list)
31 changes: 31 additions & 0 deletions kinopoisk_unofficial/request/films/premiere_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from kinopoisk_unofficial.client.http_method import HttpMethod
from kinopoisk_unofficial.contract.request import Request
from kinopoisk_unofficial.model.dictonary.month import Month
from kinopoisk_unofficial.response.films.premiere_response import PremiereResponse


class PremiereRequest(Request):
METHOD: HttpMethod = HttpMethod.GET
PATH: str = '/api/v2.2/films/premieres'
RESPONSE: type = PremiereResponse

__year: int
__month: Month

def __init__(self, year: int, month: Month) -> None:
self.__year = year
self.__month = month

@property
def year(self) -> int:
return self.__year

@property
def month(self) -> Month:
return self.__month

def path(self) -> str:
return self._build_url(self.PATH, {
'year': self.year,
'month': self.month.value
})
11 changes: 11 additions & 0 deletions kinopoisk_unofficial/response/films/premiere_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses import dataclass, field
from typing import List

from kinopoisk_unofficial.contract.response import Response
from kinopoisk_unofficial.model.premiere_film import PremiereFilm


@dataclass(frozen=True)
class PremiereResponse(Response):
total: int
items: List[PremiereFilm] = field(default_factory=list)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setuptools.setup(
name="kinopoisk-api-unofficial-client",
version="1.0.2",
version="1.1.0",
author="Master Weber",
author_email="[email protected]",
description="API Client for the unofficial Kinopoisk api",
Expand Down

0 comments on commit d13455b

Please sign in to comment.