August 16, 2022

PlexTraktSync with Ofelia in Docker

PlexTraktSync with Ofelia in Docker

This guide assumes you already have a Plex Media Server up and running, a Linux server with Docker installed and a Trakt account.

First let's create your Trakt API app: https://trakt.tv/oauth/applications/new

Name: $AnythingYouWant
Description: $AnythingYouWillRememberInFurture
Redirect URI: urn:ietf:wg:oauth:2.0:oob

Then click Save App. You will need the newly created ClientID and ClientSecret in a moment, so keep that page open.

On your docker host, create a new folder wherever you keep your docker-compose files called 'plextraktsync':

mkdir plextraktsync

In this folder we create a 'docker-compose.yml' file:

nano docker-compose.yml

with the contents:
(from https://github.com/Taxel/PlexTraktSync#docker-compose)

services:
  scheduler:
    image: mcuadros/ofelia:latest
    container_name: scheduler
    depends_on:
      - plextraktsync
    command: daemon --docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    labels:
      ofelia.job-run.plextraktsync.schedule: "@every 6h"
      ofelia.job-run.plextraktsync.container: "plextraktsync"
  plextraktsync:
    image: ghcr.io/taxel/plextraktsync:latest
    container_name: plextraktsync
    volumes:
      - ./config:/app/config

With our file saved, let's run and daemonize it:

docker-compose up -d

And with our container running, we can do the first-time setup/authentication:

docker-compose run --rm plextraktsync

Fill in all the info it prompts you for

Plex email
Plex Password (Remember if you use 2FA you will need to append the code to the end of the password without a  space, EG: password123456)
Pick your server from the list available
Sign into Trakt using the link and enter the key provided
Finally enter your Trakt API Client ID and Client Secret

Once all that is entered it will automatically start scrobbling everything on your server for you. Be patient or grab a coffee here.

The last thing to do is to restart your containers to ensure that they are using the correct credentials now that you've logged in.

docker-compose stop

docker-compose up -d

And you're done! Happy Scrobbling!