diff --git a/root/scripts/PlexNotify.bash b/root/scripts/PlexNotify.bash index 7bd77ba..e64ce30 100644 --- a/root/scripts/PlexNotify.bash +++ b/root/scripts/PlexNotify.bash @@ -1,13 +1,11 @@ #!/usr/bin/env bash -lidarrApiKey="$(grep "" /config/config.xml | sed "s/\ //;s/<\/ApiKey>//")" -lidarrUrl="http://127.0.0.1:8686" lidarrRootFolderPath="$(dirname "$lidarr_artist_path")" exec &>> "/config/logs/PlexNotify.txt" chmod 777 "/config/logs/PlexNotify.txt" log () { m_time=`date "+%F %T"` - echo $m_time" "$1 + echo $m_time" :: "$1 } if [ "$lidarr_eventtype" == "Test" ]; then @@ -15,6 +13,11 @@ if [ "$lidarr_eventtype" == "Test" ]; then exit 0 fi +if [ -z "$plexToken" ]; then + log "ERROR :: Plex Token Not configured" + exit +fi + plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken" | xq .)" if echo "$plexLibraries" | grep "$lidarrRootFolderPath" | read; then if echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" &>/dev/null; then