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