从 IMDbPy 结果中的片目中获取电影 ID

2024-06-21

我正在尝试创建一个数据集,允许我根据 Python IMDb API 中的演员 ID 和电影 ID 加入演员和电影。现在,我正在尝试从演员的电影作品中提取电影 ID 列表,但无法做到。

例如,我知道 Rodney Dangerfield 在 IMDb 上的 ID 是 0001098。我可以通过以下方式查看他的整个电影作品:

from imdb import IMDb
ia = IMDb()

actor_results = ia.get_person_filmography('0001098')

它返回一个大字典。我可以看他最近主演的一部电影:

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

返回:

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

这个对象类型是imdb.Movie.Movie。该对象有几个键/值对:

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)')]

但没有 ID 密钥。当我尝试将 IMDb 对象转换为字符串时str(results['data']['filmography'][0]['actor'][0]),我刚刚得到'Angels with Angels'.

有没有办法从 IMDb 对象获取电影 ID?


results['data']['filmography'][0]['actor'][0].getID()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

从 IMDbPy 结果中的片目中获取电影 ID 的相关文章

随机推荐