#!/bin/sh
# Checks if jellyfin server is currently serving media to any user.
# Mark Blakeney, Nov 2020.

MYTOKEN="$1"
PORT=${2:-8096}

if curl -m 10 -fsS \
    -H "Authorization: MediaBrowser Token=\"$MYTOKEN\"" \
    "http://localhost:$PORT/Sessions" |
    grep -qw NowPlayingItem; then
    exit 254
fi

exit 0
