Skip to content

Latest commit

 

History

History
170 lines (122 loc) · 7.7 KB

plex.md

File metadata and controls

170 lines (122 loc) · 7.7 KB

Plex Media Server

Use cliamp to stream music from Plex Media Server, including any library served by PlexAmp. Streaming uses the Plex HTTP API. You do not need extra software.

Quick start: Run cliamp setup, select Sign in with Plex, approve cliamp in the browser, and select a server. cliamp discovers and verifies local, remote, and relay connections automatically. Manual setup remains available.

Prerequisites

  • Plex Media Server running and signed in to your Plex account
  • At least one music library configured in Plex

For access away from home, enable Plex Remote Access. Plex Relay is the fallback when no direct connection answers in time.

Browser sign-in

Run cliamp setup, select Plex Media Server, and keep the recommended browser sign-in option. cliamp opens the Plex-hosted authorization page and waits for approval. If more than one server is available, select one in the wizard. The chosen server and a stable identifier for this cliamp installation are saved in [plex]:

[plex]
url       = "https://192-168-1-10.0123abcd.plex.direct:32400"
token     = "xxxxxxxxxxxxxxxxxxxx"
client_id = "written-by-sign-in"
server_id = "written-by-sign-in"

Setup writes client_id and server_id; do not set them by hand. With both set, cliamp finds the server through plex.tv and does not use url.

On every start, cliamp asks Plex for the selected server's current connection addresses and checks them at the same time. It prefers a secure local address, then a plain-HTTP local address, then a secure direct remote address, and finally a secure relay. It does not wait long for a better address: when one address has answered, a better one must answer within 100 ms. A slow secure local address can therefore lose to a plain-HTTP local one, and a slow direct address to a relay. Public plain-HTTP addresses are never selected. Before cliamp sends the token to an address, it asks the address, without the token, whether it is the selected server.

cliamp keeps the address it found until it exits. After a network change, restart cliamp to find the server again.

On a plain-HTTP local address the token travels unencrypted inside the local network. Use the manual setup with an https:// URL where you do not trust that network.

This means the same configuration can move between home and work without hard-coding a 192.168.x.x address. Remote playback still requires the Plex server to advertise a reachable remote or relay connection.

Change the music libraries

Run cliamp setup, select Plex Media Server, and choose Change music libraries. Setup shows this option while [plex] holds a token. It changes only libraries and keeps the saved login. Leave the field blank to load every music library. Restart cliamp if it is running.

Sign out

Run cliamp setup, select Plex Media Server, and choose Sign out and remove saved credentials. To change the server or the login type, sign out and sign in again.

  • After a browser sign-in, cliamp asks Plex to revoke the token, checks that Plex no longer accepts it, and removes token, server_id, url, and libraries from [plex].
  • A manual token was copied from Plex Web and belongs to that session, so cliamp does not revoke it. It removes token and libraries and keeps the server URL.

client_id stays, so a later sign-in is the same Plex device. If Plex cannot be reached or still accepts the token, cliamp removes it anyway and asks you to remove the device under Authorized Devices in your Plex account. Restart a running cliamp, which keeps the token in memory.

Manual token setup

To configure a fixed server URL instead, select the manual option in setup or find an X-Plex-Token:

  1. Open Plex Web in a browser and sign in.
  2. Browse to an item in the music library.
  3. Click the ··· menu → Get Info → View XML.
  4. Copy the X-Plex-Token query parameter value from the XML page URL.

You can also follow the official Plex guide.

Configuration

Add a [plex] section to ~/.config/cliamp/config.toml:

[plex]
url   = "http://192.168.1.10:32400"
token = "xxxxxxxxxxxxxxxxxxxx"
libraries = ["Music", "Jazz"]
Key Description
url Plex Media Server base URL, including port (default 32400)
token X-Plex-Token for authentication
client_id Written by browser sign-in: the ID of this cliamp installation. Do not set it by hand
server_id Written by browser sign-in: the ID of the selected server. Do not set it by hand
libraries Optional comma-separated music library names to load. If omitted, cliamp loads all music libraries. Name matching is case-insensitive. Search results are limited to these libraries too.

When both client_id and server_id are set, cliamp finds the server through plex.tv and does not use url. Leave both out for a fixed manual URL. Do not copy them between installations; rerun browser sign-in on the other computer so Plex lists it as a separate authorized device.

Usage

After configuration, Plex appears in the cliamp provider list.

The provider shows audio playlists and the music library under two headers:

── Playlists ──
GOOD
All Music
drums

── Albums ──
Artist - Album Title (Year)

Select a playlist or album to load its tracks. Smart playlists are included. They resolve to current server content.

Start cliamp with Plex as the default provider:

cliamp --provider plex

Or set it in configuration:

provider = "plex"

How it works

cliamp calls the Plex HTTP API to list audio playlists (/playlists) and music library albums. When you select an entry, cliamp gets its track list from the playlist-items or album-children endpoint. Queues, playlists, favorites, history, resume state and IPC keep only a token-free path:

plex:track:<serverID>:<ratingKey>

When playback starts, cliamp resolves that path to the Plex part URL in memory and adds your token to the request. The serverID is the server's Plex machine identifier, so a saved path from another server is reported as an error instead of playing a different track. The token is not written into new track paths. Entries saved by an earlier cliamp version keep the full stream URL, token included, until you remove them. The part URLs serve files directly. Plex serves the original file without transcoding: cliamp asks for it with download=1, as Plexamp does, so Plex does not check the file against a client profile. Without it Plex refuses FLAC files it has analyzed with HTTP 500. cliamp handles playback through its HTTP streaming pipeline. cliamp can play MP3, FLAC, AAC, OGG, OPUS, WAV, and other supported source formats.

Troubleshooting

macOS: dial tcp ... connect: no route to host

If cliamp reports no route to host for a Plex server on the LAN, but curl works with the same URL, macOS likely denies Local Network access to the app. macOS blocks the connection before it sends a packet and reports a routing error.

Fix: Open System Settings > Privacy & Security > Local Network. Enable access for the terminal app, such as Terminal, iTerm2, or Ghostty. Then restart cliamp. If the terminal is not listed, turn an entry off and on. Or reset the permission database with tccutil reset All, then restart the terminal so macOS prompts again.

Known limitations

  • No scrobbling: cliamp does not report play counts to Plex.
  • No playlist write-back: cliamp cannot create or change Plex playlists.
  • Token is long-lived: Store it safely. It gives full access to the Plex account.
  • Album list is flat: Artist drill-down is not available. Search by scrolling or with cliamp search.