pythonimdbimdbpy

Getting movie ID from filmography in IMDbPy results


I'm trying to create a dataset that allows me to join actors and movies based on actor IDs and movie IDs from the Python IMDb API. Right now, I am trying to extract a list of movie IDs from an actor's filmography and cannot do it.

For example, I know the ID for Rodney Dangerfield on IMDb is 0001098. I can see his whole filmography with:

from imdb import IMDb
ia = IMDb()

actor_results = ia.get_person_filmography('0001098')

which returns a large dictionary. I can see the most recent movie where he had an acting credit with:

actor_results['data']['filmography'][0]['actor'][0]

which returns:

<Movie id:0179803[http] title:_Angels with Angles (2005)_>

This object type is imdb.Movie.Movie. This object has a few key/value pairs:

In: results['data']['filmography'][0]['actor'][0].items()
Out: 
[('title', 'Angels with Angles'),
 ('kind', 'movie'),
 ('year', 2005),
 ('canonical title', 'Angels with Angles'),
 ('long imdb title', 'Angels with Angles (2005)'),
 ('long imdb canonical title', 'Angels with Angles (2005)'),
 ('smart canonical title', 'Angels with Angles'),
 ('smart long imdb canonical title', 'Angels with Angles (2005)')]

But there's no ID key. And when I try to convert the IMDb object to a string with str(results['data']['filmography'][0]['actor'][0]), I just get 'Angels with Angels'.

Is there a way to get the Movie ID from the IMDb object?


Solution

  • results['data']['filmography'][0]['actor'][0].getID()