CoolFace
Apppublic

jthorrigan/letterboxd-recommender

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

๐ŸŽฌ Letterboxd Movie Recommender

A comprehensive Gradio-based movie recommendation application that analyzes your Letterboxd watching history to provide personalized movie recommendations.

![Hugging Face Spaces](https://huggingface.co/spaces) ![Python 3.8+](https://www.python.org/downloads/) ![License: MIT](https://opensource.org/licenses/MIT)

โœจ Features

๐ŸŽฏ Core Functionality

  1. 1.Dual Data Import Methods
  2. 2.๐Ÿ“ค CSV Upload: Upload your official Letterboxd data export
  3. 3.๐Ÿ” Username Scraping: Automatically fetch public profile data
  1. 1.Hybrid Recommendation System
  2. 2.๐Ÿค Collaborative filtering based on similar users
  3. 3.๐Ÿ“Š Content-based filtering using movie attributes
  4. 4.๐Ÿง  Semantic analysis of your reviews and preferences
  5. 5.๐Ÿ’ก Every recommendation includes an explanation showing why it's suggested
  1. 1.Personalized Recommendations
  2. 2.Get top N movie suggestions based on your taste
  3. 3.Filter by genre, year range, and more
  4. 4.See match scores and detailed reasoning
  1. 1.Similar Movie Finder
  2. 2.Select any movie from your favorites
  3. 3.Discover similar films with similarity scores
  4. 4.Understand why movies are similar
  1. 1.Rating Predictor
  2. 2.Predict what rating you'd give to any movie
  3. 3.See confidence levels for predictions
  4. 4.Based on your rating patterns and preferences
  1. 1.Interactive Visualizations
  2. 2.๐Ÿ“Š Rating distribution histogram
  3. 3.๐Ÿ“ˆ Ratings over time with trends
  4. 4.๐Ÿ“… Watch frequency timeline
  5. 5.๐ŸŽญ Movies by decade analysis
  6. 6.๐Ÿ“‰ Rating trends (getting harsher/more generous?)

๐Ÿš€ Quick Start

Installation

  1. 1.Clone the repository
bash
   git clone https://github.com/jthorrigan/letterboxd-recommender.git
   cd letterboxd-recommender
  1. 1.Install dependencies
bash
   pip install -r requirements.txt
  1. 1.Run the app
bash
   python app.py
  1. 1.Open in browser
  2. 2.The app will launch at http://localhost:7860

๐Ÿ“ฅ Getting Your Letterboxd Data

Method 1: CSV Export (Recommended)

  1. 1.Log in to your Letterboxd account
  2. 2.Navigate to Settings > Import & Export
  3. 3.Click "Export your data"
  4. 4.Wait for the email with your data export
  5. 5.Download and extract the ZIP file
  6. 6.Upload the CSV files to the app:
  7. 7.ratings.csv (required)
  8. 8.watchlist.csv (optional)
  9. 9.watched.csv (optional)

Method 2: Username Scraping

  1. 1.Ensure your Letterboxd profile is public
  2. 2.Enter your username in the app (without @ symbol)
  3. 3.Click "Scrape Profile"
  4. 4.Wait for data to be fetched

Note: Scraping respects rate limits and only accesses public data.

๐ŸŽฎ How to Use

Tab 1: Data Import

  • โ€”Choose between CSV upload or username scraping
  • โ€”Wait for data to process
  • โ€”View import statistics

Tab 2: Recommendations

  • โ€”Set number of recommendations (5-50)
  • โ€”Apply optional year filters
  • โ€”Get personalized suggestions with explanations

Tab 3: Similar Movies

  • โ€”Select a movie from your rated films
  • โ€”Choose number of similar movies
  • โ€”Discover films with similar themes and styles

Tab 4: Rating Predictor

  • โ€”Enter any movie title
  • โ€”See predicted rating and confidence level
  • โ€”Understand the reasoning behind the prediction

Tab 5: Insights & Visualizations

  • โ€”View your watching statistics
  • โ€”Explore interactive charts
  • โ€”Understand your rating patterns and preferences

๐Ÿ—๏ธ Project Structure

letterboxd-recommender/
โ”œโ”€โ”€ app.py                  # Main Gradio application
โ”œโ”€โ”€ recommender.py          # Hybrid recommendation engine
โ”œโ”€โ”€ scraper.py             # Letterboxd profile scraping
โ”œโ”€โ”€ data_processor.py      # CSV processing and data cleaning
โ”œโ”€โ”€ visualizations.py      # Interactive chart generation
โ”œโ”€โ”€ config.py              # Configuration and constants
โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”œโ”€โ”€ .gitignore            # Git ignore rules
โ”œโ”€โ”€ .gitattributes        # Git LFS configuration
โ””โ”€โ”€ README.md             # This file

๐Ÿ”ง Configuration

Edit config.py to customize:

  • โ€”Number of recommendations
  • โ€”Similarity thresholds
  • โ€”Collaborative filtering parameters
  • โ€”Content-based weights
  • โ€”Visualization settings
  • โ€”API keys (optional, for enhanced metadata)

Getting Better Recommendations (Optional)

For significantly enhanced recommendations, get a free TMDB API key:

  1. 1.Create an account at https://www.themoviedb.org/
  2. 2.Go to Settings โ†’ API โ†’ Create โ†’ Developer
  3. 3.Fill out the form (you can use "Personal/Educational" for type)
  4. 4.Copy your API Key (v3 auth)
  5. 5.Add to your environment:
  6. 6.Local development: Create a .env file (see .env.example)
  7. 7.Hugging Face Spaces: Add as secret named TMDB_API_KEY in Settings

What you get with TMDB API:

  • โ€”โœ… Recommendations based on actual genres, directors, and actors
  • โ€”โœ… Semantic similarity using movie plots and themes
  • โ€”โœ… TMDB's "similar movies" algorithm
  • โ€”โœ… Quality filtering (minimum ratings, vote counts)
  • โ€”โœ… Intelligent explanations (e.g., "You rated 3 other Quentin Tarantino films highly")
  • โ€”โœ… Diversity in recommendations (avoids suggesting 10 similar movies)

Without TMDB API:

  • โ€”โš ๏ธ Basic recommendations using only your Letterboxd data
  • โ€”โš ๏ธ Limited to decade preferences and acclaimed films
  • โ€”โš ๏ธ No genre/director/actor analysis

The app works without this, but recommendations will be much more basic.

Optional: Additional Movie API Integration

For enhanced movie metadata and posters (deprecated, use TMDB above):

  1. 1.Get free API keys:
  2. 2.OMDb API (optional, for posters)
  1. 1.Create a .env file:
   TMDB_API_KEY=your_key_here
   OMDB_API_KEY=your_key_here

๐ŸŒ Deploy to Hugging Face Spaces

  1. 1.Create a new Space
  2. 2.Go to Hugging Face Spaces
  3. 3.Click "Create new Space"
  4. 4.Choose "Gradio" as the SDK
  5. 5.Set visibility to Public or Private
  1. 1.Upload files
bash
   git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
   cd YOUR_SPACE_NAME
   
   # Copy all project files
   cp /path/to/letterboxd-recommender/* .
   
   git add .
   git commit -m "Initial commit"
   git push
  1. 1.Space will build automatically
  2. 2.Check the "Building" status
  3. 3.Once complete, your app will be live!

๐Ÿ› ๏ธ Technology Stack

  • โ€”Frontend: Gradio 4.19+
  • โ€”Data Processing: Pandas, NumPy
  • โ€”Machine Learning: Scikit-learn, SciPy, Sentence-Transformers
  • โ€”Movie Metadata: TMDB API v3
  • โ€”Semantic Analysis: Sentence Transformers (all-MiniLM-L6-v2)
  • โ€”Visualizations: Plotly
  • โ€”Web Scraping: BeautifulSoup4, Requests
  • โ€”Environment: Python 3.8+

๐Ÿ“Š Recommendation Algorithm

The app uses a sophisticated hybrid approach with TMDB integration:

With TMDB API (Recommended):

Weighted Hybrid Scoring System (5 factors):

  1. 1.Genre Matching (30% weight)
  2. 2.Analyzes your highly-rated movies to identify favorite genres
  3. 3.Recommends movies matching your genre preferences
  4. 4.Example: "Matches your favorite genres: neo-noir, thriller"
  1. 1.Director/Cast Preferences (20% weight)
  2. 2.Identifies favorite directors from your ratings
  3. 3.Tracks actors you consistently rate highly
  4. 4.Example: "Directed by Quentin Tarantino" or "Features Tim Roth, Steve Buscemi"
  1. 1.Semantic Similarity (25% weight)
  2. 2.Uses sentence transformers to analyze movie plots and themes
  3. 3.Creates embeddings from descriptions, keywords, and themes
  4. 4.Finds movies with similar content, not just titles
  5. 5.Example: "Similar themes: heist films, ensemble casts, nonlinear narrative"
  1. 1.Year/Era Preferences (10% weight)
  2. 2.Identifies your favorite decades from rating history
  3. 3.Considers time period but doesn't over-weight it
  4. 4.Example: "From the 1990s, one of your favorite eras"
  1. 1.TMDB Similarity Algorithm (15% weight)
  2. 2.Leverages TMDB's own "similar movies" recommendations
  3. 3.Based on their collaborative filtering and metadata

Quality Filters:

  • โ€”โœ… Minimum TMDB rating (6.0+) and vote count (100+ votes)
  • โ€”โœ… Excludes movies you've already watched
  • โ€”โœ… Filters out obvious sequels/prequels of watched movies
  • โ€”โœ… Prevents recommending movies with just similar titles

Diversity Algorithm:

  • โ€”Limits recommendations to max 2 movies per director
  • โ€”Balances across different time periods
  • โ€”Mixes sub-genres to avoid repetition
  • โ€”Applies diversity penalty to prevent clustering

Without TMDB API (Basic Mode):

  1. 1.Decade-Based Filtering (simplified)
  2. 2.Recommends from your favorite decades
  3. 3.Uses a curated list of acclaimed films
  1. 1.Basic Title Analysis (minimal)
  2. 2.Simple word-based matching

Result: Each recommendation shows:

  • โ€”Match score (0-100%)
  • โ€”2-3 specific reasons why it's recommended
  • โ€”Relevant metadata (year, genres, cast)

๐Ÿ”’ Privacy & Ethics

Privacy

  • โ€”โœ… All data processing is local/session-based
  • โ€”โœ… No data is stored permanently on servers
  • โ€”โœ… No tracking or analytics
  • โ€”โœ… You control your data

Web Scraping Ethics

  • โ€”โœ… Only public profile data is accessed
  • โ€”โœ… Rate limiting prevents server overload
  • โ€”โœ… Respects robots.txt
  • โ€”โœ… User-agent identification
  • โ€”โš ๏ธ Use responsibly and respect Letterboxd's terms

๐Ÿค Contributing

Contributions are welcome! Here's how:

  1. 1.Fork the repository
  2. 2.Create a feature branch (git checkout -b feature/AmazingFeature)
  3. 3.Commit your changes (git commit -m 'Add AmazingFeature')
  4. 4.Push to the branch (git push origin feature/AmazingFeature)
  5. 5.Open a Pull Request

Ideas for Contributions

  • โ€”Integration with TMDB/OMDb APIs for movie posters and metadata
  • โ€”More sophisticated recommendation algorithms
  • โ€”Support for additional data sources
  • โ€”Enhanced visualizations
  • โ€”Mobile-responsive design improvements
  • โ€”Additional filtering options
  • โ€”Export recommendations to CSV/PDF

๐Ÿ“ Requirements

Minimum:

  • โ€”Python 3.8+
  • โ€”3+ rated movies for basic recommendations

Recommended:

  • โ€”Python 3.10+
  • โ€”20+ rated movies for quality recommendations
  • โ€”Public Letterboxd profile (for scraping method)

๐Ÿ› Troubleshooting

"Profile not found" error

  • โ€”Ensure your profile is public
  • โ€”Check username spelling (no @ symbol)
  • โ€”Try exporting CSV instead

"Need more ratings" message

  • โ€”Rate at least 5-10 movies for basic functionality
  • โ€”20+ ratings recommended for quality results

CSV upload fails

  • โ€”Ensure you're using official Letterboxd export
  • โ€”Check file is not corrupted
  • โ€”Try re-exporting from Letterboxd

Scraping is slow

  • โ€”This is normal - respects rate limits
  • โ€”Large profiles take longer
  • โ€”Consider CSV upload for faster results

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • โ€”Letterboxd for the amazing platform and data
  • โ€”Gradio for the excellent UI framework
  • โ€”Hugging Face for Spaces hosting
  • โ€”The open-source community for the tools and libraries

๐Ÿ“ง Contact

Questions? Suggestions? Feel free to:

  • โ€”Open an issue
  • โ€”Submit a pull request
  • โ€”Reach out on GitHub

Disclaimer: This is an unofficial tool and is not affiliated with, endorsed by, or connected to Letterboxd. All movie data and ratings belong to their respective owners.