Skip to main content

plextool

Command line tool for Plex library maintenance, built on python-plexapi. It talks to the server through its API. No access is made to the Plex database file, which is too risky to edit by hand.

What it is useful for

plextool is a command line toolkit for looking after a Plex Media Server: fixing things Plex's web interface can't, and finding problems across a large library. Typical jobs:

  • Fix the Recently Added order. This is what it was first built for. Plex has no way to edit the Recently Added lists, so after the database is rebuilt, duplicate files are deleted and Plex rescans, or files are reorganised on disk, everything shows up as "new" and the real newest content is buried. plextool recent changes the "added at" date of movies, shows, seasons and episodes: set each item back to its own release or air date, shift dates by an offset, or set one date for a whole batch. The date is locked so a rescan can't undo it.
    $ plextool recent --recent 20 --release              # preview: put the 20 newest back to their release dates
    $ plextool recent --title "Some Show" --shift=-30d --commit
    
  • Find and remove duplicate movies and episodes. plextool dupes lists every item Plex holds more than one file for, and can delete the extras that are not wanted.
  • Free up disk space. plextool stale finds large, never-watched or long-idle movies and shows.
  • Audit a library. plextool audit reports unmatched items, missing files, missing posters or summaries, low-resolution video, and missing subtitle or audio languages.
  • Copy, back up and restore watched status. plextool watched moves watched state between users (for example when a shared account is split), saves it to a file, and restores it after a rebuild or when someone closes and reopens their Plex account.
  • Clear a stuck Continue Watching list. plextool resume lists and removes entries that won't go away.
  • Back up and restore playlists. plextool playlists saves video playlists to a file and recreates them on the same or another server.
  • Get subtitles. plextool subs extracts the subtitle tracks inside MKV and MP4 files, searches Plex's subtitle providers for a language and downloads one, and, with --export, copies the subtitle Plex downloaded out of its database into a file beside the video so it works outside Plex too. Plex itself never writes that file.
  • Script Plex. Reports can print JSON, and exports can go through a pipe, so the output feeds other tools.

Everything that changes the server is a preview until --commit is passed. plextool uses Plex's API and never edits the Plex database file. It signs in through a browser with plextool auth, and works against a server on the same machine, across the internet, or directly with no internet access (plextool server).

Commands

Command What it does
plextool auth Sign in to Plex with a link or QR code, list and remove old sign-ins from the account, and wipe the saved login and keys.
plextool server Find servers on the account or network and choose the one to use. Covers working offline or directly against the server.
plextool status Server version, library sizes, who is watching what.
plextool scan Scan libraries or a single folder, refresh metadata, empty trash, optimize.
plextool recent Change "added at" dates to reorder Recently Added. Works on movies, shows, seasons and episodes.
plextool dupes List movies and episodes that have more than one file, and optionally delete the extras.
plextool stale Find large, unwatched or long-idle content to free up space.
plextool audit Find unmatched items, missing files, missing posters or summaries, low resolution, missing subtitle or audio languages.
plextool watched Copy watched state between users, back it up and restore it, or mark a show or movie watched.
plextool resume List or clear stuck Continue Watching entries.
plextool playlists Back up and restore video playlists.
plextool subs Extract subtitles from MKV and MP4 files, search Plex's subtitle providers for new ones and pick which to download, and copy subtitles Plex downloaded (kept in its database, not beside the video) out as files next to the video. Files are named for Plex, forced and SDH included.

The plextool commands that change anything do a dry run unless --commit is passed. Deleting files (dupes --keep) also asks for DELETE to be typed.

Quick start

Install it from PyPI. This needs python installed as a prerequisite:

$ python3 -m venv .venv && source .venv/bin/activate   # optional: keeps plextool's packages separate
$ pip install 'plextool[qr]'        # '[qr]' adds a QR code to the sign-in; leave it off if no QR code is wanted
$ plextool auth login               # open the link it prints (or scan the QR code) and approve
$ plextool server find              # servers on the Plex account and on the network
$ plextool server use "My Server"   # one of the names from the list
$ plextool status                   # libraries, and who is watching what right now

status ends with what is playing:

Now playing (1 session, 0 transcoding)
  alice: Some Movie (2020) [playing] on Living Room TV

To get, say, Swedish subtitles for that movie from the subtitle providers Plex searches:

$ plextool subs fetch -t "Some Movie" --lang sv --list               # see what is available; nothing is downloaded
$ plextool subs fetch -t "Some Movie" --lang sv --choose --commit    # pick one; Plex downloads it
$ plextool subs fetch -t "Some Movie" --lang sv --choose --export --commit   # same, and also save a file beside the video

Where the subtitle ends up. When Plex downloads a subtitle from a provider, it keeps the copy in its own database. It does not put a file next to the video, so only Plex can show it: another player, or another Plex server, never sees it. The first two commands stop there, and the subtitle is picked from the player's subtitle menu.

