From 02ffb30fcb4ef430aa73805966475ba121b8831e Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Sat, 10 Sep 2022 23:31:23 +0300 Subject: [PATCH] Extended logging Kinopoisk --- src/kinopoisk_api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kinopoisk_api.py b/src/kinopoisk_api.py index 614ee91..b26841f 100644 --- a/src/kinopoisk_api.py +++ b/src/kinopoisk_api.py @@ -1,4 +1,5 @@ from src.imdb_datasets_worker import get_title_by_names_and_year +from loguru import logger import requests import time @@ -13,12 +14,14 @@ with open(".auth_kinopoisk", mode='rt') as key_file: def get_kinopoisk_movie_to_imdb(film=list): films_resolved = [] for i in film: + logger.debug(f'запрос id {i} у Кинопоиска') headers = { "X-API-KEY": token, } r = requests.get(kinopoisk_api_url + "/films/" + i, headers=headers) if r.status_code == 200: film_data = r.json() + logger.debug('КП ответил: ' + film_data) films_resolved.append((film_data['nameOriginal'], film_data['nameRu'], film_data['year'])) else: @@ -27,5 +30,8 @@ def get_kinopoisk_movie_to_imdb(film=list): parsed_imdb_titles = get_title_by_names_and_year(films_resolved) if parsed_imdb_titles != []: + logger.success('Найдены запрошенные фильмы КП у IMDB') return parsed_imdb_titles + else: + logger.error('Запрошенные фильмы КП не найдены у IMDB ' + films_resolved)