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

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# getting the movie with id
search = ia.get_movie("0111161")
  
# getting movie year
year = search['year']
  
# printing movie name and year
print(search['title'] + " : " + str(year))

chevron_right


Output :

The Shawshank Redemption : 1994

Another example

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# getting the movie with name
search = ia.search_movie("3 Idiots")
  
# getting movie year
year = search[0]['year']
  
# printing movie name and year
print(search[0]['title'] + " : " + str(year))

chevron_right


Output :

3 Idiots : 2009

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.