def run(self): import jikan import tmdb import tvmaze api_map = { "tvmaze": tvmaze.TvMazeApi(), "tmdb": tmdb.TmdbApi(), "mal": jikan.JikanApi(), } s = self.item["api_info"].split("_") api_name = s[0] api_id = s[1] api_ret = { api_name: api_map[api_name].get_item(api_id) } del self.item["username"] del self.item["item_id"] if self.remove_status: del self.item["status"] self.item = {**api_ret, **self.item} items_lock.acquire() merged_items.append(self.item) items_lock.release()
from datetime import datetime import jikan import tmdb import tvmaze import updates import reviews_db tmdb_api = tmdb.TmdbApi() tvmaze_api = tvmaze.TvMazeApi() jikan_api = jikan.JikanApi() def handler(event, context): _check_tmdb_updates() _check_tvmaze_updates() _check_mal_updates() def _check_tmdb_updates(): tmdb_updates = tmdb_api.get_all_changes() for update in tmdb_updates: tmdb_id = update["id"] try: reviews_db.get_items("tmdb", tmdb_id) except reviews_db.NotFoundError: # Show not present in db, exclude it from updates continue