Search code examples
pythonpython-2.7imdbimdbpy

IMDbPY get_top250_movies() returns empty list


When I try to get the top 250 movies from imdbpy it returns an empty list:

>>> from imdb import IMDb
>>> imdb_instance=IMDb()
>>> top250=imdb_instance.get_top250_movies()
>>> top250
[]

Any idea? The above code should return a list of the top 250 movies rated by IMDb found here. The problem is the code only returns an empty array, and not the list of 250 movies.


Solution

  • I found the problem.

    I did: >>>import imdb then >>>dir(imdb). dir() is a very useful python function that returns the classes and functions that are under an object.

    From there, I found that for some reason, the way it is written, the class IMDbBase contains get_top250_movies(), not IMDb. Just change from imdb import IMDb to from imdb import IMDbBase and instance that.

    EDIT: Good point, @user3577702 pointed out that this is an abstract base class (oops).

    The mysterious empty list seems to have been a problem for a while. I found a question on Google Groups. According to the answer,

    The version in the SVN repository should work.

    However, that is no longer the case. The current commit doesn't work.

    I have started a new question, hopefully the maintainer will respond soon.