From 611613fd0a37da99ee593643c4ff297bf72bcb80 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 15 Jul 2016 12:55:04 +0200 Subject: [PATCH 1/2] Fix for token issue --- plexupdate.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 5e309e4..391f7a7 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -302,6 +302,8 @@ if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ] && [ "${PUBLIC}" == "no" ]; then cat /tmp/failcause >&2 exit 1 fi + TOKEN=$(/dev/null | grep -ioe '"label"[^}]*' | grep -i "\"distro\":\"${DISTRO}\"" | grep -i "\"build\":\"${BUILD}\"" | grep -m1 -ioe 'https://[^\"]*' ) +DOWNLOAD=$(wget --header "X-Plex-Token:"${TOKEN}"" --load-cookies /tmp/kaka --save-cookies /tmp/kaka --keep-session-cookies "${URL_DOWNLOAD}" -O - 2>/dev/null | grep -ioe '"label"[^}]*' | grep -i "\"distro\":\"${DISTRO}\"" | grep -i "\"build\":\"${BUILD}\"" | grep -m1 -ioe 'https://[^\"]*' ) + if [ "${CRON}" = "no" ]; then echo -e "OK" fi From 1decd0c58cd8c22e7e34d8188d3404a42a2f3d62 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 15 Jul 2016 13:06:57 +0200 Subject: [PATCH 2/2] Added minor comments for the changes --- plexupdate.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 391f7a7..7cfec22 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -302,6 +302,9 @@ if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ] && [ "${PUBLIC}" == "no" ]; then cat /tmp/failcause >&2 exit 1 fi + + # If the system got here, it means the login was successfull, so we set the TOKEN variable to the authToken from the response + # I use cut -c 14- to cut off the "authToken":" string from the grepped result, can probably be done in a different way TOKEN=$(/dev/null | grep -ioe '"label"[^}]*' | grep -i "\"distro\":\"${DISTRO}\"" | grep -i "\"build\":\"${BUILD}\"" | grep -m1 -ioe 'https://[^\"]*' ) if [ "${CRON}" = "no" ]; then