Sign inSign up

thorgilis/plex-movie-export

By thorgilis

•Updated about 1 year ago

A Python app, to extract movie information from Plex and push to Postgres

Image
Integration & delivery
API management
Databases & storage
1

233

thorgilis/plex-movie-export repository overview

⁠Plex Export Data – Docker Image 🐳

Export and analyze Plex Media Server data. Run it once or put it on a schedule. Funky, but not flashy.

⁠TL;DR

# One-off run (no scheduling)
docker run --rm \
  --name plex-export \
  -e PLEX_BASE_URL=http://your-plex:32400 \
  -e PLEX_TOKEN=your_plex_token \
  -e DB_HOST=host.docker.internal \
  -e DB_PORT=5432 \
  -e DB_NAME=plex_stats \
  -e DB_USER=myuser \
  -e DB_PASSWORD=supersecret \
  thorgilis/plex-export:latest
# Scheduled run (daily at 03:00)
docker run -d \
  --name plex-export \
  --restart=no \
  --env-file .env \
  -e CRON_SCHEDULE="0 3 * * *" \
  thorgilis/plex-export:latest

⁠Features ✨

  • Minimal image: based on python:3.12-slim
  • Built-in scheduler: cron for hands-off runs
  • Clear logs: cron output is tailed to container logs
  • Sensible defaults with environment overrides

⁠How it works

  • If CRON_SCHEDULE is unset/empty: the container runs python app/main.py once, then exits.
  • If CRON_SCHEDULE is set: a cron job runs /usr/local/bin/run-etl.sh (which calls python app/main.py) on the schedule. Logs stream to stdout via /var/log/cron.log.

⁠Environment variables

NameRequiredDescription
PLEX_BASE_URLYesPlex server base URL
PLEX_TOKENYesPlex auth token
DB_HOSTYesPostgres host
DB_PORTYesPostgres port
DB_NAMEYesDatabase name
DB_USERYesDatabase user
DB_PASSWORDYesDatabase password
CRON_SCHEDULENoCron expression for scheduled runs

Pro tip: Use an .env file to avoid putting secrets in your shell history.

⁠Example .env
PLEX_BASE_URL=http://your-plex:32400
PLEX_TOKEN=your_plex_token
DB_HOST=host.docker.internal
DB_PORT=5432
DB_NAME=plex_stats
DB_USER=myuser
DB_PASSWORD=supersecret
# Leave empty to run once, or set a schedule:
CRON_SCHEDULE=0 3 * * *

⁠Docker Compose

services:
  plex-export:
    image: thorgilis/plex-export:latest
    container_name: plex-export
    environment:
      - PLEX_BASE_URL=http://your-plex:32400
      - PLEX_TOKEN=your_plex_token
      - DB_HOST=host.docker.internal
      - DB_PORT=5432
      - DB_NAME=plex_stats
      - DB_USER=myuser
      - DB_PASSWORD=supersecret
      - CRON_SCHEDULE=0 3 * * *
    restart: "no"

⁠Logs

# One-off run: logs print to stdout automatically
# Scheduled run: follow cron output
docker logs -f plex-export

⁠Tags

  • latest
  • Versioned tags may be published alongside latest.

⁠Security

  • Prefer --env-file .env over long -e lists
  • Consider secrets managers for tokens and passwords

⁠License

MIT. See the project repository for details.

Tag summary

Content type

Image

Digest

sha256:1918fb6ef…

Size

61.2 MB

Last updated

about 1 year ago

docker pull thorgilis/plex-movie-export