Spaces:
Sleeping
Sleeping
| from imdb import IMDb | |
| # Create a global IMDb instance | |
| ia = IMDb() | |
| def search_imdb(title: str): | |
| """ | |
| Search for a movie by title and return the most relevant result. | |
| """ | |
| results = ia.search_movie(title) | |
| if not results: | |
| return {"error": "No results found"} | |
| top_result = results[0] | |
| ia.update(top_result) # fetch full details | |
| return { | |
| "Title": top_result.get("title"), | |
| "Year": top_result.get("year"), | |
| "Rating": top_result.get("rating"), | |
| "Genres": top_result.get("genres"), | |
| "Plot": top_result.get("plot", ["No plot available"])[0], | |
| } | |