Plex Skill
Overview
- Manages a Plex Media Server through its HTTP API.
- Credentials stored in
.envfile next to this SKILL.md. Start from.env.example; the CLI auto-loads and validates the final.env. - Main helper script:
scripts/plex_cli.py(Python 3). - Dependency:
plexapipackage required forwatchlistcommand (pip3 install plexapi).
Quick Start
- Credentials: create
.envnext to this SKILL.md from.env.example, then fill in your real Plex URL and token. The CLI auto-loads.env, but CLI flags and existing shell env vars override it. - Run:
cp ~/.agents/skills/plex/.env.example ~/.agents/skills/plex/.env # edit ~/.agents/skills/plex/.env and replace the placeholder values python3 ~/.agents/skills/plex/scripts/plex_cli.py ping python3 ~/.agents/skills/plex/scripts/plex_cli.py libraries
Section IDs are server-specific. Use python3 ~/.agents/skills/plex/scripts/plex_cli.py libraries to discover them on the target server.
What This Skill Can Do
- Verify Plex connection and auth:
python3 ~/.agents/skills/plex/scripts/plex_cli.py ping - List Plex libraries:
python3 ~/.agents/skills/plex/scripts/plex_cli.py libraries - Search media by title:
python3 ~/.agents/skills/plex/scripts/plex_cli.py search --query "Alien" --limit 20 - Show recently added items:
python3 ~/.agents/skills/plex/scripts/plex_cli.py recently-added --limit 10 python3 ~/.agents/skills/plex/scripts/plex_cli.py recently-added --section-id SECTION_ID --limit 10 - Show active playback sessions:
python3 ~/.agents/skills/plex/scripts/plex_cli.py sessions - Get metadata by
ratingKey:python3 ~/.agents/skills/plex/scripts/plex_cli.py metadata --rating-key 12345 - Trigger library refresh (scan) — normally not needed, Plex scans automatically:
python3 ~/.agents/skills/plex/scripts/plex_cli.py refresh-section --section-id SECTION_ID - Get user's Plex Watchlist (from plex.tv cloud, not local server):
python3 ~/.agents/skills/plex/scripts/plex_cli.py watchlist python3 ~/.agents/skills/plex/scripts/plex_cli.py watchlist --filter movie python3 ~/.agents/skills/plex/scripts/plex_cli.py watchlist --filter show python3 ~/.agents/skills/plex/scripts/plex_cli.py watchlist --sort titleSort:asc
Watchlist
The watchlist lives on plex.tv (cloud), not on the local Plex server. The watchlist command uses python-plexapi to fetch it.
Important notes
- Requires:
pip3 install plexapi(already installed). - The local Plex server API does NOT have a watchlist endpoint — it only exists on plex.tv.
- Returns metadata from Plex's online database (title, year, guid, type). These are NOT local library items.
- To match watchlist items against the local library, search by title/year using the
searchcommand.
Filter options
--filter movie— only movies--filter show— only TV shows- No filter — returns all items (movies + shows)
Sort options (format: field:dir)
| Sort | Description |
|---|---|
watchlistedAt:desc | Most recently added to watchlist first (default) |
watchlistedAt:asc | Oldest watchlist additions first |
titleSort:asc | Alphabetical A→Z |
titleSort:desc | Alphabetical Z→A |
originallyAvailableAt:desc | Newest releases first |
rating:desc | Highest rated first |
Workflow: Download all watchlist movies
- Get watchlist:
plex_cli.py watchlist --filter movie - For each item, search RuTracker (see
rutrackerskill) - Send .torrent to NAS (see
synology-download-stationskill) - Plex picks up new files automatically after download
Operational Notes
- Default output is JSON for easy processing.
- Invalid or incomplete config also returns JSON errors, not Python tracebacks.
- Library refresh happens automatically — only use
refresh-sectionif the user explicitly asks. - Never print or commit real
PLEX_TOKEN. - Summarize results naturally — don't dump raw JSON to the user.
References
references/api-cheatsheet.mdfor endpoint and command mapping.