mirror of
https://github.com/MHA-Team/PTS-Team.git
synced 2026-02-03 14:03:25 +00:00
145 lines
6.0 KiB
Bash
145 lines
6.0 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Title: PGBlitz (Reference Title File)
|
|
# Author(s): Admin9705 - Deiteq
|
|
# URL: https://pgblitz.com - http://github.pgblitz.com
|
|
# GNU: General Public License v3.0
|
|
################################################################################
|
|
|
|
# FUNCTIONS START ##############################################################
|
|
|
|
# BAD INPUT
|
|
badinput() {
|
|
echo
|
|
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed </dev/tty
|
|
question1
|
|
}
|
|
|
|
badinput2() {
|
|
echo
|
|
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed </dev/tty
|
|
question2
|
|
}
|
|
|
|
question1() {
|
|
tee <<-EOF
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
🌎 PlexToken Generator
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
Generate new Token for Plex Patrol
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
EOF
|
|
read -p '↘️ PRESS [ENTER] ' typed </dev/tty
|
|
|
|
case $typed in
|
|
*)
|
|
read -p 'Enter the PLEX User Name | Press [ENTER]: ' user </dev/tty
|
|
read -p 'Enter the PLEX User Password | Press [ENTER]: ' pw </dev/tty
|
|
|
|
tee <<-EOF
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
🍖 NOM NOM - Saved Your Information!
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
EOF
|
|
sleep 3
|
|
question2
|
|
;;
|
|
esac
|
|
}
|
|
|
|
question2() {
|
|
tee <<-EOF
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
📂 User Name & Password Confirmation
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
User Name: $user
|
|
|
|
User Pass: $pw
|
|
|
|
⚠️ Information Correct?
|
|
|
|
[1] YES
|
|
[2] NO
|
|
|
|
[Z] - Exit Interface
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
EOF
|
|
read -p 'Make a Selection | Press [ENTER]: ' typed </dev/tty
|
|
|
|
if [ "$typed" == "1" ]; then
|
|
tee <<-EOF
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
🍖 NOM NOM - Got It! Generating the Plex Token!
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
NOTE: If the token is bad, this process will repeat again!
|
|
|
|
EOF
|
|
sleep 4
|
|
question3
|
|
elif [ "$typed" == "2" ]; then
|
|
question1
|
|
elif [[ "$typed" == "Z" || "$typed" == "z" ]]; then
|
|
exit
|
|
else badinput2; fi
|
|
}
|
|
|
|
question3() {
|
|
echo "$pw" >/var/plexguide/plexpatrol/plex.pw
|
|
echo "$user" >/var/plexguide/plexpatrol/plex.user
|
|
PLEX_LOGIN=$(cat /var/plexguide/plexpatrol/plex.user)
|
|
PLEX_PASSWORD=$(cat /var/plexguide/plexpatrol/plex.pw)
|
|
|
|
curl -qu "${PLEX_LOGIN}":"${PLEX_PASSWORD}" 'https://plex.tv/users/sign_in.xml' \
|
|
-X POST -H 'X-Plex-Device-Name: PlexMediaServer' \
|
|
-H 'X-Plex-Provides: server' \
|
|
-H 'X-Plex-Version: 0.9' \
|
|
-H 'X-Plex-Platform-Version: 0.9' \
|
|
-H 'X-Plex-Platform: xcid' \
|
|
-H 'X-Plex-Product: Plex Media Server'\
|
|
-H 'X-Plex-Device: Linux'\
|
|
-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)
|
|
if [ -z "$X_PLEX_TOKEN" ]; then
|
|
cat /tmp/plex_sign_in
|
|
rm -f /tmp/plex_sign_in
|
|
>&2 echo 'Failed to retrieve the X-Plex-Token.'
|
|
exit 1
|
|
fi
|
|
echo $X_PLEX_TOKEN >/var/plexguide/plexpatrol/plex.token
|
|
|
|
token=$(cat /var/plexguide/plexpatrol/plex.token)
|
|
if [ "$token" != "" ]; then
|
|
tee <<-EOF
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
✅️ PlexToken Generation Succeeded!
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
EOF
|
|
sleep 4
|
|
else
|
|
tee <<-EOF
|
|
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
⛔️ PlexToken Generation Failed!
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
NOTE: Process will repeat until you succeed or exit!
|
|
|
|
EOF
|
|
read -p 'Confirm Info | Press [ENTER] ' typed </dev/tty
|
|
question1
|
|
fi
|
|
}
|
|
|
|
# FUNCTIONS END ##############################################################
|
|
question1
|