Smart TV show recommendations designed specifically for background viewing. Tell the app what you're doing (laundry, coding, cooking, etc.) and it will recommend the perfect shows based on your mood, available time, and streaming subscriptions.
- Smart Text Analysis: Automatically detects mood and viewing constraints from natural language input
- TMDB Integration: Leverages The Movie Database API for comprehensive TV show data
- Streaming Integration: Filters recommendations by your streaming subscriptions
- Intelligent Caching: Reduces API calls with SQLite-based caching (24-hour TTL)
- User Feedback: Learn from your preferences with thumbs up/down voting
- Modern UI: Clean, responsive interface built with Tailwind CSS
- Backend: FastAPI (Python 3.11+)
- Database: SQLite with SQLModel ORM
- Frontend: Jinja2 templates + Tailwind CSS (CDN)
- External API: TMDB (The Movie Database)
- HTTP Client: httpx with async support
- Python 3.11 or higher
- TMDB API key (free) - Get one here
# Clone or download this repository
cd background-tv-genie
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Copy the example environment file
cp .env.example .env
# Edit .env and add your TMDB API key
# TMDB_API_KEY=your_actual_api_key_hereTo get a TMDB API key:
- Create a free account at TMDB
- Go to Settings > API
- Request an API key (choose "Developer" option)
- Copy the "API Read Access Token" or "API Key (v3 auth)"
# Start the development server
uvicorn app.main:app --reload
# Or using Python directly
python -m app.mainThe app will be available at: http://localhost:8000
# Test that your subscriptions are correctly configured
python -m scripts.verify_providers
# This will show which providers TMDB recognizes- Navigate to Settings (top right navigation)
- Select your streaming subscriptions (Netflix, Hulu, YouTube TV, Paramount Plus, Prime Video, Discovery Plus, Max)
- Choose your region (default: US)
- Click Save Settings
Note: The app supports flexible provider name matching. For example, "HBO Max" and "Max" are recognized as the same service, and "Amazon Prime Video" is matched to "Prime Video".
-
On the home page, describe what you're doing in the text box:
- "doing laundry"
- "cooking dinner tonight"
- "need something cozy while I work"
- "background noise for deep work"
-
Optionally adjust the filters:
- Mood: cozy, comfort, focus, energy, tech, spooky-chill
- Noise Level: low, medium
- Episode Length: short (<25m), standard (25-45m), long (45m+)
-
Click Find My Show
-
Browse recommendations and use π/π to provide feedback
- Netflix
- Hulu
- Max (HBO Max)
- Prime Video (Amazon)
- Disney Plus
- Peacock
- Paramount Plus
- Apple TV Plus
- YouTube TV
- Discovery Plus
The app uses a weighted scoring system (0.0 - 1.0):
- Genre Match (35%): How well show genres align with detected mood
- Vibe Score (20%): Popularity adjusted for desired noise level
- Episode Length (15%): Match with preferred episode duration
- Provider Availability (15%): Bonus for your subscriptions
- Popularity (10%): General show popularity
- Feedback Bias (5%): Your historical thumbs up/down votes
The app analyzes your input text for keywords and activities:
- Cozy/Comfort: Comedy, reality, animation
- Focus: Documentary, reality (low noise)
- Energy: Reality, talk shows, comedy
- Tech: Documentary, talk shows
- Spooky-chill: Mystery, reality, sci-fi/fantasy
Certain activities automatically set optimal parameters:
| Activity | Episode Length | Noise Level |
|---|---|---|
| Laundry | Standard | Low |
| Short | Low | |
| Writing | Short | Low |
| Cooking | Standard | Medium |
| Deep Work | Long | Low |
background-tv-genie/
βββ app/
β βββ __init__.py
β βββ main.py # FastAPI app and routes
β βββ config.py # Settings and environment variables
β βββ db.py # Database connection
β βββ deps.py # FastAPI dependencies
β βββ models.py # SQLModel database models
β βββ schemas.py # Pydantic request/response schemas
β βββ recs.py # Recommendation logic
β βββ tmdb_client.py # TMDB API client with caching
β βββ static/
β β βββ site.js # Frontend JavaScript
β βββ templates/
β βββ base.html # Base template
β βββ index.html # Home page
β βββ results.html # Recommendations display
β βββ settings.html # Settings page
βββ tests/
β βββ __init__.py
β βββ test_recs.py # Recommendation logic tests
βββ .env.example # Environment variables template
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ README.md # This file
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/test_recs.py# Build the image
docker build -t background-tv-genie .
# Run the container
docker run -p 8000:8000 --env-file .env background-tv-genie
# Or using docker-compose
docker-compose upGET /- Home page with recommendation formPOST /recommend- Submit request and get recommendationsGET /settings- Settings pagePOST /settings- Update user preferencesPOST /feedback- Submit thumbs up/down feedback (JSON)
- TMDB API: Free tier allows 10,000 requests per day
- Caching: All TMDB responses cached for 24 hours in SQLite
- Provider Map: Loaded once at startup and cached
To adjust cache TTL, modify CACHE_TTL_HOURS in .env
Edit app/recs.py:
MOOD_TO_GENRES = {
"your-mood": [genre_id_1, genre_id_2],
# ...
}
MOOD_KEYWORDS = {
"your-mood": ["keyword1", "keyword2"],
# ...
}TMDB Genre IDs:
- 35: Comedy
- 99: Documentary
- 10764: Reality
- 10767: Talk
- 16: Animation
- 9648: Mystery
- 10765: Sci-Fi & Fantasy
TASK_HINTS = {
"your-task": {"episode_len": "standard", "noise_level": "low"},
# ...
}- Ensure your
.envfile exists and hasTMDB_API_KEY=your_key - Restart the server after adding the key
- Check that your TMDB API key is valid
- Ensure you have an internet connection
- Check server logs for API errors
- Run
python -m scripts.verify_providersto check provider configuration
- Run the provider verification script:
python -m scripts.verify_providers - Check if TMDB lists your provider for your region
- Provider names must match TMDB's naming (e.g., "Max" not "HBO Max")
- Some providers may not be available in TMDB's database for certain regions
- Delete
data.dbfile and restart (will reset all preferences) - Check file permissions for SQLite database
This is a demonstration project. Please comply with TMDB Terms of Use when using their API.
- The Movie Database (TMDB) for comprehensive TV data
- FastAPI for the excellent web framework
- Tailwind CSS for beautiful styling
Built with β€οΈ for those who need the perfect background companion.