4

I would like to collect the IMDb rating details by demographic (gender, age group).

When I try to use the get_movie_vote_details module in imdbpy, my output is empty. Here is my code:

 import imdb

 i =  imdb.IMDb(accessSystem='http')

 movie = i.get_movie('0780504')

 print(movie)

 votes = i.get_movie_vote_details('0780504')

 print(votes)

and here is the output:

print(m)

Drive

print(votes)

{'charactersRefs': {}, 'data': {}, 'namesRefs': {}, 'titlesRefs': {}}

As you can see, the "votes" output is a little off. Is there a way I can extract rating details using imdbpy?

theBrainyGeek
  • 584
  • 1
  • 6
  • 17
driskerr
  • 45
  • 6
  • I tires the same code and it looks like an error with the library: "'AttributeError: 'DOMHTMLPlotParser' object has no attribute '_useModule' During handling of the above exception, another exception occurred: msg = msg % self.args TypeError: not enough arguments for format string Call stack: Message: '%s: unable to gather refs: %s' Arguments: ('DOMHTMLPlotParser',)' Drive", strangely prints the title but not the other data – oetoni Nov 13 '17 at 22:39
  • @oetoni : that bug is already fixed in the repository version. – Davide Alberani Nov 16 '17 at 07:56

1 Answers1

2

You are not supposed to call the .get_movie_XYZ(...) methods directly: they are used internally to update a Movie instance using the IMDb().update(...) method.

For example:

import imdb

i = imdb.IMDb(accessSystem='http')

movie = i.get_movie('0780504')
i.update(movie, 'vote details')
print(movie.get('mean and median')

If you want to know all the available info sets, call i.get_movie_infoset(); to see which keys of a Movie instance were added when a given info set was updated, use the movie.infoset2key mapping.

For more information, refer to the official documentation.

Regarding the format of the data, this code:

from imdb import IMDb
ia = IMDb()
m = ia.get_movie('0780504', 'vote details')
print('median', m.get('median'))
print('arithmetic mean', m.get('arithmetic mean'))
print('number of votes', m.get('number of votes'))
print('demographics', m.get('demographics'))

will output something like this: median 8 arithmetic mean 7.8 number of votes {1: 8626, 2: 4135, 3: 5762, 4: 9264, 5: 17595, 6: 39440, 7: 84746, 8: 133331, 9: 98870, 10: 75737} demographics {'imdb staff': {'rating': 7.8, 'votes': 36}, 'aged under 18': {'rating': 8.5, 'votes': 844}, 'non us users': {'rating': 7.8, 'votes': 250586}, 'top 1000 voters': {'rating': 7.6, 'votes': 739}, 'males aged 45 plus': {'rating': 7.4, 'votes': 24213}, 'aged 45 plus': {'rating': 7.4, 'votes': 28779}, 'aged 18 29': {'rating': 7.9, 'votes': 183217}, 'us users': {'rating': 8.0, 'votes': 71299}, 'aged 30 44': {'rating': 7.7, 'votes': 181063}, 'males aged under 18': {'rating': 8.5, 'votes': 705}, 'males aged 30 44': {'rating': 7.8, 'votes': 152988}, 'females aged under 18': {'rating': 7.9, 'votes': 133}, 'males aged 18 29': {'rating': 8.0, 'votes': 148749}, 'females aged 45 plus': {'rating': 7.4, 'votes': 4004}, 'imdb users': {'rating': 7.8, 'votes': 477506}, 'females aged 18 29': {'rating': 7.6, 'votes': 32575}, 'females': {'rating': 7.6, 'votes': 65217}, 'males': {'rating': 7.9, 'votes': 341617}, 'females aged 30 44': {'rating': 7.5, 'votes': 25465}}

Davide Alberani
  • 1,061
  • 1
  • 18
  • 28
  • Thanks @Davide. I now understand the syntax better and have used it to pull other detailed information (budget, gross, etc). I will stay tuned for the next update when *hopefully* the ratings feature will be fixed. – driskerr Nov 14 '17 at 01:01
  • @driskerr the parser should be fixed, now. If you can, please test it (and if you find the answer satisfying, accept it). – Davide Alberani Nov 14 '17 at 22:00
  • hmm this is exactly what I'm looking for, but unfortunately, when I reinstall imdbpy and I run the code exactly as written and I get the following output: `median None arithmetic mean None number of votes None demographics None` – driskerr Nov 14 '17 at 22:38
  • @driskerr : did you use the Github version? I've not packaged/released it, yet (will be done in some weeks: I want to fix some stuff) – Davide Alberani Nov 15 '17 at 08:28
  • 1
    hallejuah! it works now! I thought I had reinstalled the Github version, but I guess I messed up somewhere. Thank you for addressing this for me – driskerr Nov 15 '17 at 18:43