get the company info for a movie from IMDB using IMDBPY

梦想与她 提交于 2019-12-12 02:59:42

问题


I am trying to get the movie info, specifically I am interested in finding the company info (i.e. which company has made the movie). I am using IMDBPY package in python but I am cannot find the info about the company. I am wondering if anyone was able to retrieve the company info for a specific movie from IMDB. In the API description, it is stated that the company info is also available but I cannot find it. Only I can see this info and there is nothing about the company. Title: Genres: Director: Writer: Runtime: Country: Language: Rating: Plot: title: Cover url:


回答1:


You should post a snippet of the code you use. A working code example:

>>> from imdb import IMDb
>>> ia = IMDb()
>>> dp = ia.get_movie('1431045')
>>> print dp.keys()
[u'music department', 'sound crew', 'camera and electrical department', u'distributors', 'rating', 'runtimes', 'costume designer', u'thanks', 'make up', 'year', 'production design', 'miscellaneous crew', 'color info', u'casting department', 'languages', 'votes', 'producer', 'title', 'mpaa', 'assistant director', 'writer', 'production manager', 'casting director', 'visual effects', 'top 250 rank', 'set decoration', 'editor', 'certificates', u'costume department', 'country codes', 'language codes', 'cover url', u'special effects department', 'special effects companies', 'sound mix', 'genres', u'production companies', 'stunt performer', 'miscellaneous companies', 'cinematographer', 'art direction', 'akas', 'aspect ratio', 'director', 'kind', u'art department', 'countries', u'transportation department', 'plot outline', 'plot', 'cast', u'animation department', 'original music', u'editorial department', 'canonical title', 'long imdb title', 'long imdb canonical title', 'smart canonical title', 'smart long imdb canonical title', 'full-size cover url']
>>> print dp.get('production companies')
[<Company id:0001946[http] name:_Donners' Company_>, <Company id:0475575[http] name:_Donners' Company, The_>, <Company id:0566686[http] name:_Kinberg Genre_>, <Company id:0047120[http] name:_Marvel Entertainment_>, <Company id:0420822[http] name:_TSG Entertainment_>, <Company id:0000756[http] name:_Twentieth Century Fox Film Corporation_>]

Now, you are probably working on a Movie object that is the result of a search query. As stated in the documentation ( http://imdbpy.sourceforge.net/support.html ) a result object only contains basic information about a movie (after all other information are not present in the search results...)

To fetch the complete information, you have to use the IMDb's class update method. For example:

>>> from imdb import IMDb
>>> ia = IMDb()
>>> s = ia.search_movie('Deadpool')
>>> dp = s[0]
>>> ia.update(dp)
>>> print dp.get('production companies')
[<Company id:0001946[http] name:_Donners' Company_>, <Company id:0475575[http] name:_Donners' Company, The_>, <Company id:0566686[http] name:_Kinberg Genre_>, <Company id:0047120[http] name:_Marvel Entertainment_>, <Company id:0420822[http] name:_TSG Entertainment_>, <Company id:0000756[http] name:_Twentieth Century Fox Film Corporation_>]


来源:https://stackoverflow.com/questions/35789308/get-the-company-info-for-a-movie-from-imdb-using-imdbpy

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