1.0.6 - Only update library that has the folder

Previously, all libraries were notified to update, now only the correct one will...
pull/139/head
RandomNinjaAtk 2 years ago committed by GitHub
parent d8bd8e5d6f
commit 03366fff73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash
scriptVersion=1.0.5
scriptVersion=1.0.6
if [ -z "$lidarr_artist_path" ]; then
lidarr_artist_path="$1"
notfidedBy=Extended_Script
@ -22,21 +22,21 @@ log () {
}
if [ "$lidarr_eventtype" == "Test" ]; then
log "$notfidedBy :: Tested Successfully"
log "Tested Successfully"
exit 0
fi
# Validate connection
plexVersion=$(curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . | jq -r '.MediaContainer."@version"')
if [ $plexVersion = null ]; then
log "$notfidedBy :: ERROR :: Cannot communicate with Plex"
log "$notfidedBy :: ERROR :: Please check your plexUrl and plexToken"
log "$notfidedBy :: ERROR :: Configured plexUrl \"$plexUrl\""
log "$notfidedBy :: ERROR :: Configured plexToken \"$plexToken\""
log "$notfidedBy :: ERROR :: Exiting..."
log "ERROR :: Cannot communicate with Plex"
log "ERROR :: Please check your plexUrl and plexToken"
log "ERROR :: Configured plexUrl \"$plexUrl\""
log "ERROR :: Configured plexToken \"$plexToken\""
log "ERROR :: Exiting..."
exit
else
log "$notfidedBy :: Plex Connection Established, version: $plexVersion"
log "Plex Connection Established, version: $plexVersion"
fi
plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken")"
@ -47,26 +47,27 @@ elif echo "$plexLibraries" | xq ".MediaContainer.Directory[] | select(.\"@type\"
plexKeys=($(echo "$plexLibraries" | xq ".MediaContainer.Directory[] | select(.\"@type\"==\"artist\")" | jq -r '."@key"'))
plexLibraryData=$(echo "$plexLibraries" | xq ".MediaContainer.Directory[] | select(.\"@type\"==\"artist\")")
else
log "$notfidedBy :: ERROR: No Plex Music Type libraries found"
log "$notfidedBy :: ERROR: Exiting..."
log "ERROR: No Plex Music Type libraries found"
log "ERROR: Exiting..."
exit 1
fi
if echo "$plexLibraryData" | grep "\"@path\": \"$lidarrRootFolderPath" | read; then
sleep 0.01
else
log "$notfidedBy :: ERROR: No Plex Library found containing path \"$lidarrRootFolderPath\""
log "$notfidedBy :: ERROR: Add \"$lidarrRootFolderPath\" as a folder to a Plex Music 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
for key in ${!plexKeys[@]}; do
plexKey="${plexKeys[$key]}"
if echo "$plexLibraryData" | grep "\"@path\": \"$lidarrRootFolderPath" | read; then
plexKeyLibraryData=$(echo "$plexLibraryData" | jq -r "select(.\"@key\"==\"$plexKey\")")
if echo "$plexKeyLibraryData" | grep "\"@path\": \"$lidarrRootFolderPath" | read; then
plexFolderEncoded="$(jq -R -r @uri <<<"$lidarr_artist_path")"
curl -s "$plexUrl/library/sections/$plexKey/refresh?path=$plexFolderEncoded&X-Plex-Token=$plexToken"
log "$notfidedBy :: Plex Scan notification sent! ($lidarr_artist_path)"
log "Plex Scan notification sent! ($plexKey :: $lidarr_artist_path)"
fi
done
exit 0
exit

Loading…
Cancel
Save