Syncs track ratings from Plex to ListenBrainz and/or Last.fm. ListenBrainz supports both loved and hated tracks.
By default, syncing is one-way (Plex → other services). Plex ratings are not modified unless you enable the TWO_WAY environment variable.
The script will only remove loved/hated tracks from Last.fm/ListenBrainz that it previously added, preserving any manually set ratings.
Create a config.env file in the repository root. Use config.env.example as a template.
Required settings:
PLEX_SERVER_URL: Your Plex server URLMUSIC_LIBRARY: Name of your music library (default: "Music")LOVE_THRESHOLD: Rating threshold for loving tracks (default: 10, which equals 5 stars). Plex uses a 0-10 scale where 1 star = 2 points.HATE_THRESHOLD: (Optional) Rating threshold for hating tracks on ListenBrainz
API credentials:
- Configure ListenBrainz and/or Last.fm credentials (at least one required)
-
Set the required environment variables in
config.env -
Authenticate with Plex:
sudo docker compose run --rm ratingrelay
Follow the authentication prompts. You can exit with
Ctrl+Cafter authenticating. -
Adjust the sync frequency by modifying this line in
docker-compose.yml:ofelia.job-run.ratingrelay.schedule: "@every 24h"
-
Start the container:
sudo docker compose up -d
-
Install dependencies:
uv sync --frozen
-
Run the script:
uv run /path/to/repo/ratingrelay.py
On first run, you'll be prompted for Plex authentication.
Alternatively:
/path/to/repo/.venv/bin/python /path/to/repo/ratingrelay.py -
Schedule regular execution using cron (Linux) or Task Scheduler (Windows)
Warning: Tests reset all data on the configured accounts. Use separate test accounts to avoid data loss.
- Install uv
- Install dependencies:
uv sync --frozen
- Create
test.envfromconfig.env.examplewith test account credentials - Either back up your existing database or change the
DATABASEvalue inconfig.envto use a separate test database - Edit
./ratingrelay/config.py:class Settings(BaseSettings): ... env_file="test.env")
- Run the script once to authenticate with Plex
- Run tests:
uv run pytest