From e1962a9896badce9c043b275ccdb5916bd3bc0bd Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Thu, 20 Jul 2023 16:17:51 +0000 Subject: [PATCH] 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... --- lidarr/PlexNotify.bash | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lidarr/PlexNotify.bash b/lidarr/PlexNotify.bash index 72f59c1..7b47028 100644 --- a/lidarr/PlexNotify.bash +++ b/lidarr/PlexNotify.bash @@ -1,14 +1,13 @@ #!/usr/bin/env bash -scriptVersion="1.0.8" +scriptVersion="1.1" scriptName="PlexNotify" #### Import Settings source /config/extended.conf - -log () { - m_time=`date "+%F %T"` - echo $m_time" :: $scriptName :: $scriptVersion :: "$1 -} +#### Import Functions +source /config/extended/functions +#### Create Log File +logfileSetup if [ -z "$lidarr_artist_path" ]; then lidarr_artist_path="$1" @@ -18,15 +17,6 @@ else fi 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 log "Tested Successfully" @@ -80,7 +70,7 @@ fi for key in ${!plexKeys[@]}; do plexKey="${plexKeys[$key]}" 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")" curl -s "$plexUrl/library/sections/$plexKey/refresh?path=$plexFolderEncoded&X-Plex-Token=$plexToken" log "Plex Scan notification sent! ($plexKey :: $lidarr_artist_path)"