diff --git a/plex-token.sh b/plex-token.sh index b2c6782..a81d310 100644 --- a/plex-token.sh +++ b/plex-token.sh @@ -1,21 +1,26 @@ #!/bin/bash -# ChuckPa already wrote a great function for getting host info -source ./HostConfig.sh +read_Pref_XML() { + # ChuckPa already wrote a great function for getting host info + source ./HostConfig.sh -echo "Getting Host Information" -HostConfig + echo "Getting Host Information" + HostConfig + + PLEX_PREFERENCES_XML="$AppSuppDir/Plex Media Server/Preferences.xml" + if [[ -f "$PLEX_PREFERENCES_XML" ]]; then + echo "Plex Preferences.xml found: $PLEX_PREFERENCES_XML" + # get token + LOCAL_PLEX_TOKEN=`cat "${PLEX_PREFERENCES_XML}" | sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1` + echo "Local Token found: $LOCAL_PLEX_TOKEN" + else + echo "Plex Preferences.xml not found" + exit + fi +} + +read_Pref_XML -PLEX_PREFERENCES_XML="$AppSuppDir/Plex Media Server/Preferences.xml" -if [[ -f "$PLEX_PREFERENCES_XML" ]]; then - echo "Plex Preferences.xml found: $PLEX_PREFERENCES_XML" - # get token - LOCAL_PLEX_TOKEN=`cat "${PLEX_PREFERENCES_XML}" | sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1` - echo "Local Token found: $LOCAL_PLEX_TOKEN" -else - echo "Plex Preferences.xml not found" - exit -fi exit