v1.0.4 - Support script execution from Extended script

pull/16/head
RandomNinjaAtk 2 years ago committed by GitHub
parent 98d7be44b9
commit f445695de1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,12 @@
#!/usr/bin/env bash
version=1.0.4
if [ -z "$lidarr_artist_path" ]; then
lidarr_artist_path="$1"
notfidedBy=Extended_Script
else
notfidedBy=Lidarr
fi
lidarrRootFolderPath="$(dirname "$lidarr_artist_path")"
version=1.0.3
# auto-clean up log file to reduce space usage
if [ -f "/config/logs/PlexNotify.txt" ]; then
@ -16,21 +22,21 @@ log () {
}
if [ "$lidarr_eventtype" == "Test" ]; then
log "Tested Successfully"
log "$notfidedBy :: 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 "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..."
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..."
exit
else
log "Plex Connection Established, version: $plexVersion"
log "$notfidedBy :: Plex Connection Established, version: $plexVersion"
fi
plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken")"
@ -41,16 +47,16 @@ 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 "ERROR: No Plex Music Type libraries found"
log "ERROR: Exiting..."
log "$notfidedBy :: ERROR: No Plex Music Type libraries found"
log "$notfidedBy :: ERROR: Exiting..."
exit 1
fi
if echo "$plexLibraryData" | grep "\"@path\": \"$lidarrRootFolderPath" | read; then
sleep 0.01
else
log "ERROR: No Plex Library found containing path \"$lidarrRootFolderPath\""
log "ERROR: Add \"$lidarrRootFolderPath\" as a folder to a Plex Music Library"
log "$notfidedBy :: ERROR: No Plex Library found containing path \"$lidarrRootFolderPath\""
log "$notfidedBy :: ERROR: Add \"$lidarrRootFolderPath\" as a folder to a Plex Music Library"
exit 1
fi
@ -59,7 +65,7 @@ for key in ${!plexKeys[@]}; do
if echo "$plexLibraryData" | 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 "Plex Scan notification sent! ($lidarr_artist_path)"
log "$notfidedBy :: Plex Scan notification sent! ($lidarr_artist_path)"
fi
done

Loading…
Cancel
Save