mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-19 21:03:19 -07:00
Use local vars in functions and fix getRemoteSHA
This commit is contained in:
parent
861cf1fdf5
commit
2064fb2744
2 changed files with 9 additions and 6 deletions
|
@ -91,9 +91,9 @@ getPlexServerToken() {
|
|||
|
||||
# GPW
|
||||
getPlexWebToken() {
|
||||
FILE_POSTDATA=$(mktemp /tmp/plexupdate.postdata.XXXX)
|
||||
FILE_RAW=$(mktemp /tmp/plexupdate.raw.XXXX)
|
||||
FILE_FAILCAUSE=$(mktemp /tmp/plexupdate.failcause.XXXX)
|
||||
local FILE_POSTDATA=$(mktemp /tmp/plexupdate.postdata.XXXX)
|
||||
local FILE_RAW=$(mktemp /tmp/plexupdate.raw.XXXX)
|
||||
local FILE_FAILCAUSE=$(mktemp /tmp/plexupdate.failcause.XXXX)
|
||||
|
||||
# Fields we need to submit for login to work
|
||||
#
|
||||
|
@ -114,7 +114,7 @@ getPlexWebToken() {
|
|||
wget --header "X-Plex-Client-Identifier: 4a745ae7-1839-e44e-1e42-aebfa578c865" --header "X-Plex-Product: Plex SSO" "${URL_LOGIN}" --post-file="${FILE_POSTDATA}" -q -S -O "${FILE_FAILCAUSE}" 2>"${FILE_RAW}"
|
||||
|
||||
# Provide some details to the end user
|
||||
RESULTCODE=$(head -n1 "${FILE_RAW}" | grep -oe '[1-5][0-9][0-9]')
|
||||
local RESULTCODE=$(head -n1 "${FILE_RAW}" | grep -oe '[1-5][0-9][0-9]')
|
||||
if [ $RESULTCODE -eq 401 ]; then
|
||||
error "Username and/or password incorrect"
|
||||
elif [ $RESULTCODE -ne 201 ]; then
|
||||
|
@ -166,7 +166,10 @@ trimQuotes() {
|
|||
}
|
||||
|
||||
getRemoteSHA() {
|
||||
(wget -q "$1" -O - 2>/dev/null || return 1) | sha1sum | cut -f1 -d" "
|
||||
# these two lines can't be combined. `local RESULT=` will gobble up the return
|
||||
local RESULT
|
||||
RESULT=$(wget -q "$1" -O - 2>/dev/null) || return 1
|
||||
sha1sum <<< "$RESULT" | cut -f1 -d" "
|
||||
}
|
||||
|
||||
getLocalSHA() {
|
||||
|
|
|
@ -339,7 +339,7 @@ if [ "${PUBLIC}" = "no" -a -z "$TOKEN" ]; then
|
|||
[ -f "$TO_SOURCE" ] && source $TO_SOURCE
|
||||
if ! getPlexToken; then
|
||||
error "Unable to get Plex token, falling back to public release"
|
||||
PUBLiC="yes"
|
||||
PUBLIC="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue