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:
parent
014543eb57
commit
e1962a9896
1 changed files with 6 additions and 16 deletions
|
@ -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)"
|
||||
|
|
Loading…
Reference in a new issue