Using IMDbPY to search for movies : Python

In this tutorial, we will be learning how to search for a movie using IMDbPY in Python.

IMDb is an online database of information related to movies, television series, video games, streaming content online, documentaries, etc. It also includes cast, production team, biographies, plot, rating, and critical reviews. There are many instances when we need to search for a movie or television program and get some information like rating, review, or cast. Python provides us with a package that can do this task for us. The name of this package is IMDbPY.

First, we need to install this package. Let’s do it by using the following command in command prompt or terminal.

pip install IMDbPY

Now we are ready to use it and its features in our Python program.

We are going to use the search_movie() method to search for a movie. The syntax for this method is as follows:

imdb_obj.search_movie(movie_name)

In the above syntax, imdb_obj is the instance of IMDb and movie_name is the name of the movie that this method takes as an argument. The method returns a list of items for the searched title.

Example Programs to search for a movie

Here, you can see an example program for searching for a movie using the IMDbPY.

import imdb

imdb_obj = imdb.IMDb()

item_list = imdb_obj.search_movie('Ford vs Ferrari')

for i in item_list:
    print(i)

Output:

Ford v Ferrari 
Ford v Ferrari 
Ford v Ferrari 
Ford v Ferrari 
Shelby vs. Ferrari 
Ford GT40 vs. Ferrari Take Two 
Zakarian vs. Ferraro: Peach 
Desert Water, LED TVs, Ferraris 
Shelby Legendary Cars: Ford V Ferrari - 'CSX 8198' Cobra 
Behind the scenes: 'Ford V Ferrari' 
Reaction from stars on 'Ford V Ferrari' 
Supercar Road Trip - Ford GT vs. Ferrari F430 vs. Pagani Zonda 
Reaction from Stars on 'Ford V Ferrari' - Legendary 
Rendezvous at premiere of 'Ford V Ferrari' 
Sci Fi a Bomb, Ford v. Ferrari, Colorado Brown Stain 
Superformance LLC: Ford V Ferrari 'Ken Miles Edition' Cobra 
Once Upon A Time In Hollywood, Marriage Story, Ford V Ferrari 
Pagani Zonda Cinque vs McLaren P1vs Ferrari F40: Abdul's Garage //LTACY SPECIAL EDITION DUBAI Pt. 1

Let’s see another example.

import imdb

imdb_obj = imdb.IMDb()

item_list = imdb_obj.search_movie('Agent Vinod')

print(item_list)

Output:

[<Movie id:1395025[http] title:_Agent Vinod (2012)_>, <Movie id:0165610[http] title:_Agent Vinod (1977)_>]

Thank you.

Also read: Movie Recommendation System using Machine Learning in Python

Leave a Reply

Your email address will not be published. Required fields are marked *