#!/bin/bash # Static config IFS='' MAX_RESULTS=200 CURL_OPTS=(--silent --connect-timeout 5 --max-time 30) # Functional environmental parameters if [ -z "${NUM_SERIES}" ]; then NUM_SERIES=25 fi if [ -z "${NUM_EPISODES}" ]; then NUM_EPISODES=4 fi # 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="https://${PMS_HOST}:${PMS_PORT}" fi if [ -z "${PMS_TOKEN}" ]; then echo "No PMS_TOKEN provided" 1>&2 fi CURL_OPTS+=(-H "X-Plex-Token: ${PMS_TOKEN}") # Select a configuration mode URL1="${PMS_URL}/library/sections/2/onDeck/" URL2_POST="children/allLeaves?unwatched=1" if echo "${1}" | grep -iq Movie; then URL1="${PMS_URL}/library/sections/1/recentlyAdded/" URL2_POST="" elif echo "${1}" | grep -iq YouTube; then URL1="${PMS_URL}/library/sections/16/onDeck/" fi # Find recent items ITEMS="`curl ${CURL_OPTS[@]} "${URL1}" | \ grep '