See if someone is playing a file from terminal

I was looking for this too, and this post along with https://forums.plex.tv/t/now-playing-from-bash/167597 helped me figure this out.

My complete solution is a bash script. It relies on curl and xmllint

Created a script named get-active-streams with the following content:

#! /bin/sh

PLEX_HOST=${PLEX_HOST:-localhost}

PLEX_TOKEN=$(curl -H "Content-Length: 0" -H "X-Plex-Client-Identifier: my-app" -u $PLEX_USERNAME:$PLEX_PASSWORD -X POST https://my.plexapp.com/users/sign_in.xml --silent | xmllint --xpath "/user/authentication-token/text()" -)
curl --silent http://$PLEX_HOST:32400/status/sessions -H "X-Plex-Token: $PLEX_TOKEN" | xmllint --xpath 'string(//MediaContainer/@size)' -

don’t forget to chmod the file with u+x: chmod ./get-active-streams

and the you can run it like this:

PLEX_USERNAME="<username>" PLEX_PASSWORD="<password>" ./get-active-streams

In case you run this remotely you’ll need to also update the PLEX_HOST variable:

PLEX_HOST="<plex hostname/ip>" PLEX_USERNAME="<username>" PLEX_PASSWORD="<password>" ./get-active-streams

Hope this helps out to anyone trying to figure this out.