Skip to main content

plextool

Swiss army knife command line tool for Plex library maintenance. Built on python-plexapi, which talks to the server through its API. No accesses is made to the Plex database file which is too risky to edit by hand.

What it is useful for

plextool is a CLI toolkit for looking after a Plex Media Server: fixing things Plex's web interface can't, giving CLI methods to things that would otherwise need many clicks through the web interface for, for server maintenance over SSH, and for finding and fixing problems in large libraries. 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
    
  • Manage who has access. plextool users lists who can use the server, invites people, changes what they can see and removes them, with a preview of exactly what would be granted or lost.
  • Tidy the apps authorised on the account. plextool devices lists every app and device signed in to the Plex account and removes the old ones by ID, age, app or name. It never removes a Plex Media Server.
  • Give another tool its own token. plextool token makes, lists and revokes tokens for a program such as a Plex MCP server, so it does not need the saved login. Whether it is full access (--rw) or a shared user's (--ro) has to be stated, and the output says what the token can do.
  • 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.
  • Look up an item, or compare several. plextool info shows what Plex holds about a movie, show or episode: the people, the tags and IDs, and the technical side (paths, video, audio and subtitle tracks). Giving more than one item shows them side by side with the differences marked.
  • 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.

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 users See who has access to the server, and invite, change and remove people: libraries, restrictions, downloads, invitations. Previews until --commit.
plextool devices List the apps and devices authorised on the Plex account, and sign out the ones no longer wanted, by ID or by age, app or name. Plex Media Servers are never removed.
plextool token Make, list and revoke tokens for other tools (such as an MCP server) without sharing the saved login: a separate full-access token that can be revoked on its own, or a shared user's token. Also shows who has access to the server.
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 info Everything Plex holds about one item: people, tags, playback, and every file, path, video, audio and subtitle track. Several items can be compared side by side.
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.2.0

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.2.0
File Size Uploaded Provenance Actions
plextool-3.2.0.tar.gz 106.1 kB With provenance Details for plextool-3.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 193.6 kB

Release files / plextool-3.2.0.tar.gz

Download URL plextool-3.2.0.tar.gz
Size 106.1 kB
Tags Source
SHA-256 checksum
How to use checksums
935f0a2c683016e070d22a9400b9a8b6ab72c4215d48bd13732b781dfb952d11
BLAKE2b-256 checksum
How to use checksums
46b8ca89d54ec4afd8c52a7edc0931d9c1e53756118fa4319eec8b11e3101e74
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.2.0-py3-none-any.whl

Download URL plextool-3.2.0-py3-none-any.whl
Size 87.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20ae0fe0f4d140020e933f4a88a4405ffe2dc242d876c2bce2e56c4e75254f7e
BLAKE2b-256 checksum
How to use checksums
c91b5a8944b7d9453d5efb73b81a3f17c3848fae90ee88fa90022f2b8f6bf594
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.2.0

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.2.0.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.2.0 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