#!/bin/bash CURL_OPTS=(--silent --connect-timeout 5 --max-time 30) NUM_SERIES=18 NUM_EPISODES=4 MAX_RESULTS=100 # Construct URL components from the environment if [ -z "${PMS_URL}" ]; then if [ -z "${PMS_HOST}" ]; then PMS_HOST="localhost" fi if [ -z "${PMS_PORT}" ]; then PMS_PORT=32400 fi PMS_URL="http://${PMS_HOST}:${PMS_PORT}" fi PMS_AUTH="" if [ -n "${PMS_TOKEN}" ]; then PMS_AUTH="X-Plex-Token=${PMS_TOKEN}" fi # Select a configuration mode URL1="${PMS_URL}/library/sections/2/onDeck/?${PMS_AUTH}" URL2_POST="children/allLeaves?unwatched=1" if echo "${1}" | grep -iq Movie; then URL1="${PMS_URL}/library/sections/1/recentlyAdded/?${PMS_AUTH}" URL2_POST="" elif echo "${1}" | grep -iq YouTube; then URL1="${PMS_URL}/library/sections/16/onDeck/?${PMS_AUTH}" NUM_EPISODES=$(( $NUM_EPISODES * 3 )) NUM_SERIES=$(( $NUM_SERIES * 2 )) fi # Find recent items ITEMS="`curl ${CURL_OPTS[@]} "${URL1}" | \ grep '