How you can access IMDb page of any movie through two clicks

Bidyudipta Chanda
Python Pandemonium
Published in
5 min readApr 12, 2017

This is my first article on Medium. Medium has been a walking and talking encyclopaedia for me since months. And the best thing about this is you can follow what you like and read about things which are really influencing the world, much much unlike Facebook.

Now about me, I am an out and out movie buff, not only movies, shows too. Much of my days, leisure time and vacations are spersed by long and continuous hours of #NetflixAndChill or on my PC’s VLC player with downloaded media.

With great power, comes great responsibility. With high-speed Internet connection and plenty of free time, comes the most inevitable choice of all times, what to watch and what not to. A movie or an entire season of a show gets downloaded within minutes; but you have to spend an entire two-hour period or much more in case of shows for that. And you find at the end of the running time that the entire show was a loss and this was one of the worst movies you have ever watched. Completely unforgivable offence, right?

But this is not a problem anymore. Enthusiasts made a site called Internet Movie Database, which houses the largest database of ratings for movies and shows yet in this whole universe. Voila! Now you can sort your list and just see those movies, which have been branded good by people. BUT.

There is always a but. And I felt this but so immensely that I decided to work upon it. Time is to be saved, not to be wasted. How is time being wasted here, you say. I will demonstrate that.

Suppose, you just downloaded a film, say One Flew Over The Cuckoo’s Nest. You know nothing about it and want to check what people have said about it, the plot synopsis and the overall rating which it has received. I will just describe the entire procedure for it, for no reason.

A famous still from the same movie. (Source: IMDb)
  1. Open up Chrome — 1 click
  2. Go to Google (considering Google is already one of your frequently visited sites. Typing a ‘g’ or at most ‘goo’ will give you Google) — 3 strokes.
  3. Type ‘imdb’ in search bar. Press Enter — 5 strokes.
  4. The IMDb page comes up. To find ‘One Flew Over The Cuckoo’s Nest’, typing in ‘one fl’ does the job — 7 strokes, including one mouse click.

Wow. An 8.7 rating. Definitely a worthy piece. Bye bye, world!

I counted the number of keystrokes or clicks by the way. Wondering, why? So, I sum up the total number of strokes or clicks for finding out about the movie I set the example on and 16 strokes and clicks at least.

But I hover in and around IMDb almost all the time of the day, searching about the stuff and obviously, I spend thousands of keystrokes on the website everyday. So, what if I told you, you can do all this just by ONE RIGHT MOUSE CLICK AND ANOTHER LEFT MOUSE CLICK? 16 strokes reduced to 2. I take an average of 15 strokes per movie and say, you search about 10 movies on one of your very busy movie days. So, 150 strokes reduced to 20.

I will tell you how I did this whole thing and before starting, I will assure you by my life that this is one of the easiest useful things you can do by Python, which will make your life a lot easier. I will explain the steps one by one and the code used in that too and at the end, I will leave a screen-capture video, which shows the working of it. Let’s begin.

The basic concept underlying is that you cannot run a Python script upon a file. To do that you have to have a .cmd or a .bat file, which can be set up in one of the options for Send To when you right click a folder.

  1. Go to any folder and type shell:sendto in the address bar of the folder. The ways with which you can do a Send To > is listed here, like Desktop and Mail Recepient to name a few.
  2. Create a new text file.

Type this into and save it as runner.cmd.

Code Walkthrough:

echo off : turns off the command-line echoing.

cls : clear screen.

py <Address of your saved Python file> %* : The path of the Python file which I will demonstrate a few minutes from now should be inserted here to run it when this cmd file is being run.

pause : Pauses the command line screen from disappearing within moments.

3. Create a Python file anywhere in your computer, the path for which you have to insert in the .cmd file above.

import statements : Imports all the needed packages.

sys.argv[1]: Most important line. When you right-click a folder and go to Send To > runner.cmd, this line takes its argument from that file and the entire path of the folder is the output.

os.path.basename() : Outputs the name of the folder only from the entire path.

name.replace(“ “,”%20"): OMDbapi is a site which has the entire database of IMDb films along with the details in separate JSON files. And its search criteria is replace the spaces in the name of the film by ‘%20’.

r.read() : Opens the OMDb url and stores the info about the film in web.

web.decode(‘UTF-8’) : The web variable is of bytes type, change into a string.

re.findall(r’tt[0–9]+’,web): IMDb is searched via an imdbID, which is found in the JSON file given by OMDb. All the IDs of IMDb start with ‘tt’, like ‘tt0877890’ is an arbitrary one. This statement finds every occurence of ‘tt’ along with at least one occurence of a digit from web. This gives me an array with the film ID, for which I am searching.

open_new_tab(url) : Opens a new tab in your default browser for the url.

So, that’s all. I will leave you with video of the workthrough of this entire thing. This thing has one small shortcoming. Films have to be named like La La Land or One Flew Over The Cuckoo’s Nest and not like La La Land (2016). I am working on this to make this as error-free as possible.

That is all for today. I am working on another Python script, which will again automate one of the most frequently done things and save a lot of time. But I am saving that for another day. If you have any suggestions for this, feel free to contact me here on Medium. I am free to suggestions; I know there can be discrepancies.

I am on LinkedIn at https://www.linkedin.com/in/bidyutchanda/.

My GitHub repo is at https://github.com/Bidyut108.

--

--