|
|
@ -1,11 +1,8 @@
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
PLEXURL="http://$plexIp:32400"
|
|
|
|
|
|
|
|
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"
|
|
|
|
lidarrRootFolderPath="$(dirname "$Lidarr_Artist_Path")"
|
|
|
|
lidarrRootFolderPath="$(dirname "$Lidarr_Artist_Path")"
|
|
|
|
plexfolder="$Lidarr_Artist_Path"
|
|
|
|
exec &>> "/config/logs/PlexNotify.log"
|
|
|
|
exec &>> "/config/scripts/PlexNotify.log"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log () {
|
|
|
|
log () {
|
|
|
|
m_time=`date "+%F %T"`
|
|
|
|
m_time=`date "+%F %T"`
|
|
|
@ -17,21 +14,21 @@ if [ "$Lidarr_EventType" == "Test" ]; then
|
|
|
|
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 "$lidarrRootFolderPath" | read; then
|
|
|
|
if echo "$plexLibraries" | grep "$lidarrRootFolderPath" | read; then
|
|
|
|
plexlibrarykey="$(echo "$plexlibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@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 \"$lidarrRootFolderPath\""
|
|
|
|
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 \"/$lidarrRootFolderPath\""
|
|
|
|
log "ERROR: No Plex Library found containing path \"/$lidarrRootFolderPath\""
|
|
|
|
log "ERROR: Add \"/$lidarrRootFolderPath\" as a folder to a Plex Music Library"
|
|
|
|
log "ERROR: Add \"/$lidarrRootFolderPath\" as a folder to a Plex TV Library"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
plexfolderencoded="$(jq -R -r @uri <<<"${plexfolder}")"
|
|
|
|
plexFolderEncoded="$(jq -R -r @uri <<<"$Lidarr_Artist_Path")"
|
|
|
|
curl -s "$PLEXURL/library/sections/$plexlibrarykey/refresh?path=$plexfolderencoded&X-Plex-Token=$PLEXTOKEN"
|
|
|
|
curl -s "$plexUrl/library/sections/$plexlibrarykey/refresh?path=$plexFolderEncoded&X-Plex-Token=$plexToken"
|
|
|
|
log "Plex Scan notification sent! ($plexfolder)"
|
|
|
|
log "Plex Scan notification sent! ($plexfolder)"
|
|
|
|
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
|