introduce webhook to be posted to when fatal error happens

pull/60/head
RandomUser345 2 years ago
parent b675f11ac0
commit 382c68e395

@ -117,6 +117,7 @@ Container images are configured using parameters passed at runtime (such as thos
| `-e plexUrl=http://x.x.x.x:32400` | ONLY used if PlexNotify.bash is used...|
| `-e plexToken=` | ONLY used if PlexNotify.bash is used... |
| `-e youtubeSubtitleLanguage=en` | Desired Language Code :: For guidence, please see yt-dlp documentation.
| `-e webHook=https://myhook.mydomain.com` | POST's to this URL on error events which prevent the script from working. Content is JSON `{"event":"eventtype", "message":"eventmessage"}`
## Usage

@ -1,5 +1,5 @@
#!/usr/bin/env bash
scriptVersion="1.0.240"
scriptVersion="1.0.241"
if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
if [ "$lidarrUrlBase" = "null" ]; then
@ -161,6 +161,7 @@ DownloadFormat () {
log "ERROR :: Invalid audioFormat and audioBitrate options set..."
log "ERROR :: Change audioBitrate to a low, high, or lossless..."
log "ERROR :: Exiting..."
NotifyWebhook "Error" "Invalid audioFormat and audioBitrate options set"
exit
fi
else
@ -168,6 +169,7 @@ DownloadFormat () {
log "ERROR :: Invalid audioFormat and audioBitrate options set..."
log "ERROR :: Change audioBitrate to a desired bitrate number, example: 192..."
log "ERROR :: Exiting..."
NotifyWebhook "Error" "Invalid audioFormat and audioBitrate options set"
exit
else
tidal-dl -q HiFi
@ -374,6 +376,7 @@ TidalClientTest () {
log "TIDAL :: ERROR :: You will need to re-authenticate on next script run..."
log "TIDAL :: ERROR :: Exiting..."
rm -rf $downloadPath/incomplete/*
NotifyWebhook "Error" "TIDAL not authenticated but configured"
exit
else
rm -rf $downloadPath/incomplete/*
@ -803,6 +806,7 @@ DeezerClientTest () {
log "DEEZER :: ERROR :: Try updating your ARL Token to possibly resolve the issue..."
log "DEEZER :: ERROR :: Exiting..."
rm -rf $downloadPath/incomplete/*
NotifyWebhook "Error" "DEEZER not authenticated but configured"
exit
else
rm -rf $downloadPath/incomplete/*
@ -870,6 +874,7 @@ LidarrRootFolderCheck () {
log "ERROR :: No root folder found"
log "ERROR :: Configure root folder in Lidarr to continue..."
log "ERROR :: Exiting..."
NotifyWebhook "Error" "No root folder found"
exit
fi
}
@ -1892,6 +1897,13 @@ audioFlacVerification () {
verifiedFlacFile=$(flac --totally-silent -t "$1"; echo $?)
}
NotifyWebhook () {
if [ "$webHook" ]
then
curl -X POST "{$webHook}" -H 'Content-Type: application/json' -d '{"event":"'"$1"'", "message":"'"$2"'"}'
fi
}
Configuration
if [ "$configureLidarrWithOptimalSettings" = "true" ]; then

@ -1,5 +1,5 @@
#!/usr/bin/env bash
scriptVersion="1.0.037"
scriptVersion="1.0.038"
if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
@ -199,6 +199,7 @@ TidalClientTest () {
log "TIDAL :: ERROR :: You will need to re-authenticate on next script run..."
log "TIDAL :: ERROR :: Exiting..."
rm -rf $downloadPath/incomplete/*
NotifyWebhook "Error" "TIDAL not authenticated but configured"
exit
else
rm -rf $downloadPath/incomplete/*
@ -550,6 +551,13 @@ AddFeaturedVideoArtists () {
}
NotifyWebhook () {
if [ "$webHook" ]
then
curl -X POST "{$webHook}" -H 'Content-Type: application/json' -d '{"event":"'"$1"'", "message":"'"$2"'"}'
fi
}
Configuration
TidalClientSetup
AddFeaturedVideoArtists

Loading…
Cancel
Save