Ver código fonte

Simplify and parameterize the unwatched check; we already do a general responses check and I am willing to conflate the two failure modes in the rare case where the connectivity check passes once and then fails.
Increase the number of retries and sleep length in the unwatched check.

Zachary Kotlarek 13 anos atrás
pai
commit
6c63e460ca
1 arquivos alterados com 8 adições e 10 exclusões
  1. 8 10
      pms/PMSCheck.sh

+ 8 - 10
pms/PMSCheck.sh

@@ -4,9 +4,10 @@
 CURL_TIMEOUT=5
 RESTART_DELAY=120
 PMS_URL="http://localhost:32400/"
-UNWATCHED_URL="${PMS_URL}library/sections/2/unwatched"
+UNWATCHED_SECTION="2"
 UNWATCHED_TIMEOUT=$(( $CURL_TIMEOUT * 2 ))
-UNWATCHED_RETRIES=3
+UNWATCHED_SLEEP=$UNWATCHED_TIMEOUT
+UNWATCHED_RETRIES=5
 MIN_UNWATCHED_COUNT=10
 ADMIN_EMAIL="zach@kotlarek.com"
 
@@ -43,20 +44,17 @@ while [ $LOOP -ne 0 ]; do
 
 	# Ask Plex for a list of unwatched TV series
 	if [ -z "${FAILED}" ]; then
+		UNWATCHED_URL="${PMS_URL}library/sections/${UNWATCHED_SECTION}/unwatched"
 		TRY=1
 		FAILED="Too few unwatched series"
 		while [ $TRY -le $UNWATCHED_RETRIES ] && [ -n "${FAILED}" ]; do
 			TRY=$(( $TRY + 1 ))
 			PAGE="`curl --silent --max-time "${UNWATCHED_TIMEOUT}" "${UNWATCHED_URL}"`"
-			if [ -z "${PAGE}" ]; then
-				FAILED="HTTP timeout"
+			COUNT="`echo "${PAGE}" | grep '</Directory>' | wc -l`"
+			if [ $COUNT -ge $MIN_UNWATCHED_COUNT ]; then
+				FAILED=""
 			else
-				COUNT="`echo "${PAGE}" | grep '</Directory>' | wc -l`"
-				if [ $COUNT -ge $MIN_UNWATCHED_COUNT ]; then
-					FAILED=""
-				else
-					sleep 2
-				fi
+				sleep $UNWATCHED_SLEEP
 			fi
 		done
 	fi