From ca1e9bb74eeb0e6facdcd4d92d13cca97fb08a2d Mon Sep 17 00:00:00 2001 From: Zach Bernstein Date: Sat, 2 Nov 2024 15:30:11 -0400 Subject: [PATCH] chore: update sonarr/radarr notification scripts from onedr0p --- .../radarr/app/resources/pushover-notify.sh | 9 ++++++-- .../sonarr/app/resources/pushover-notify.sh | 7 +++++- .../sonarr/app/resources/refresh-series.sh | 23 +++++++++++-------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/kubernetes/apps/default/radarr/app/resources/pushover-notify.sh b/kubernetes/apps/default/radarr/app/resources/pushover-notify.sh index 30d453a5..54b66910 100755 --- a/kubernetes/apps/default/radarr/app/resources/pushover-notify.sh +++ b/kubernetes/apps/default/radarr/app/resources/pushover-notify.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash # shellcheck disable=SC2154 - set -euo pipefail # User defined variables for pushover @@ -14,7 +13,13 @@ if [[ "${radarr_eventtype:-}" == "Test" ]]; then "Test Notification" printf -v PUSHOVER_MESSAGE \ "Howdy this is a test notification from %s" \ - "${radarr_instancename:-Sonarr}" + "${radarr_instancename:-Radarr}" + printf -v PUSHOVER_URL \ + "%s" \ + "${radarr_applicationurl:-localhost}" + printf -v PUSHOVER_URL_TITLE \ + "Open %s" \ + "${radarr_instancename:-Radarr}" fi if [[ "${radarr_eventtype:-}" == "Download" ]]; then diff --git a/kubernetes/apps/default/sonarr/app/resources/pushover-notify.sh b/kubernetes/apps/default/sonarr/app/resources/pushover-notify.sh index e7c5eb44..38423526 100755 --- a/kubernetes/apps/default/sonarr/app/resources/pushover-notify.sh +++ b/kubernetes/apps/default/sonarr/app/resources/pushover-notify.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash # shellcheck disable=SC2154 - set -euo pipefail # User defined variables for pushover @@ -15,6 +14,12 @@ if [[ "${sonarr_eventtype:-}" == "Test" ]]; then printf -v PUSHOVER_MESSAGE \ "Howdy this is a test notification from %s" \ "${sonarr_instancename:-Sonarr}" + printf -v PUSHOVER_URL \ + "%s" \ + "${sonarr_applicationurl:-localhost}" + printf -v PUSHOVER_URL_TITLE \ + "Open %s" \ + "${sonarr_instancename:-Sonarr}" fi if [[ "${sonarr_eventtype:-}" == "Download" ]]; then diff --git a/kubernetes/apps/default/sonarr/app/resources/refresh-series.sh b/kubernetes/apps/default/sonarr/app/resources/refresh-series.sh index f88c7233..be570f16 100755 --- a/kubernetes/apps/default/sonarr/app/resources/refresh-series.sh +++ b/kubernetes/apps/default/sonarr/app/resources/refresh-series.sh @@ -1,18 +1,21 @@ #!/usr/bin/env bash # shellcheck disable=SC2154 +set -euo pipefail + +CURL_CMD=(curl -fsSL --header "X-Api-Key: ${SONARR__AUTH__APIKEY:-}") +SONARR_API_URL="http://localhost:${SONARR__SERVER__PORT:-}/api/v3" if [[ "${sonarr_eventtype:-}" == "Grab" ]]; then - tba_count=$(curl -fsSL \ - --header "X-Api-Key: ${SONARR__AUTH__APIKEY}" \ - "http://localhost:${SONARR__SERVER__PORT}/api/v3/episode?seriesId=${sonarr_series_id}" \ - | jq --raw-output '[.[] | select((.title == "TBA") or (.title == "TBD"))] | length') + tba=$("${CURL_CMD[@]}" "${SONARR_API_URL}/episode?seriesId=${sonarr_series_id:-}" | jq --raw-output ' + [.[] | select((.title == "TBA") or (.title == "TBD"))] | length + ') - if (( tba_count > 0 )); then - echo "INFO: Refreshing series ${sonarr_series_id} due to TBA/TBD episodes found" - curl -fsSL \ - --header "X-Api-Key: ${SONARR__AUTH__APIKEY}" \ + if (( tba > 0 )); then + echo "INFO: Refreshing series ${sonarr_series_id:-} due to TBA/TBD episodes found" + "${CURL_CMD[@]}" \ + --request POST \ --header "Content-Type: application/json" \ - --data-binary '{"name": "RefreshSeries", "seriesId": '"${sonarr_series_id}"'}' \ - --request POST "http://localhost:${SONARR__SERVER__PORT}/api/v3/command" &> /dev/null + --data-binary '{"name": "RefreshSeries", "seriesId": '"${sonarr_series_id:-}"'}' \ + "${SONARR_API_URL}/command" &>/dev/null fi fi