--export gets around that. Once Plex has downloaded the subtitle, plextool copies Plex's stored copy out of the server and saves it as an ordinary file beside the video (<video name>.sv.srt), which any player can use. It doesn't read the video file, so the MKV or MP4 is never opened, and it doesn't contact the subtitle provider. (Subtitle tracks that are already inside an MKV or MP4 are a different job, for plextool subs extract.) For --export, the machine it runs on must be able to read the media files. If it sees them under a different path than Plex does, use --map. The subs page sets out where each kind of subtitle comes from.

For a TV show, -t "Some Show" covers every episode, which is a search for each one, so start with --list.

If the server is on the same machine as the terminal, skip server find and server use: plextool tries http://localhost:32400 by default. Without internet access, see working offline.

Getting help

Every command explains itself, with options and examples:

$ plextool --help
$ plextool recent --help
$ plextool watched copy --help

To see what plextool is doing, add -v (--verbose) to any command. It prints each request sent to Plex, with the time, on standard error, followed by a line for the reply: the status, how many records were in it (and where that page sits in the whole list), its size and how long it took. It also prints when each slow step starts and finishes. The token is hidden in that output.

$ plextool stale --all-users -v

When a command takes more than 5 seconds, plextool prints Finished in 2m 14s on standard error at the end (with -v, always).

Reading a big library can take minutes. After about 10 seconds of silence, plextool prints still reading <library>... to standard error, and again every 20 seconds, so it is clear it has not stopped. --json output is not affected.

A fuller page for each command is on Read the Docs (linked in the table above); its source is in docs/source/commands/.

Install

plextool needs Python 3.10 or later, because plexapi 4.18 does. It is tested on Python 3.12. If something doesn't work on another version, please open an issue with the Python version.

plextool subs also needs MKVToolNix (mkvmerge, mkvextract) for MKV files and FFmpeg (ffmpeg, ffprobe) for MP4 files. Only the ones for the file types in use are needed.

$ pip install plextool     # installs the `plextool` command
$ plextool --help

To install from a checkout instead (this needs git):

$ git clone https://github.com/milkmansson/plextool.git
$ cd plextool
$ pip install .

To run from a checkout without installing, pip install -r requirements.txt and use python3 -m plextool ... instead.

Connecting

Sign in once. This prints a link (and a QR code, if segno is installed) to approve in a browser:

$ plextool auth login
$ plextool server find                       # skip if the server is on this machine
$ plextool server use "My Server"            # or: server use http://myserver:32400

Without a saved choice, plextool uses http://localhost:32400, or $PLEX_URL or --base-url if given. plextool server explains the options, including working with no internet or directly on the server's machine.

That saves a Plex token in ~/.config/plextool/ (readable only by the current user). plextool auth explains exactly what is kept, how to wipe it with plextool auth wipe, and --type jwt, a short-lived token that plex.tv accepts but Plex Media Server doesn't yet.

plextool looks for a Plex token in this order: --token, --token-file FILE (- for standard input), $PLEX_TOKEN, the output of $PLEX_TOKEN_CMD, then the saved login. Prefer --token-file or the environment to --token, which leaves the token in the shell history.

Development

$ pip install -e '.[dev]'
$ pytest

Disclaimer

These tools only use the documented plexapi calls, but they do write to the server when --commit is passed. Check the dry run first. Use is at the user's own risk.

Metadata

Release files for plextool 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plextool 3.1.1
File Size Uploaded Provenance Actions
plextool-3.1.1.tar.gz 71.8 kB With provenance Details for plextool-3.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for plextool 3.1.1
File Interpreter ABI Platform Actions
plextool-3.1.1-py3-none-any.whl Python 3 none any Details for plextool-3.1.1-py3-none-any.whl

Total release size: 131.9 kB

Release files / plextool-3.1.1.tar.gz

Download URL plextool-3.1.1.tar.gz
Size 71.8 kB
Tags Source
SHA-256 checksum
How to use checksums
70dd749cfabad18e7339be8c672d4f4e3f2205ea1e444eaa6d7bada6a0e044f1
BLAKE2b-256 checksum
How to use checksums
bd03b6e72c316d8d3cf4c6e3f4cd9cfecb176938eb945a21e70f71d232aa9035
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / plextool-3.1.1-py3-none-any.whl

Download URL plextool-3.1.1-py3-none-any.whl
Size 60.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b51b4f3802479c2dd01c8c4add7b1edb8f27b61dc9c11c93b81fdfb40f31271
BLAKE2b-256 checksum
How to use checksums
14d95e00cc5a8755f778884bb4571bbb267fab460b7272a61ac259767dbfe63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for plextool 3.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for plextool-3.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page