Update PlexNotify.bash

pull/6/head
RandomNinjaAtk 2 years ago committed by GitHub
parent c1586bc9c6
commit 51fdc677e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,13 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PLEXURL="http://Your_Plex_IP:32400" PLEXURL="http://plexIp:32400"
PLEXTOKEN="Your_Plex_Token" PLEXTOKEN="plexToken"
lidarrApiKey="$(grep "<ApiKey>" /config/config.xml | sed "s/\ <ApiKey>//;s/<\/ApiKey>//")" lidarrApiKey="$(grep "<ApiKey>" /config/config.xml | sed "s/\ <ApiKey>//;s/<\/ApiKey>//")"
lidarrUrl="http://127.0.0.1:8686" lidarrUrl="http://127.0.0.1:8686"
seriesId=$sonarr_series_id lidarrRootFolderPath="$(dirname "$Lidarr_Artist_Path")"
seriesData=$(curl -s "http://localhost:8989/api/v3/series/$seriesId?apikey=$sonarrApiKey") plexfolder="$Lidarr_Artist_Path"
seriesPath="$(echo "$seriesData" | jq -r ".path")"
seriesRootFolderPath="$(echo "$seriesData" | jq -r ".rootFolderPath")"
plexfolder="$seriesPath"
exec &>> "/config/scripts/PlexNotify.log" exec &>> "/config/scripts/PlexNotify.log"
log () { log () {
@ -15,21 +12,21 @@ log () {
echo $m_time" "$1 echo $m_time" "$1
} }
if [ "$sonarr_eventtype" == "Test" ]; then if [ "$Lidarr_EventType" == "Test" ]; then
log "Tested" log "Tested"
exit 0 exit 0
fi fi
plexlibraries="$(curl -s "$PLEXURL/library/sections?X-Plex-Token=$PLEXTOKEN" | xq .)" plexlibraries="$(curl -s "$PLEXURL/library/sections?X-Plex-Token=$PLEXTOKEN" | xq .)"
if echo "$plexlibraries" | grep "$seriesRootFolderPath" | read; then if echo "$plexlibraries" | grep "$lidarrRootFolderPath" | read; then
plexlibrarykey="$(echo "$plexlibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$seriesRootFolderPath\") | .\"@key\"" | head -n 1)" plexlibrarykey="$(echo "$plexlibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" | head -n 1)"
if [ -z "$plexlibrarykey" ]; then if [ -z "$plexlibrarykey" ]; then
log "ERROR: No Plex Library key found for \"$seriesRootFolderPath\"" log "ERROR: No Plex Library key found for \"$lidarrRootFolderPath\""
exit 1 exit 1
fi fi
else else
log "ERROR: No Plex Library found containing path \"/$seriesRootFolderPath\"" log "ERROR: No Plex Library found containing path \"/$lidarrRootFolderPath\""
log "ERROR: Add \"/$seriesRootFolderPath\" as a folder to a Plex TV Library" log "ERROR: Add \"/$lidarrRootFolderPath\" as a folder to a Plex Music Library"
exit 1 exit 1
fi fi

Loading…
Cancel
Save