test
This commit is contained in:
parent
1e87ba205c
commit
e8b5843731
@ -4,15 +4,27 @@ 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
|
||||||
|
|
||||||
|
if [[ "silent" == *"$2"* ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
echo "Getting Host Information"
|
echo "Getting Host Information"
|
||||||
|
fi
|
||||||
HostConfig
|
HostConfig
|
||||||
|
|
||||||
PLEX_PREFERENCES_XML="$AppSuppDir/Plex Media Server/Preferences.xml"
|
PLEX_PREFERENCES_XML="$AppSuppDir/Plex Media Server/Preferences.xml"
|
||||||
if [[ -f "$PLEX_PREFERENCES_XML" ]]; then
|
if [[ -f "$PLEX_PREFERENCES_XML" ]]; then
|
||||||
|
if [[ "silent" == *"$2"* ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
echo "Plex Preferences.xml found: $PLEX_PREFERENCES_XML"
|
echo "Plex Preferences.xml found: $PLEX_PREFERENCES_XML"
|
||||||
|
fi
|
||||||
# get token
|
# get token
|
||||||
LOCAL_PLEX_TOKEN=`cat "${PLEX_PREFERENCES_XML}" | sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1`
|
LOCAL_PLEX_TOKEN=`cat "${PLEX_PREFERENCES_XML}" | sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1`
|
||||||
|
if [[ "silent" == *"$2"* ]]; then
|
||||||
|
echo "$LOCAL_PLEX_TOKEN"
|
||||||
|
else
|
||||||
echo "Local Token found: $LOCAL_PLEX_TOKEN"
|
echo "Local Token found: $LOCAL_PLEX_TOKEN"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Plex Preferences.xml not found"
|
echo "Plex Preferences.xml not found"
|
||||||
exit
|
exit
|
||||||
@ -57,6 +69,6 @@ token_from_api() {
|
|||||||
|
|
||||||
case "$2" in
|
case "$2" in
|
||||||
api) token_from_api;;
|
api) token_from_api;;
|
||||||
""|xml) token_from_Pref_XML;;
|
""|xml|silent) token_from_Pref_XML;;
|
||||||
*) echo "'$2' is not a valid plex-tools token command";;
|
*) echo "'$2' is not a valid plex-tools token command";;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -12,6 +12,7 @@ urllib3.disable_warnings()
|
|||||||
|
|
||||||
SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))
|
SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
class PLEX_INFO():
|
class PLEX_INFO():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -32,7 +33,7 @@ class PLEX_INFO():
|
|||||||
@property
|
@property
|
||||||
def token(self):
|
def token(self):
|
||||||
token_script = pathlib.Path(SCRIPT_DIR).joinpath('plex-token.sh')
|
token_script = pathlib.Path(SCRIPT_DIR).joinpath('plex-token.sh')
|
||||||
token_proc = subprocess.Popen(['/bin/bash', token_script, "xml"], stdout=subprocess.PIPE)
|
token_proc = subprocess.Popen(['/bin/bash', token_script, "silent"], stdout=subprocess.PIPE)
|
||||||
token = token_proc.stdout.read().decode().strip("\n")
|
token = token_proc.stdout.read().decode().strip("\n")
|
||||||
token_proc.terminate()
|
token_proc.terminate()
|
||||||
token_proc.communicate()
|
token_proc.communicate()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user