jthorrigan/letterboxd-recommender
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.
  
โจ Features
๐ฏ Core Functionality
- Dual Data Import Methods
- ๐ค CSV Upload: Upload your official Letterboxd data export
- ๐ Username Scraping: Automatically fetch public profile data
- Hybrid Recommendation System
- ๐ค Collaborative filtering based on similar users
- ๐ Content-based filtering using movie attributes
- ๐ง Semantic analysis of your reviews and preferences
- ๐ก Every recommendation includes an explanation showing why it's suggested
- Personalized Recommendations
- Get top N movie suggestions based on your taste
- Filter by genre, year range, and more
- See match scores and detailed reasoning
- Similar Movie Finder
- Select any movie from your favorites
- Discover similar films with similarity scores
- Understand why movies are similar
- Rating Predictor
- Predict what rating you'd give to any movie
- See confidence levels for predictions
- Based on your rating patterns and preferences
- Interactive Visualizations
- ๐ Rating distribution histogram
- ๐ Ratings over time with trends
- ๐ Watch frequency timeline
- ๐ญ Movies by decade analysis
- ๐ Rating trends (getting harsher/more generous?)
๐ Quick Start
Installation
- Clone the repository
git clone https://github.com/jthorrigan/letterboxd-recommender.git
cd letterboxd-recommender- Install dependencies
pip install -r requirements.txt- Run the app
python app.py- Open in browser
- The app will launch at
http://localhost:7860
๐ฅ Getting Your Letterboxd Data
Method 1: CSV Export (Recommended)
- Log in to your Letterboxd account
- Navigate to Settings > Import & Export
- Click "Export your data"
- Wait for the email with your data export
- Download and extract the ZIP file
- Upload the CSV files to the app:
ratings.csv(required)watchlist.csv(optional)watched.csv(optional)
Method 2: Username Scraping
- Ensure your Letterboxd profile is public
- Enter your username in the app (without @ symbol)
- Click "Scrape Profile"
- 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:
- Create an account at https://www.themoviedb.org/
- Go to Settings โ API โ Create โ Developer
- Fill out the form (you can use "Personal/Educational" for type)
- Copy your API Key (v3 auth)
- Add to your environment:
- Local development: Create a
.envfile (see.env.example) - Hugging Face Spaces: Add as secret named
TMDB_API_KEYin 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):
- Get free API keys:
- OMDb API (optional, for posters)
- Create a
.envfile:
TMDB_API_KEY=your_key_here
OMDB_API_KEY=your_key_here๐ Deploy to Hugging Face Spaces
- Create a new Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose "Gradio" as the SDK
- Set visibility to Public or Private
- Upload files
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- Space will build automatically
- Check the "Building" status
- 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):
- Genre Matching (30% weight)
- Analyzes your highly-rated movies to identify favorite genres
- Recommends movies matching your genre preferences
- Example: "Matches your favorite genres: neo-noir, thriller"
- Director/Cast Preferences (20% weight)
- Identifies favorite directors from your ratings
- Tracks actors you consistently rate highly
- Example: "Directed by Quentin Tarantino" or "Features Tim Roth, Steve Buscemi"
- Semantic Similarity (25% weight)
- Uses sentence transformers to analyze movie plots and themes
- Creates embeddings from descriptions, keywords, and themes
- Finds movies with similar content, not just titles
- Example: "Similar themes: heist films, ensemble casts, nonlinear narrative"
- Year/Era Preferences (10% weight)
- Identifies your favorite decades from rating history
- Considers time period but doesn't over-weight it
- Example: "From the 1990s, one of your favorite eras"
- TMDB Similarity Algorithm (15% weight)
- Leverages TMDB's own "similar movies" recommendations
- 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):
- Decade-Based Filtering (simplified)
- Recommends from your favorite decades
- Uses a curated list of acclaimed films
- Basic Title Analysis (minimal)
- 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:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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.
