Graceful exit when plexToken not configured

pull/6/head
RandomNinjaAtk 3 years ago committed by GitHub
parent 338fe8d56f
commit b742a0d161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,13 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
lidarrApiKey="$(grep "<ApiKey>" /config/config.xml | sed "s/\ <ApiKey>//;s/<\/ApiKey>//")"
lidarrUrl="http://127.0.0.1:8686"
lidarrRootFolderPath="$(dirname "$lidarr_artist_path")" lidarrRootFolderPath="$(dirname "$lidarr_artist_path")"
exec &>> "/config/logs/PlexNotify.txt" exec &>> "/config/logs/PlexNotify.txt"
chmod 777 "/config/logs/PlexNotify.txt" chmod 777 "/config/logs/PlexNotify.txt"
log () { log () {
m_time=`date "+%F %T"` m_time=`date "+%F %T"`
echo $m_time" "$1 echo $m_time" :: "$1
} }
if [ "$lidarr_eventtype" == "Test" ]; then if [ "$lidarr_eventtype" == "Test" ]; then
@ -15,6 +13,11 @@ if [ "$lidarr_eventtype" == "Test" ]; then
exit 0 exit 0
fi fi
if [ -z "$plexToken" ]; then
log "ERROR :: Plex Token Not configured"
exit
fi
plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken" | xq .)" plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken" | xq .)"
if echo "$plexLibraries" | grep "$lidarrRootFolderPath" | read; then if echo "$plexLibraries" | grep "$lidarrRootFolderPath" | read; then
if echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" &>/dev/null; then if echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | select(.Location.\"@path\"==\"$lidarrRootFolderPath\") | .\"@key\"" &>/dev/null; then

Loading…
Cancel
Save