Python IMDbPY – Getting list of movies performed by the actor

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 almst 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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

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

Another example

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

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

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.