test
This commit is contained in:
parent
bf932a649a
commit
9f86b4dd93
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
read_Pref_XML() {
|
token_from_Pref_XML() {
|
||||||
# ChuckPa already wrote a great function for getting host info
|
# ChuckPa already wrote a great function for getting host info
|
||||||
source ./HostConfig.sh
|
source ./HostConfig.sh
|
||||||
|
|
||||||
@ -19,30 +19,25 @@ read_Pref_XML() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
read_Pref_XML
|
token_from_api() {
|
||||||
|
if [ -z "$PLEX_LOGIN" ] || [ -z "$PLEX_PASSWORD" ]; then
|
||||||
|
|
||||||
exit
|
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$PLEX_LOGIN" ] || [ -z "$PLEX_PASSWORD" ]; then
|
|
||||||
PLEX_LOGIN=$1
|
PLEX_LOGIN=$1
|
||||||
PLEX_PASSWORD=$2
|
PLEX_PASSWORD=$2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [ -z "$PLEX_LOGIN" ]; do
|
while [ -z "$PLEX_LOGIN" ]; do
|
||||||
>&2 echo -n 'Your Plex login (e-mail or username): '
|
>&2 echo -n 'Your Plex login (e-mail or username): '
|
||||||
read PLEX_LOGIN
|
read PLEX_LOGIN
|
||||||
done
|
done
|
||||||
|
|
||||||
while [ -z "$PLEX_PASSWORD" ]; do
|
while [ -z "$PLEX_PASSWORD" ]; do
|
||||||
>&2 echo -n 'Your Plex password: '
|
>&2 echo -n 'Your Plex password: '
|
||||||
read PLEX_PASSWORD
|
read PLEX_PASSWORD
|
||||||
done
|
done
|
||||||
|
|
||||||
>&2 echo 'Retrieving a X-Plex-Token using Plex login/password...'
|
>&2 echo 'Retrieving a X-Plex-Token using Plex login/password...'
|
||||||
|
|
||||||
curl -qu "${PLEX_LOGIN}":"${PLEX_PASSWORD}" 'https://plex.tv/users/sign_in.xml' \
|
curl -qu "${PLEX_LOGIN}":"${PLEX_PASSWORD}" 'https://plex.tv/users/sign_in.xml' \
|
||||||
-X POST -H 'X-Plex-Device-Name: PlexMediaServer' \
|
-X POST -H 'X-Plex-Device-Name: PlexMediaServer' \
|
||||||
-H 'X-Plex-Provides: server' \
|
-H 'X-Plex-Provides: server' \
|
||||||
-H 'X-Plex-Version: 0.9' \
|
-H 'X-Plex-Version: 0.9' \
|
||||||
@ -51,15 +46,21 @@ curl -qu "${PLEX_LOGIN}":"${PLEX_PASSWORD}" 'https://plex.tv/users/sign_in.xml'
|
|||||||
-H 'X-Plex-Product: Plex Media Server'\
|
-H 'X-Plex-Product: Plex Media Server'\
|
||||||
-H 'X-Plex-Device: Linux'\
|
-H 'X-Plex-Device: Linux'\
|
||||||
-H 'X-Plex-Client-Identifier: XXXX' --compressed >/tmp/plex_sign_in
|
-H 'X-Plex-Client-Identifier: XXXX' --compressed >/tmp/plex_sign_in
|
||||||
X_PLEX_TOKEN=$(sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p' /tmp/plex_sign_in)
|
X_PLEX_TOKEN=$(sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p' /tmp/plex_sign_in)
|
||||||
if [ -z "$X_PLEX_TOKEN" ]; then
|
if [ -z "$X_PLEX_TOKEN" ]; then
|
||||||
cat /tmp/plex_sign_in
|
cat /tmp/plex_sign_in
|
||||||
rm -f /tmp/plex_sign_in
|
rm -f /tmp/plex_sign_in
|
||||||
>&2 echo 'Failed to retrieve the X-Plex-Token.'
|
>&2 echo 'Failed to retrieve the X-Plex-Token.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -f /tmp/plex_sign_in
|
rm -f /tmp/plex_sign_in
|
||||||
|
|
||||||
>&2 echo "Your X_PLEX_TOKEN:"
|
>&2 echo "Your X_PLEX_TOKEN:"
|
||||||
|
|
||||||
echo $X_PLEX_TOKEN
|
echo $X_PLEX_TOKEN
|
||||||
|
}
|
||||||
|
|
||||||
|
token_from_Pref_XML
|
||||||
|
token_from_api
|
||||||
|
|
||||||
|
exit
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user