1.1 - Logging Improvements, only scan the correct library

Previously, the script would scan all libraries if they had almost identical folder names, example:

/path/folder and /path/folder-02

Both folders would be notified to be scanned, when only the first folder was valid. This fixes that...
This commit is contained in:
RandomNinjaAtk 2023-07-20 16:17:51 +00:00 committed by GitHub
parent 014543eb57
commit e1962a9896
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,14 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.0.8" scriptVersion="1.1"
scriptName="PlexNotify" scriptName="PlexNotify"
#### Import Settings #### Import Settings
source /config/extended.conf source /config/extended.conf
#### Import Functions
log () { source /config/extended/functions
m_time=`date "+%F %T"` #### Create Log File
echo $m_time" :: $scriptName :: $scriptVersion :: "$1 logfileSetup
}
if [ -z "$lidarr_artist_path" ]; then if [ -z "$lidarr_artist_path" ]; then
lidarr_artist_path="$1" lidarr_artist_path="$1"
@ -18,15 +17,6 @@ else
fi fi
lidarrRootFolderPath="$(dirname "$lidarr_artist_path")" lidarrRootFolderPath="$(dirname "$lidarr_artist_path")"
# auto-clean up log file to reduce space usage
if [ -f "/config/logs/PlexNotify.txt" ]; then
find /config/logs -type f -name "PlexNotify.txt" -size +1024k -delete
fi
exec &> >(tee -a "/config/logs/PlexNotify.txt")
chmod 666 "/config/logs/PlexNotify.txt"
if [ "$lidarr_eventtype" == "Test" ]; then if [ "$lidarr_eventtype" == "Test" ]; then
log "Tested Successfully" log "Tested Successfully"
@ -80,7 +70,7 @@ fi
for key in ${!plexKeys[@]}; do for key in ${!plexKeys[@]}; do
plexKey="${plexKeys[$key]}" plexKey="${plexKeys[$key]}"
plexKeyLibraryData=$(echo "$plexLibraryData" | jq -r "select(.\"@key\"==\"$plexKey\")") plexKeyLibraryData=$(echo "$plexLibraryData" | jq -r "select(.\"@key\"==\"$plexKey\")")
if echo "$plexKeyLibraryData" | grep "\"@path\": \"$lidarrRootFolderPath" | read; then 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 "Plex Scan notification sent! ($plexKey :: $lidarr_artist_path)" log "Plex Scan notification sent! ($plexKey :: $lidarr_artist_path)"