What should I watch?

A Netflix recommender in Python

Tell me a film or series you loved and I'll tell you what to watch now on Netflix, and why. In English with the Netflix USA catalogue and in Spanish with the Netflix Spain one.

Portfolio project for the Advanced Python module of the Full Stack Master at Conquer Blocks.

Home page of What should I watch?: a wall of posters, the language switcher with flags, the search box and suggestions to start with
  • ~7,600Netflix USA titles
  • ~9,000Netflix Spain titles
  • 36unit tests
  • Day 1monthly auto-update

The problem

You open Netflix, scroll for 20 minutes and still can't decide. This site puts an end to that: you type a title you liked and it searches the real, current Netflix catalogue for the closest ones, about 7,600 titles in the English version (Netflix USA) and about 9,000 in the Spanish one (Netflix Spain).

Every recommendation comes with:

  • an affinity percentage, with a scale that explains what it means;
  • the specific reasons: same director, shared actors, shared themes or genres;
  • the title's ★ rating and a 👥 «Recommended by the audience» badge when the community recommends it too;
  • a detail card with synopsis and cast.

It is a hybrid recommender written from scratch: first it compares titles with each other by their content, then it lets audience opinion reorder the list without touching the affinity percentage.

How it decides

Put simply, the engine does what you would do if you knew the whole catalogue by heart.

  1. 1

    It takes each title apart

    It turns every film or series into tags: genres, themes, who directed it, who is in it, where it comes from, the age rating, whether it is a film or a series and the keywords of its synopsis.

  2. 2

    It values what is rare

    Sharing a director says far more than sharing «Drama», which thousands of titles have. Uncommon matches weigh more.

  3. 3

    It compares in two ways

    It measures how alike two titles are overall and also aspect by aspect. Affinity combines both, so only what matches in the specifics and in general scores high.

  4. 4

    The audience sets the order

    Then audience opinion decides the order: what the community recommends to people who liked your title moves up, and the rating helps break ties. The percentage stays the same, and for each title it tells you why it recommends it.

How to read affinity

  • 40% or moreSame family
  • 25–40%Very similar
  • Under 25%Same style

«Same family» covers sequels and spin-offs.

The «How it decides» section: the weight of each tag group and why Better Call Saul is the top recommendation for Breaking Bad

The technical detail

Real, current data

descargar_catalogo.py downloads the Netflix Spain and Netflix USA catalogues from the TMDb API, with country availability from JustWatch. It runs the requests in parallel with urllib and concurrent.futures, with retries. The Kaggle datasets stopped in 2021.

Cleaning

With pandas and re, each title becomes groups of tags: genres, themes, direction, cast, country, age rating, type and synopsis keywords. nltk removes stop words and reduces words to their stem.

TF-IDF engine with weights per group

With numpy. TF-IDF makes sharing something rare, like a director, count more than something common, like «Drama». On top of that, each group of tags has its own weight:

  • Genres3
  • Themes2
  • Direction2
  • Cast2
  • Synopsis1.5
  • Country1
  • Rating and format1.25

Affinity

It is the geometric mean of two measures: the cosine of the full vector and the aspect-by-aspect similarity. With it, the top recommendation went from around 15% to around 36%, without making the lists worse.

Audience opinion

Once the list is computed, two signals reorder it. Recommendations from the TMDb community («people who liked X also liked Y») lift a title by up to 20%, more the higher it appears on that list. The vote-adjusted rating, with the Bayesian formula from the IMDb top 250, (v·R + m·C) / (v + m), acts as a small tie-breaker. The affinity percentage stays the same: the audience only decides the order.

A real example: with Breaking Bad, the top pick is Better Call Saul (50%, recommended by the audience). With Wednesday, Stranger Things comes first even though Sabrina has higher affinity.

Speed

An inverted index compares one title with the whole catalogue in about a millisecond.

Extras

A desktop app with tkinter and 36 unit tests with unittest, which need no network and no keys.

The frontend

A static site in plain HTML, CSS and JavaScript, with no frameworks, mobile-friendly and accessible: it works with the keyboard and respects prefers-reduced-motion.

Cloudflare Pages doesn't run Python, so exportar_web.py precomputes every recommendation as JSON in about 15 seconds, and the site only reads the block it needs.

Both versions share the same Python engine and the same HTML, CSS and JavaScript. The language comes from the page's lang attribute, which decides which data it loads and which texts it shows.

  • Home page with a 3D wall of posters and ambient light that takes the colour of the chosen poster.
  • Language switcher with 🇪🇸 ES / 🇺🇸 EN flags in the top bar; on mobile only the flags show.
  • Search box with a hint («For example, Stranger Things») that disappears when you tap, instead of a title already typed in.
  • Explained recommendations, with each title's ★ rating and a films or series filter.
  • «How it decides», which lights up the groups that match and includes an animated affinity meter.
  • «Esta noche» (tonight), with a free-time bar that tells you how many films you have time to watch.
  • Share links such as ?t=Breaking Bad.
  • Its own icon when you add the site to the iPhone home screen, with apple-touch-icon and manifest, and a reviewed mobile layout.
Recommendations for Breaking Bad: the closest match, with its affinity, its rating, the «Recomendada por el público» badge and its reasons
Home page on a phone
Results on a phone: Better Call Saul, recommended by the audience

The automation

A GitHub Actions workflow runs on the 1st of every month and with every change to the site or the engine:

  1. Runs the tests.
  2. Downloads both catalogues.
  3. Checks each one with comprobar_catalogo.py: if it is incomplete, it does not publish.
  4. Precomputes the recommendations.
  5. Publishes to Cloudflare Pages with Wrangler.
  6. Records the date with a commit.

The keys are stored as GitHub secrets.

Two challenges

  • Combining content and audience opinion without letting popularity hide similarity

    If the audience counted towards the percentage, the most popular titles would rise even when they were barely alike. So affinity comes only from the content and the audience only changes the order: a title moves up by at most 20% and the vote-adjusted rating only breaks ties.

  • Protecting an automatic release from incomplete data from an external API

    Once, TMDb returned half the catalogue and about 800 titles were missing. Since then, comprobar_catalogo.py checks each catalogue before publishing: if it has fewer than 5,000 titles or 5% fewer than the last one published, it is not released and the site stays as it was.

What it is built with

EngineHybrid recommender system with Python, pandas, numpy, NLTK and TF-IDFWebHTML, CSS and JavaScript with no frameworks, bilingual with i18nDeploymentGitHub Actions and Cloudflare Pages

Data and images from TMDb; availability from JustWatch. Educational project, not affiliated with Netflix.

Back to the portfolio