Getting movie ID from filmography in IMDbPy results

只谈情不闲聊 提交于 2021-02-08 15:13:46

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/55500337/getting-movie-id-from-filmography-in-imdbpy-results

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!