mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-20 21:33:16 -07:00
Merge branch 'master' into stored-token-auth
This commit is contained in:
commit
0e28f1bbe7
1 changed files with 66 additions and 52 deletions
|
@ -200,6 +200,16 @@ keypair() {
|
||||||
echo "${key}=${val}"
|
echo "${key}=${val}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlexServerToken() {
|
||||||
|
[ -f /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver
|
||||||
|
local pmsApplicationSupportDir="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-${HOME}/Library/Application Support}"
|
||||||
|
local prefFile="${pmsApplicationSupportDir}/Plex Media Server/Preferences.xml"
|
||||||
|
|
||||||
|
if [ -f "${prefFile}" ]; then
|
||||||
|
sed -n 's/.*PlexOnlineToken="\([[:alnum:]]*\).*".*/\1/p' "${prefFile}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Setup an exit handler so we cleanup
|
# Setup an exit handler so we cleanup
|
||||||
cleanup() {
|
cleanup() {
|
||||||
for F in "${FILE_RAW}" "${FILE_FAILCAUSE}" "${FILE_POSTDATA}" "${FILE_KAKA}" "${FILE_SHA}" "${FILE_LOCAL}" "${FILE_REMOTE}" "${FILE_WGETLOG}"; do
|
for F in "${FILE_RAW}" "${FILE_FAILCAUSE}" "${FILE_POSTDATA}" "${FILE_KAKA}" "${FILE_SHA}" "${FILE_LOCAL}" "${FILE_REMOTE}" "${FILE_WGETLOG}"; do
|
||||||
|
@ -371,7 +381,6 @@ if [ "${AUTOUPDATE}" = "yes" ]; then
|
||||||
popd &>/dev/null
|
popd &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "${AUTOINSTALL}" = "yes" -o "${AUTOSTART}" = "yes" ] && [ ${EUID} -ne 0 ]; then
|
if [ "${AUTOINSTALL}" = "yes" -o "${AUTOSTART}" = "yes" ] && [ ${EUID} -ne 0 ]; then
|
||||||
error "You need to be root to use AUTOINSTALL/AUTOSTART option."
|
error "You need to be root to use AUTOINSTALL/AUTOSTART option."
|
||||||
fi
|
fi
|
||||||
|
@ -435,14 +444,6 @@ if [ "${CHECKUPDATE}" = "yes" -a "${AUTOUPDATE}" = "no" ]; then
|
||||||
rm "${FILE_REMOTE}" 2>/dev/null >/dev/null
|
rm "${FILE_REMOTE}" 2>/dev/null >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
getPlexServerToken() {
|
|
||||||
[ -f /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver
|
|
||||||
local pmsApplicationSupportDir="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-${HOME}/Library/Application Support}"
|
|
||||||
local prefFile="${pmsApplicationSupportDir}/Plex Media Server/Preferences.xml"
|
|
||||||
|
|
||||||
sed -n 's/.*PlexOnlineToken="\([[:alnum:]]*\).*".*/\1/p' "$prefFile"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fields we need to submit for login to work
|
# Fields we need to submit for login to work
|
||||||
#
|
#
|
||||||
# Field Value
|
# Field Value
|
||||||
|
@ -457,18 +458,24 @@ if [ "${PUBLIC}" = "no" ]; then
|
||||||
# Clean old session
|
# Clean old session
|
||||||
rm "${FILE_KAKA}" 2>/dev/null
|
rm "${FILE_KAKA}" 2>/dev/null
|
||||||
|
|
||||||
|
# Try to obtain token from Plex Server Installation
|
||||||
|
TOKEN=
|
||||||
if [ -z "${EMAIL}" -o -z "${PASS}" ]; then
|
if [ -z "${EMAIL}" -o -z "${PASS}" ]; then
|
||||||
TOKEN=$(getPlexServerToken)
|
TOKEN=$(getPlexServerToken)
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${TOKEN}" ]; then
|
if [ -z "${TOKEN}" ]; then
|
||||||
|
# If no token, go through regular process
|
||||||
|
if [ -z "${EMAIL}" -o -z "${PASS}" ]; then
|
||||||
error "Need username & password to download PlexPass version. Otherwise run with -p to download public version."
|
error "Need username & password to download PlexPass version. Otherwise run with -p to download public version."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
elif [ ! -z "${EMAIL}" ] && [[ "$EMAIL" == *"@"* ]] && [[ "$EMAIL" != *"@"*"."* ]]; then
|
elif [ ! -z "${EMAIL}" ] && [[ "$EMAIL" == *"@"* ]] && [[ "$EMAIL" != *"@"*"."* ]]; then
|
||||||
error "EMAIL field must contain a valid email address"
|
error "EMAIL field must contain a valid email address"
|
||||||
exit 1
|
exit 1
|
||||||
|
elif [ ! -z "${EMAIL}" -a ! -z "${PASS}" -a "${PUBLIC}" = "yes" ]; then
|
||||||
info "Authenticating with plex.tv"
|
warn "You have defined email and password but PUBLIC is set to yes, this will not download the PlexPass version"
|
||||||
|
fi
|
||||||
|
info "Authenticating with plex.tv using email and password"
|
||||||
|
|
||||||
# Build post data
|
# Build post data
|
||||||
echo -ne >"${FILE_POSTDATA}" "$(keypair "user[login]" "${EMAIL}" )"
|
echo -ne >"${FILE_POSTDATA}" "$(keypair "user[login]" "${EMAIL}" )"
|
||||||
|
@ -500,6 +507,9 @@ if [ "${PUBLIC}" = "no" ]; then
|
||||||
|
|
||||||
# Remove this, since it contains more information than we should leave hanging around
|
# Remove this, since it contains more information than we should leave hanging around
|
||||||
rm "${FILE_FAILCAUSE}"
|
rm "${FILE_FAILCAUSE}"
|
||||||
|
else
|
||||||
|
info "Using Plex Server credentials to authenticate"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ "$PUBLIC" != "no" ]; then
|
elif [ "$PUBLIC" != "no" ]; then
|
||||||
|
@ -540,6 +550,10 @@ CHECKSUM=$(echo ${RELEASE} | grep -ioe '\"checksum\"\:\"[^\"]*' | sed 's/\"check
|
||||||
|
|
||||||
if [ -z "${DOWNLOAD}" ]; then
|
if [ -z "${DOWNLOAD}" ]; then
|
||||||
error "Unable to retrieve the URL needed for download (Query DISTRO: $DISTRO, BUILD: $BUILD)"
|
error "Unable to retrieve the URL needed for download (Query DISTRO: $DISTRO, BUILD: $BUILD)"
|
||||||
|
if [ ! -z "${RELEASE}" ]; then
|
||||||
|
error "It seems release info is missing a link"
|
||||||
|
error "Please try https://plex.tv and confirm it works there before reporting this issue"
|
||||||
|
fi
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue