1

I'm trying to get the parents guide from movies and TV-shows using Imdbpy, but I can't figure out how. I can see some refrences to "Parents guide" in the source code, so I hope it can be done with Imdbpy.

Can someone help me or point me in the right direction? :)

Thanks!

2 Answers2

3

You could use the following code to get the 'parents guide' information from IMDB. The ia.get_movie_parents_guide method returns a dictionary containing keys ['data', 'namesRefs', 'titlesRefs'] and only 'data' is of our interest.

from imdb import IMDb
ia = IMDb()
theMatrix = ia.get_movie_parents_guide('0133093')
sorted(theMatrix.keys())

#output:
['data', 'namesRefs', 'titlesRefs']

Within the 'data' we have another dictionary containing keys ['certification', 'mpaa']. While certification information gives the certification(age restriction) imposed by each country.

theMatrix['data']['certification']

#output:
[' Argentina:13',
 ' Australia:M',
 ' Belgium:KT/EA',
 ' Brazil:12',
 ...
 ...
 ' India:A',
 ...
 ...
 ' United States:R',
 ' (certificate #36569)',
 ' Ukraine:16']

MPAA (Motion Picture Association of America) is the certification given in the United States.

theMatrix['data']['mpaa']

#output:
'Rated R for sci-fi violence and brief language'

However, the main information about the parents guide is not only the MPAA and Certification ratings from around the world, but to give parents additional information about the title that cannot be fully conveyed by the certificate. If you check a title in IMDB, I am talking about the sections circled in red.

Currently, I couldn't find a way to retrieve this information using imdbpy, I would love to hear from anyone if there is a solution withing imdbpy. I know we can create a scraper with other packages, but looking for any features I might be overlooking within imdbpy.

IMDB Parents Guid

For those who are new to imdbpy, I believe it would help to read my other answer in understanding the information sets.

1

Here is How I Do it in Python 3:

import imdb
ia = imdb.IMDb()
movie = ia.get_movie_parents_guide("1640718")
print(movie)

Output should be:

{'titlesRefs': {}, 'data': {'certification': [' Canada:G', ' (Alberta/Quebec/Nova Scotia)', ' Canada:PG', ' (Manitoba/Ontario)', ' Mexico:A', ' Portugal:M/6', ' Singapore:PG13', ' South Korea:All', ' (2015)', ' Sweden:7', ' Switzerland:6', ' United States:PG'], 'mpaa': 'Rated PG for thematic elements including some violence and sensual images'}, 'namesRefs': {}}

OR you can use:

movie = ia.get_movie("1640718", info='parents_guide')
print(movie['mpaa'])

Output:

Rated PG for thematic elements including some violence and sensual images

Note: "1640718" is IMDb title's ID without the 'tt', for example: https://www.imdb.com/title/tt1640718

iamzeid
  • 104
  • 1
  • 2
  • 18
  • thanks I got that already but what I was looking for is just the "PG" rating. Not the entire sentence I thought you could potentially pull it from the list I provided. – Lacer Jul 18 '21 at 19:40