Python IMDbPY – Info set to keys of Movie object
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.
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 moduleimport imdb # creating instance of IMDbia = imdb.IMDb() # IDcode = "0094226" # searching the Id and getting info setmovie = ia.get_movie(code, info =['taglines', 'plot']) # making infoset to use as keysmovie.infoset2keys # printing movie taglineprint(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 moduleimport imdb # creating instance of IMDbia = imdb.IMDb() # IDcode = "4434004" # searching the Id and getting info setmovie = ia.get_movie(code, info =['plot']) # making infoset to use as keysmovie.infoset2keys # printing movie plotprint(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!”]
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


