From 581f1272fc50b143d10912bdbdc68300b8c88421 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Tue, 14 Jun 2022 18:41:34 -0400 Subject: [PATCH] Update PlexNotify.bash --- root/scripts/PlexNotify.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/root/scripts/PlexNotify.bash b/root/scripts/PlexNotify.bash index 668c30c..bce68c6 100644 --- a/root/scripts/PlexNotify.bash +++ b/root/scripts/PlexNotify.bash @@ -17,7 +17,11 @@ fi plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken" | xq .)" if echo "$plexLibraries" | grep "$lidarrRootFolderPath" | read; then - plexlibrarykey="$(echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" | head -n 1)" + if echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" | head -n 1 &>/dev/null; then + plexlibrarykey="$(echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" | head -n 1)" + else + plexlibrarykey="$(echo "$plexLibraries" | jq -r ".MediaContainer.Directory | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" | head -n 1)" + fi if [ -z "$plexlibrarykey" ]; then log "ERROR: No Plex Library key found for \"$lidarrRootFolderPath\"" exit 1