Extended logging Kinopoisk

This commit is contained in:
localhost_frssoft 2022-09-10 23:31:23 +03:00
parent ea80e549f4
commit 02ffb30fcb

View File

@ -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)