An intelligent, privacy-focused TV and movie recommendation system powered by your Trakt.tv watch history and a local GPU-accelerated Large Language Model (LLM). This tool analyzes your viewing habits to generate personalized recommendations without sending your data to third-party AI services.
- Trakt Recommendation Agent
The Trakt Recommendation Agent offers a personalized discovery experience by combining structured data from Trakt with the semantic understanding of modern LLMs.
Key Features:
- Privacy-First: Uses a local LLM (OpenAI-compatible) for all reasoning; your detailed history stays local.
- Smart Filtering: Automatically excludes watched items, works with release year constraints, and respects genre exclusions.
- Taste Profiling: Generates a psychological profile of your media preferences based on your history.
- Flexible Interactions: Supports "seeding" recommendations with specific titles and marking items as watched manually.
- Obsidian Integration: specific output format designed for Obsidian users (
output/Trakt Recommendations.md).
trakt_agent/
├── cli.py # Main entry point for all commands
├── config.py # Global configuration settings (paths, API keys config)
├── requirements.txt # Python dependencies
├── core/ # Core application logic
│ ├── fetch_data.py # Retrieves watch history from Trakt API
│ ├── profile_taste.py # Analyzes history to generate user profile
│ ├── recommend.py # Interacts with LLM to generate recommendations
│ └── mark_watched.py # Handles marking items as watched on Trakt
├── data/ # Local data cache (history, candidates)
├── scripts/ # Helper scripts
│ ├── exchange_pin.py # OAuth authentication script
│ └── validate_llm.py # Utility to test LLM connection
├── resources/ # Templates and default resources
│ ├── secrets.json.example # API credentials template
│ └── preferences.json.example # User preferences template
└── output/ # Generated markdown files (recommendations, logs)
Before setting up, ensure you have the following:
- Python 3.8+: Installed on your system.
- Trakt.tv Account: You need an account to fetch history and sync changes.
- Trakt API App: Create a new API application at Trakt.tv/oauth/applications.
- Name:
Trakt Agent(or similar) - Redirect URI:
urn:ietf:wg:oauth:2.0:oob
- Name:
- Local LLM Server: We recommend using LM Studio or Ollama with a wrapper like OpenWebUI.
- Standard configuration assumes an OpenAI-compatible server at
http://127.0.0.1:1234/v1.
- Standard configuration assumes an OpenAI-compatible server at
Get up and running in under 5 minutes:
./install.shThis script will:
- Check for Python 3.8+ and pip
- Create a virtual environment
- Install all dependencies
- Create necessary directories
source venv/bin/activate # Activate virtual environment
python setup.py # Interactive setup wizardThe setup wizard will guide you through:
- Creating a Trakt API application
- Configuring API credentials
- Setting your content preferences
- Authenticating with Trakt
python cli.py fetch # Fetch your watch history
python cli.py recommend # Generate recommendationsYour recommendations will be saved to output/Trakt Recommendations.md!
Download this repository to your local machine.
It is recommended to use a virtual environment to manage dependencies.
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCopy the example secrets file and add your Trakt API details.
cp resources/secrets.json.example secrets.jsonEdit secrets.json and fill in your client_id and client_secret obtained from the Trakt dashboard.
Run the exchange script to generate your user access token.
python scripts/exchange_pin.pyFollow the prompts: click the link, log in to Trakt, copy the PIN, and paste it into the terminal.
Ensure your local LLM server is running.
- Open
config.py. - Verify
LLM_API_URLmatches your server (default:http://localhost:1234/v1). - Update
MODEL_NAMEto match the identifier of your loaded model (e.g.,qwen2.5-7b-instruct-v1).
Customize how recommendations are generated.
cp resources/preferences.json.example preferences.jsonEdit preferences.json:
preferred_min_year: Exclude content older than this year (e.g.,2010). Set to0to disable.genre_exclusions: List of genres to never recommend (e.g.,["Musical", "Documentary"]).min_imdb_score: Minimum IMDb rating filter.
The specific workflow is managed via cli.py.
-
Fetch Data: Download your latest watch history and watchlist from Trakt.
python cli.py fetch
-
Generate Profile: Analyze your history to create a taste profile.
python cli.py profile
-
Get Recommendations: Generate a list of recommendations based on your profile and candidates.
python cli.py recommend
Output is saved to
output/Trakt Recommendations.md.
Seed Recommendations: Influence the current batch by providing specific "seed" titles.
python cli.py recommend "Inception" "Interstellar"Mark Items as Watched: Manually mark items as watched on Trakt to exclude them from future recommendations.
python cli.py mark "The Room (2003)" "Cats (2019)"Check All Commands:
python cli.py --help- "Python 3.8+ not found": Install Python from python.org and ensure it's in your PATH.
- "Permission denied" on install.sh: Run
chmod +x install.shto make it executable. - Virtual environment issues: Try manually creating with
python3 -m venv venv.
- "Connection Refused" (LLM): Ensure your local LLM server (e.g., LM Studio) is running and the server is started on port
1234. - "Model not found": Check that the
MODEL_NAMEinconfig.pymatches the model string in your LLM server exactly. - Auth Errors: If your token expires or is invalid, delete
token.jsonand runpython scripts/exchange_pin.pyagain.
- Empty Recommendations: If
fetchreturns no candidates, try expanding yourpreferences.json(e.g., lower the year limit) or ensure you have enough history on Trakt. - Too many duplicates: Increase
HISTORY_LIMITinconfig.pyto fetch more watch history (default: 2000). - Slow generation: The LLM generation time depends on your local hardware. Consider using a smaller model or increasing
CANDIDATE_LIMITinconfig.py.
- Check existing issues
- Review the documentation
- Run
python cli.py --helpfor command reference
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the submission process.
This project is licensed under the MIT License - see the LICENSE file for details.
