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

Loading…
Cancel
Save