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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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'])

chevron_right


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

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"
    
# 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'])

chevron_right


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

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.