gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 02:02:07 25 4
gpt4 key购买 nike

我正在尝试创建一个数据集,允许我根据来自 Python IMDb API 的 Actor ID 和电影 ID 加入 Actor 和电影。现在,我正在尝试从 Actor 的电影作品中提取电影 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 key 。当我尝试使用 str(results['data']['filmography'][0]['actor'][0]) 将 IMDb 对象转换为字符串时,我得到 “天使与天使”

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

最佳答案

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

关于python - 从 IMDbPy 结果中的片目中获取电影 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55500337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com