Open In App
Related Articles

Python IMDbPY – Getting list of movies performed by the actor

Improve Article
Improve
Save Article
Save
Like Article
Like

In this article we will see how we can get the list of movies in which actor has performed i.e an actor performs in various movies. IMDb has a database of almost every movie performed by verified actors. In order to get the list of all the movies performed by the actor we have to get the details of filmography of the actor

Syntax : results = ia.get_person_filmography(ID) Here ia is the IMDb object 

Argument : It takes Id as argument 

Return : It returns dictionary This method returns the complicated dictionary which is hard to read in order to get the titles of the movie we use results[‘data’][‘filmography’][0][‘actor’][index]

Below is the implementation 

Python3




# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "1372788"
 
# printing person name
print(ia.get_person(code))
 
# getting information
actor_results = ia.get_person_filmography(code)
 
# printing movie name
for index in range(5):
    movie_name = actor_results['data']['filmography'][0]['actor'][index]
    print(movie_name)


Output :

Shahid Kapoor
Jersey Hindi Remake
Sachet Tandon: Bekhayali
Kabir Singh
The Insider's Watchlist
Akhil Sachdeva & Tulsi Kumar: Tera Ban Jaunga

Another example 

Python3




# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "0001098"
 
# printing person name
print(ia.get_person(code))
 
# getting information
actor_results = ia.get_person_filmography(code)
 
# printing movie name
for index in range(5):
    movie_name = actor_results['data']['filmography'][0]['actor'][index]
    print(movie_name)


Output :

Rodney Dangerfield
Angels with Angles
Still Standing
Back by Midnight
Phil of the Future
The Electric Piper

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 23 May, 2022
Like Article
Save Article
Similar Reads
Related Tutorials