mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-12 16:23:01 +00:00
Extended logging Kinopoisk
This commit is contained in:
parent
ea80e549f4
commit
02ffb30fcb
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user