Open In App

Python IMDbPY – Checking if person is part of movie or not

Last Updated : 08 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can check if some person was part of the movie or not, lot of people work to make a movie and some times we don’t know if a person is in that movie or not, but with the help in operator we can check.

Implementation steps :

1. Get the movie data with the help of get_movie method
2. Get the person data with the help of get_person method
3. Using in operator check if person was part of movie or not
4. Show the result

Below is the implementation




# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "4434004"
  
# getting movie
movie = ia.get_movie(code)
  
# person id
code2 = "1372788"
  
# getting person
person = ia.get_person(code2)
  
# printing movie object
print(movie)
  
# printing person object
print(person)
  
print("===============")
  
# checking if person is in the movie or not
if person in movie:
    print("Yes !!")
      
else:
    print("No !!")


Output :

Udta Punjab
Shahid Kapoor
===============
Yes!!

Another example




# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "1187043"
  
# getting movie
movie = ia.get_movie(code)
  
# person id
code2 = "1372788"
  
# getting person
person = ia.get_person(code2)
  
# printing movie object
print(movie)
  
# printing person object
print(person)
  
print("===============")
  
# checking if person is in the movie or not
if person in movie:
    print("Yes !!")
      
else:
    print("No !!")


Output :

3 Idiots
Shahid Kapoor
===============
No!!


Similar Reads

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
2 min read
Python IMDbPY - Retrieving movie using movie ID
In this article we will see how we can retrieve the data of movie using its movie ID, 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 i
1 min read
Python IMDbPY – Getting role of person in the movie
In this article we will see how we can get the role of person the movie, we know movie object act similar to dictionary. IMDb data base has lot of information i.e details about the persons work in the movie and what was there role in that movie. In order to the role of the person we have to do the following -1. Get the movie object with the help of
2 min read
Python IMDbPY – Retrieving person using person ID
In this article we will see how we can retrieve the data of person using its person ID, person id is the unique id given to each person by IMDb. We can use search_person method to search the persons by their name but it gives many people as they have same names therefore retrieving a person by its id is a better option. In order to search a person
1 min read
Python IMDbPY – Movie info set
IMDb data base have every information of the movie i.e when movie released, rating, locations etc but in order to retrieve them problem occur as there will be lots of web pages which can be both time-and bandwidth-consuming, especially if you’re interested in only a small part of the information. If we want to fetch only specific information we can
1 min read
Python IMDbPY – Default info of Movie object
In this article we will see how we can achieve the set of information which retrieved by default by get_movie method, with the help of get_movie_infoset we can know all the information that we can achieve of the movie. But all the information is not extracted as it will be time consuming process. In order to know the default information that a movi
1 min read
Python IMDbPY – Getting title from searched movie
In this article we will see how we can get the title of movie from the searched list of movies. We use search_movie method to find all the related movies. search_movie method returns list and each element of list work as a dictionary i.e. they can be queried by giving the key of the data, here key will be title. Syntax : movies[0][‘title’]Here movi
2 min read
Python IMDbPY – Getting movie ID from searched movies
In this article we will see how we can get the movie id from searched movies, movie id is basically unique id given to each movie as movie name can be same but id will be distinct. We use search_movie method to search movies with the same name. In order to get movie id we use movieID method. Syntax : movies[0].movieID Here movies is the list of mov
2 min read
Python IMDbPY - Searching a movie
IMDbPY is a Python package which is used to retrieve and manage the data of the IMDb. Python IMDbPY - Searching a movie IMDb is an online database of information related to films, television programs, home videos, video games, and streaming content online – including cast, production crew and personal biographies, plot summaries, trivia, fan and cr
3 min read
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 perform
2 min read
Article Tags :
Practice Tags :