A simple python script to save you time when choosing a movie.

Leo Tiokhin, PhD
2 min readAug 18, 2022

Have you ever spent more time deciding which movie to watch than actually watching the movie?

I’ve done this (and, sadly, more than once). My partner and I watch at least 1 movie a week. Usually we sit down with a vague sense of what we want to watch, I google something like “top hidden gem movies Reddit 2022,” and then I spend the next hour wading through reviews while my partner becomes increasingly frustrated.

To solve this problem (and get a bit of python practice) I thought it’d be fun to write a program to help me choose a movie.

The basic input into the program is a spreadsheet with data on movies that I’d like to watch. The program asks a few questions about the characteristics of my desired movie (such as length, year, IMDB rating, genre, and language) and then randomly outputs a movie that fits those criteria.

There are plenty of things that can be improved, but it satisfies my immediate needs pretty well. The program also does some useful quality-control things like removing duplicate entries, accounting for upper and lower case inputs, and (sometimes) outputting useful error messages.

Feel free to use this or adapt it to your needs. And of course reach out if you come up with something that blows this out of the water and only requires 5 lines of code 😊

The movie data

Snapshot of the input data. The basic approach is to keep a spreadsheet with the movies you’d like to watch, along with some information like the length, year released, IMDB rating, genres, and language. Another approach could be to use an existing movie list (or extract information from IMDB database) and then update the below code to include the attributes in that spreadsheet. A sample spreadsheet is available at this GitHub repository.

The movie-picker code

Full code is available on my GitHub page or at ray.so.

A trial run

Here’s a trial run of the get_me_a_movie() function:

Trial run of the movie picker. Input criteria were a movie that was less than 180 minutes long, came out between 1980 and 2022, had a minimum IMDB rating of 6, had drama as one of it’s genres, and was in English. The movie picker recommended “Antigone”. I then indicated that I was not happy with the selection. The movie picker then randomly selected a movie again, which happened to be “There Will Be Blood”.

Conclusion

Python is cool. My partner is significantly less frustrated with me. And tonight we’re watching There Will be Blood.

--

--

Leo Tiokhin, PhD

Senior Researcher @ Rathenau Instituut | Science Policy | Evidence-Based Advice | https://www.leotiokhin.com