mirror of
https://git.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-24 20:00:56 +01: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 src.imdb_datasets_worker import get_title_by_names_and_year
|
||||||
|
from loguru import logger
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -13,12 +14,14 @@ with open(".auth_kinopoisk", mode='rt') as key_file:
|
||||||
def get_kinopoisk_movie_to_imdb(film=list):
|
def get_kinopoisk_movie_to_imdb(film=list):
|
||||||
films_resolved = []
|
films_resolved = []
|
||||||
for i in film:
|
for i in film:
|
||||||
|
logger.debug(f'запрос id {i} у Кинопоиска')
|
||||||
headers = {
|
headers = {
|
||||||
"X-API-KEY": token,
|
"X-API-KEY": token,
|
||||||
}
|
}
|
||||||
r = requests.get(kinopoisk_api_url + "/films/" + i, headers=headers)
|
r = requests.get(kinopoisk_api_url + "/films/" + i, headers=headers)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
film_data = r.json()
|
film_data = r.json()
|
||||||
|
logger.debug('КП ответил: ' + film_data)
|
||||||
|
|
||||||
films_resolved.append((film_data['nameOriginal'], film_data['nameRu'], film_data['year']))
|
films_resolved.append((film_data['nameOriginal'], film_data['nameRu'], film_data['year']))
|
||||||
else:
|
else:
|
||||||
|
@ -27,5 +30,8 @@ def get_kinopoisk_movie_to_imdb(film=list):
|
||||||
|
|
||||||
parsed_imdb_titles = get_title_by_names_and_year(films_resolved)
|
parsed_imdb_titles = get_title_by_names_and_year(films_resolved)
|
||||||
if parsed_imdb_titles != []:
|
if parsed_imdb_titles != []:
|
||||||
|
logger.success('Найдены запрошенные фильмы КП у IMDB')
|
||||||
return parsed_imdb_titles
|
return parsed_imdb_titles
|
||||||
|
else:
|
||||||
|
logger.error('Запрошенные фильмы КП не найдены у IMDB ' + films_resolved)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user