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