Cinemagoer (formerly IMDbPY)
raw JSON → 2023.5.1 verified Fri May 01 auth: no python maintenance
Cinemagoer (previously IMDbPY) is a Python package for accessing and retrieving data from IMDb's database. It scrapes movie, person, character, and company data from IMDb web pages. Version 2023.5.1 is the latest release. The project is now under maintenance mode with occasional fixes.
pip install cinemagoer Common errors
error ModuleNotFoundError: No module named 'imdb' ↓
cause The package has been renamed to cinemagoer; installing cinemagoer creates a package named 'imdb'.
fix
Run 'pip install cinemagoer' (not 'pip install imdb'). Then import from 'imdb'.
error AttributeError: module 'imdb' has no attribute 'IMDb' ↓
cause Using old import 'from imdb import IMDb' with cinemagoer >= 2022.1.16; the class was renamed to Cinemagoer.
fix
Use 'from imdb import Cinemagoer' and instantiate with 'ia = Cinemagoer()'.
Warnings
breaking Renamed package: IMDbPY has been renamed to cinemagoer. The old 'IMDb' class is deprecated; use 'Cinemagoer' instead. ↓
fix Change import from 'from imdb import IMDb' to 'from imdb import Cinemagoer'.
breaking Exceptions raised by default: Since 2022.1.16, by default exceptions are raised on errors instead of returning None. Previously, some methods returned None on failure. ↓
fix Catch IMDbError exceptions or use the 'reraise_exceptions' parameter to control behavior.
gotcha Scraping heavy: The library scrapes IMDb's website, which can be slow and may be blocked if too many requests are made. Use caching and respect IMDb's robots.txt. ↓
fix Implement request throttling and caching to avoid IP bans.
gotcha Data format changes: IMDb regularly changes its HTML structure, so parsers can break unexpectedly. The library is maintenance-mode, so fixes may be delayed. ↓
fix Report issues on GitHub and consider using an official IMDb API if available.
Imports
- IMDb wrong
from imdb import IMDbcorrectfrom imdb import Cinemagoer
Quickstart
from imdb import Cinemagoer
# Create an instance of the Cinemagoer class
ia = Cinemagoer()
# Search for a movie
results = ia.search_movie('The Dark Knight')
for movie in results:
print(movie.movieID, movie['title'])
# Get a movie by ID
movie = ia.get_movie('0468569')
print(movie['title'], movie['year'])