A tool that syncs Letterboxd user data (ratings, watch history, and watchlists) to a personal Plex server. THIS IS A ONE WAY SYNC. This tool aims to enhance your Plex experience by keeping your viewing stats up to date with your Letterboxd profile! π
This project is provided βas-isβ without any guarantees or warranties of any kind. By using this tool, you accept full responsibility for any risks, including but not limited to data loss, misconfigurations, or disruptions to your Plex or Radarr server.
- Rate Limits: Frequent use of this tool may trigger API rate limits for Plex, TMDB, or Radarr. Ensure you comply with their respective terms of service.
- Letterboxd Scraping: This tool relies on simulating Letterboxd browser actions. Use this tool responsibly and at your own risk, as it is unknown if this could result in account restrictions.
- Sensitive Data: Handle your .env file carefully, as it contains sensitive credentials (e.g., Plex token, Letterboxd credentials, API keys). Do not share this file or include it in public repositories.
- Testing Recommended: Test this tool on a non-production server or with a limited dataset before deploying it to your main Plex or Radarr setup.
- Use at Your Own Risk: The authors are not responsible for any consequences resulting from the use of this tool.
This project simplifies syncing Letterboxd data to Plex by offering a simple Python script, as well as a Docker container wrapping that script with a cron process for easy deployment and automation.
The script leverages:
- Plex API wrapper to interact with your Plex server.
- letterboxd_stats library to download and process Letterboxd user data.
Currently, it focuses on syncing:
- β User ratings
- π Watch history
- π Watchlist (now with Radarr support)
The core functionality is provided by a Python script that:
- Fetches Data: Downloads user data from Letterboxd using the
letterboxd_statslibrary. - Processes Metadata: Maps Letterboxd data to Plex-compatible IDs using TMDB for additional metadata when required.
- Syncs Data: Updates the Plex server by:
- Adding ratings from Letterboxd.
- Marking movies as watched/unwatched.
- Syncing the Letterboxd watchlist, optionally integrating with Radarr.
The script behavior is highly configurable through environment variables, allowing users to tailor the sync to their specific requirements.
The script can sync data across all movie-type libraries in your Plex server. However, if you'd like to target a specific library, you can set the PLEX_LIBRARY_NAME environment variable. For example:
- If
PLEX_LIBRARY_NAMEis set (e.g., "Movies"), the script will sync data only with that library. - If
PLEX_LIBRARY_NAMEis not set, the script will automatically iterate through all movie libraries in your Plex server, ensuring comprehensive syncing without additional configuration.
For users who manage their media with Radarr, the script offers an additional integration:
- When the
SYNC_WATCHLIST_TO_RADARR(default:false) environment variable is set totrue, the script will take movies from your Letterboxd watchlist and add them to Radarr as monitored movies. - To enable this, you must provide:
RADARR_URL: The base URL for your Radarr server.RADARR_TOKEN: The API key for authenticating with Radarr.- Optionally, specify
RADARR_TAGSto tag these movies (e.g.,letterboxd-plex-sync), helping you organize and manage additions in Radarr.
The Python script is wrapped within a lightweight Docker container that automates execution via a cron process. The container:
- Runs Immediately (Optional): With the
RUN_NOWenvironment variable, the sync job can execute as soon as the container starts. - Schedules Jobs: A cron process schedules recurring sync jobs based on the
CRON_SCHEDULEenvironment variable. - Logs Activity: Outputs logs to a combined file for easy monitoring of sync activities and troubleshooting.
The container is designed for ease of use:
- Configurations are passed as environment variables in a
.envfile. - Users can choose between running the script locally or using Docker, depending on their preferences and setup.
This design ensures seamless integration with your existing Plex server and minimal manual intervention once deployed.
The script relies on several environment variables for configuration. Here is a list of all the environment variables you need to set:
PLEX_BASEURL: The base URL of your Plex server (e.g.,http://your-plex-server:32400).PLEX_TOKEN: Authentication token for accessing your Plex server.LB_USERNAME: Your Letterboxd username.LB_PASSWORD: Your Letterboxd password.TMDB_API_KEY: Your TMDB API key, required for fetching additional metadata.
DEBUG: Set totrueto enable debug logging. Defaults tofalse.RUN_NOW: Set totrueto run the sync job immediately when the container starts. Defaults tofalse.
CRON_SCHEDULE: The schedule for the cron job (e.g.,0 4 */1 * *for every day at 4:00AM). Defaults to0 4 */1 * *.
SYNC_WATCHLIST: Set totrueto sync the watchlist from Letterboxd to Plex. Defaults totrue.SYNC_WATCHED: Set totrueto sync watched status from Letterboxd to Plex. Defaults totrue.SYNC_RATINGS: Set totrueto sync user ratings from Letterboxd to Plex. Defaults totrue.PLEX_LIBRARY_NAME: The Plex Movies library to use. Defaults to syncing all Movie-type libraries.PLEX_USER: The Plex user to use for syncing, if not the default admin.PLEX_PIN: The PIN associated with the Plex user, if required.
SYNC_WATCHLIST_TO_RADARR: Set totrueto sync the Letterboxd watchlist to Radarr. Defaults tofalse.RADARR_URL: The base URL of your Radarr server (e.g.,http://your-radarr-server:7878). Required if syncing watchlist to Radarr.RADARR_TOKEN: The API key for your Radarr server. Required if syncing watchlist to Radarr.RADARR_TAGS: A comma-separated list of tags to assign to movies added to Radarr. Tags must exist in Radarr or will be created automatically if they donβt. Optional.RADARR_ROOT_FOLDER: The root folder path in Radarr where new movies will be added (e.g.,/movies). Defaults to/moviesif not provided. Optional.RADARR_MONITORED: Whether to set movies as monitored in Radarr. Defaults totrue.RADARR_SEARCH: Whether to search for the movie after it is added to Radarr. Defaults totrue.RADARR_QUALITY_PROFILE: The name of the quality profile to use in Radarr (e.g.,HD - 1080p). If not provided or not found, defaults to the profile with ID1. Optional.
# Schedule for the cron job (default: every day at 4:00AM)
#CRON_SCHEDULE="0 4 */1 * *"
# Immediately run the sync job on container startup (default: false)
#RUN_NOW="false"
# Debug mode (default: false)
#DEBUG="false"
# Plex server configuration (required)
PLEX_BASEURL="http://your-plex-server:32400"
PLEX_TOKEN="your_plex_token_here"
# Plex details (optional depending on setup)
#PLEX_LIBRARY_NAME='Movies' # Optional: to sync only one library
#PLEX_USER="your_plex_username" # Optional: switch to a specific Plex user
#PLEX_PIN="your_plex_pin_here" # Optional: required if switching Plex user
# Letterboxd credentials (required for downloading data)
LB_USERNAME="your_letterboxd_username"
LB_PASSWORD="your_letterboxd_password"
# TMDB API key (required for TMDB lookups)
TMDB_API_KEY="your_tmdb_api_key_here"
# Radarr configuration
RADARR_URL="http://your-radarr-server:7878" # required if syncing to Radarr
RADARR_TOKEN="your_radarr_api_key_here" # required if syncing to Radarr
RADARR_TAGS="letterboxd-plex-sync, auto" # optional: set whatever tags you like, or comment this out to skip adding tags
#RADARR_ROOT_FOLDER='/movies' # Radarr desintation folder. default: '/movies'
#RADARR_MONITORED='true' # Monitor movie in Radarr. default: 'true'
#RADARR_SEARCH='true' # Search movie after adding. default: 'true'
#RADARR_QUALITY_PROFILE='HD - 1080p' # default: Whichever profile has index 1 (usually 'Any')
# Sync options (set to "true" or "false" to enable/disable)
#SYNC_WATCHLIST="true" # default: true
#SYNC_WATCHED="true" # default: true
#SYNC_RATINGS="true" # default: true
SYNC_WATCHLIST_TO_RADARR="true" # default: false
There are multiple ways to run the letterboxd_plex_sync script:
Here's a sample Docker Compose setup to run the letterboxd_plex_sync script on a schedule:
---
name: letterboxd-plex-sync
services:
letterboxd-plex-sync:
container_name: letterboxd-plex-sync
image: treysu/letterboxd-plex-sync:latest
restart: unless-stopped
#platform: linux/x86_64 # typically only needed for Apple Silicon
env_file:
- path: letterboxd.env
required: true
volumes:
- /etc/localtime:/etc/localtime:ro # optional: for accurate log times
- path/to/resources:/app/data:rw # technically optional: add folder to avoid regenerating lb to tmdb mapping CSV fileTo use Docker Compose:
docker compose up -dAlternatively, you can run the container directly with Docker:
docker run -d \
--env-file letterboxd.env \
-v path/to/resources:/app/resources:rw \
treysu/letterboxd-plex-sync:latestIf you prefer to run the script locally without Docker:
-
Clone the Repository:
git clone https://github.com/treysu/letterboxd-plex-sync.git cd letterboxd-plex-sync/python -
Install Dependencies:
Ensure you have Python installed, then install the required packages:pip install -r requirements.txt
-
Run the Script:
Make sure yourletterboxd.envfile is properly set up with your Plex and Letterboxd credentials, then run the script:source letterboxd.env python generate_config.py python sync_lb_to_plex.py
- π Better handling of multiple Plex users.
- π Sync additional types of data (e.g., tags, custom lists).
- π Improved logging and error handling.
Feel free to open issues or make pull requests. This project is still a work in progress, and contributions are welcome!