from src.imdb_datasets_worker import get_title_by_names_and_year import requests import time kinopoisk_api_url='https://kinopoiskapiunofficial.tech/api/v2.2' # Используется неофициальное API кинопоиска, дефолтный лимит 500 запросов. with open(".auth_kinopoisk", mode='rt') as key_file: token = key_file.read().replace('\n', '') def get_kinopoisk_movie_to_imdb(film=list): films_resolved = [] for i in film: headers = { "X-API-KEY": token, } r = requests.get(kinopoisk_api_url + "/films/" + i, headers=headers) if r.status_code == 200: film_data = r.json() films_resolved.append((film_data['nameOriginal'], film_data['nameRu'], film_data['year'])) else: continue time.sleep(0.2) parsed_imdb_titles = get_title_by_names_and_year(films_resolved) if parsed_imdb_titles != []: return parsed_imdb_titles