1.0.7 - Improve plex connection validation process...

#161
pull/187/head
RandomNinjaAtk 2 years ago committed by GitHub
parent bdf8f5b04c
commit 28824e2262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion=1.0.6 scriptVersion=1.0.7
if [ -z "$lidarr_artist_path" ]; then if [ -z "$lidarr_artist_path" ]; then
lidarr_artist_path="$1" lidarr_artist_path="$1"
notfidedBy=Extended_Script notfidedBy=Extended_Script
@ -26,17 +26,27 @@ if [ "$lidarr_eventtype" == "Test" ]; then
exit 0 exit 0
fi fi
# Validate connection plexConnectionError () {
plexVersion=$(curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . | jq -r '.MediaContainer."@version"')
if [ $plexVersion = null ]; then
log "ERROR :: Cannot communicate with Plex" log "ERROR :: Cannot communicate with Plex"
log "ERROR :: Please check your plexUrl and plexToken" log "ERROR :: Please check your plexUrl and plexToken"
log "ERROR :: Configured plexUrl \"$plexUrl\"" log "ERROR :: Configured plexUrl \"$plexUrl\""
log "ERROR :: Configured plexToken \"$plexToken\"" log "ERROR :: Configured plexToken \"$plexToken\""
log "ERROR :: Exiting..." log "ERROR :: Exiting..."
exit exit
else }
# Validate connection
if curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . &>/dev/null; then
plexVersion=$(curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . | jq -r '.MediaContainer."@version"')
if [ "$plexVersion" == "null" ]; then
# Error out if version is null, indicates bad token
plexConnectionError
else
log "Plex Connection Established, version: $plexVersion" log "Plex Connection Established, version: $plexVersion"
fi
else
# Error out if error in curl | xq . command output
plexConnectionError
fi fi
plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken")" plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken")"

Loading…
Cancel
Save