How do I find a list of films performed by an actor?
I am using the below code to get a selection of a specific movie (Top 2 for example). How can I get a list of all films made by an actor / actress? For example, I choose the movie Inception (1375666) and the cast is Leonardo DiCaprio . So how can I get a list of all the films made by Leonardo DiCaprio?
from imdb import IMDb
ia = IMDb()
movie = ia.get_movie('1375666')
actor = movie['cast']
print "Cast: "
for i in actor[:2]:
for j in ia.search_person(str(i))[:1]:
print i, j.personID
+3
source to share
1 answer
It's pretty straightforward. Let's take actor
from your example and get the complete filmography:
>>> full_person = ia.get_person(actor[0].getID(), info=["filmography"])
>>> full_person.keys()
['name', u'producer', u'archive footage', u'self', u'writer', u'actor', u'soundtrack', 'in development', 'birth notes', u'thanks', 'akas', 'birth date', 'canonical name', 'long imdb name', 'long imdb canonical name']
>>> full_person["actor"]
[<Movie id:1663202[http] title: ...]
On the last line, you will find a list of films in which this person is an actor. But remember that ia.get_person(...)
you made an http request to imdb.com. And for the cast list, it might take a while.
+2
source to share