360 Secure SkillHub
360 安全技能中心

Plex Server

基于 Node 的命令行工具,使用 Plex token 调用 Plex 服务器 HTTP API,支持服务器发现与配置、媒体搜索及格式化输出、库/会话/更新状态查询和媒体库扫描;可选通过 ADB 对 Nvidia Shield 执行连接、只读诊断、重启和重启 Plex 应用。配置与 token 保存在宿主专属配置文件中。

分类:生活
grewingm
grewingm
热度 16.94
最近更新 2026-11-30 22:37:18

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add grewingm/plex-server
兼容性
OpenClaw 专属
联网要求
需要联网
数据出网
必须出网
Metadata
name
Plex Server
description
Manage Plex Media Server with optional Nvidia Shield ADB device management.
allowed-tools
["exec"]
permissions
["env","network","shell","file_read","file_write"]
user-invocable
true
metadata
{"openclaw":{"homepage":"https://github.com/GrewingM/openclaw-skill-plex-server","requires":{"bins":["node"]},"config":[{"id":"PLEX_TOKEN","label":"Plex token","type":"secret"}]}}

Plex Media Server Manager

Primary focus: Plex Media Server management via HTTP API. Optional: Nvidia Shield device management via ADB.

Secrets: rules for the agent

  • Never ask the user to type, paste or send the Plex token in chat, and never put it in a command line, a URL or a file you write.
  • If the token is missing, tell the user to do one of these themselves: set PLEX_TOKEN in the skill's OpenClaw config (it is declared as a secret), or run node scripts/shield-cli.js setup in their own terminal, which asks for the token with a hidden prompt.
  • Never print PLEX_TOKEN, ~/.openclaw/shield/config.json or any command output that could contain the token.
  • If the user pastes a token into chat anyway: don't repeat it, don't use it in a command, and suggest they sign out of all devices in Plex (which issues a new token) and set it up again as above.

What the skill accesses

  • Network: your Plex Media Server at the configured plex_url, and plex.tv (only during discover and setup, to list your servers). Redirects are refused, so the token goes nowhere else.
  • Environment: PLEX_TOKEN, and optionally PLEX_FORMAT_LANG.
  • Local file: ~/.openclaw/shield/config.json (mode 600): server URL, optional Shield address and the token. setup and configure save the token they used, whatever its source (PLEX_TOKEN, the prompt or stdin). At runtime PLEX_TOKEN overrides the stored token without updating the file.
  • Programs: adb, only when shield_ip is set: for the four Shield commands below and for the ADB part of health (connect, then read-only shell diagnostics: uptime, memory, disk, the Plex process, battery). It never receives the token. For a check that never touches the Shield, use plex-status.
  • Code: scripts/shield-cli.js is the entry point; the rest of the CLI lives in small modules in scripts/ and scripts/lib/ (config storage, plex.tv/server HTTP client, adb helpers, output formatting, one file per command group). Node.js built-ins only, no dependencies.

ADB access is powerful

The Shield commands need Debugging over network, which gives any authorized computer full shell access to the Shield (apps, data, reboot), and "Always allow" keeps that authorization until it is revoked. Explain this before helping the user enable it, run ADB commands only when the user asks for them, and treat reboot and restart-plex as interrupting playback: ask first. To undo it the user turns off Debugging over network and revokes USB debugging authorizations in Developer options.

Onboarding

The user does these steps; the agent only explains them.

Step 1: Get your Plex token

  1. Open Plex Web (app.plex.tv), play any media
  2. Click "⋯" → "Get Info" → "View XML"
  3. In the URL, find X-Plex-Token=... — that's your token

Step 2: Make the token available

Either set PLEX_TOKEN in the skill's OpenClaw config, or let setup ask for it with a hidden prompt (Step 4). The token is never passed as an argument.

Step 3: Discover your servers

node scripts/shield-cli.js discover

Lists all Plex servers on your account with name, version, platform, and local URL.

Step 4: Configure

# Plex only (auto-discovers first server, over HTTPS)
node scripts/shield-cli.js setup

# Pick a specific server (if you have multiple)
node scripts/shield-cli.js setup --server 0    # first server
node scripts/shield-cli.js setup --server 1    # second server

# Plex + Shield ADB
node scripts/shield-cli.js setup --server 0 --shield-ip 192.168.70.2

Without PLEX_TOKEN set, run these in a terminal: they ask for the token without echoing it. For automation, pipe it in with --token-stdin from a password manager. If there is no token, no terminal and no --token-stdin, the command stops with exit code 2 instead of waiting.

No username/password needed — the Plex token is the universal key. The script calls plex.tv/api/resources to auto-discover the chosen server's own address, preferring its HTTPS (*.plex.direct) connection. If the server offers only plain HTTP, setup stops; --allow-http accepts it, but then the token travels unencrypted on your network (enable "Secure connections" in Plex instead when you can). Setup sets up ADB only when you pass --shield-ip. The token is sent only in the X-Plex-Token request header, never in a URL.

Config stored at ~/.openclaw/shield/config.json (chmod 600). When PLEX_TOKEN is set, it takes precedence over the stored token.

Commands

Plex (no ADB needed)

Command Args Notes
discover [--token-stdin] List all Plex servers on account
setup [--server N] [--shield-ip IP] [--allow-http] [--token-stdin] Auto-discover + configure (HTTPS; plain HTTP only with --allow-http)
configure --shield-ip IP [--plex-url URL] [--token-stdin] Manual config, no discovery. URL is http(s)://host[:port] only (no path, query or user info); without it, http://IP:32400 (warns: plain HTTP)
plex-status — Server version, platform
search <query> Search with full metadata
format [--lang it|en] Pipe search JSON → readable text. Italian by default (the author's household); --lang en or PLEX_FORMAT_LANG=en for English
sessions — Active streams
libraries — Library sections with IDs
scan <section_id> Refresh a library
recently-added — Last 20 additions
updater-status — Plex update availability
health — Plex status + sessions; with shield_ip set, also ADB connect and read-only device diagnostics (use plex-status for Plex only)

Shield ADB (requires shield_ip)

Command Notes
connect ADB connect
adb-health Uptime, memory, disk, battery
reboot Reboot Shield
restart-plex Force stop + start Plex app

Search + Format Pipeline

node scripts/shield-cli.js search "query" | node scripts/shield-cli.js format

Produces channel-agnostic formatted output with emoji, suitable for Discord, WhatsApp, Telegram, etc.

Search Output Fields

  • Basic: title, year, type, source (local/streaming), library, summary
  • Genres: genre tags from Plex metadata
  • Quality: resolution (4k/1080p/720p), video codec, bitrate, container, file size
  • Audio: codec, channels, language per track
  • Subtitles: codec, language per track
  • Meta: duration, studio, content rating, view count

Gotchas

  • Plex token = full server admin access. Config file is chmod 600.
  • No login/password needed — the token is the universal key for all Plex API calls.
  • Multiple servers? Use discover to list them, then setup --server <index> to pick.
  • Requires Node.js 18 or later (built-in fetch). curl is no longer used.
  • Shield on Wi-Fi may change IP. Use DHCP reservation for ADB.
  • Always pipe search through format for user-facing output.
  • ADB features are optional — Plex-only setup works without Shield/ADB.