Python IMDbPY – Retrieving art department cast from the movie object

In this article we will see how we can retrieve the art department cast that involved in the movie from the movie information, movie id is the unique id given to each movie by IMDb. We can use search_movie method to search the movies by their name but it gives many movies as they have same names therefore retrieving a movie by its id is a better option.

In order to search a movie by its id we use get_movie method.

Syntax to get art department cast list : cast = movie[‘art department’]

Here movie is the object returned by the get_movie method which act as the dictionary

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()
  
# ID
code = "1187043"
  
# getting movie
movie = ia.get_movie(code)
  
# printing movie object
print(movie)
  
print("===============")
  
# getting cast
cast = movie['art department']
  
# actor name from caste
actor = cast[1]
  
print(actor)

chevron_right


Output :

3 Idiots
===============
Ajay Chodanker

Another example :

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "4434004"
  
# getting movie
movie = ia.get_movie(code)
  
# printing movie object
print(movie)
  
print("===============")
  
# getting cast
cast = movie['art department']
  
# printing actors name from caste
print(cast[0])

chevron_right


Output :

Udta Punjab
===============
Pallavi Pethkar

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.