Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python IMDbPY – Info set to keys of Movie object

  • Last Updated : 22 Apr, 2020

In this article we will see how we can convert info set to keys, we can know info sets of movie by get_movie_infoset, but even after getting the info set we are unable to use like dictionary.

In order to use info set as dictionary keys we have to use infoset2keys method.

 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. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Syntax : movie.infoset2keys



Here movie is the imdb Movie object

Action performed : This will allow info set to use as dictionary keys

Below is the implementation




# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# ID
code = "0094226"
    
# searching the Id and getting info set
movie = ia.get_movie(code, info =['taglines', 'plot'])
  
# making infoset to use as keys
movie.infoset2keys
  
# printing movie tagline
print(movie['taglines'])

Output :

[‘The Chicago Dream is that big’, ‘No one messed with Al Capone, but Eliot Ness messed with him’, “AL CAPONE. He ruled Chicago with absolute power. No one could touch him. No one could stop him. – Until Eliot Ness and a small force of men swore they’d bring him down.”, ‘What are you prepared to do?’, ‘Never stop fighting till the fight is done’]

Another example




# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# ID
code = "4434004"
    
# searching the Id and getting info set
movie = ia.get_movie(code, info =['plot'])
  
# making infoset to use as keys
movie.infoset2keys
  
# printing movie plot
print(movie['plot'])

Output :

[‘A story that revolves around drug abuse in the affluent north Indian State of Punjab and how the youth there have succumbed to it en-masse resulting in a socio-economic decline.’, “What on earth can a rock star, a migrant laborer, a doctor and a cop possibly have in common? Simple, Punjab! 4 lives, 1 connection – ‘Udta Punjab’ takes you on a trip like never before. Shahid Kapoor, Kareena Kapoor, Alia Bhatt and Diljit Dosanjh play characters from different walks of life, fighting the menace of drugs in their own way. The film journeys into the artificial highs and the real lows that they face while treading the paths fraught with mortal dangers. But above all, Udta Punjab is about the famed Punjabi spirit, that despite being fully down, has the audacity of looking you in the eye and saying – Drugs di maa di!”]




My Personal Notes arrow_drop_up
Recommended Articles
Page :