Python IMDbPY – Getting released year of movie from movie object
In this article we will see how we can get the released year of movie from the movie object, we can get movie object with the help of search_movie
and get_movie
method to find movies.
search_movie
method returns list and each element of list work as a dictionary similarly get_movie
method return a movie object which work as dictionary i.e. they can be queried by giving the key of the data, here key will be year.
Syntax : movie[‘year’]
Here movie is the imdb Movie object
Return : It returns integer which is the release year
Below is the implementation
import imdb
ia = imdb.IMDb()
search = ia.get_movie( "0111161" )
year = search[ 'year' ]
print (search[ 'title' ] + " : " + str (year))
|
Output :
The Shawshank Redemption : 1994
Another example
import imdb
ia = imdb.IMDb()
search = ia.search_movie( "3 Idiots" )
year = search[ 0 ][ 'year' ]
print (search[ 0 ][ 'title' ] + " : " + str (year))
|
Output :
3 Idiots : 2009
Last Updated :
22 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...