Skip to content

Commit

Permalink
chore: update sonarr/radarr notification scripts from onedr0p
Browse files Browse the repository at this point in the history
  • Loading branch information
zebernst committed Nov 2, 2024
1 parent d4cbd7e commit ca1e9bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2154

set -euo pipefail

# User defined variables for pushover
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2154

set -euo pipefail

# User defined variables for pushover
Expand All @@ -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
Expand Down
23 changes: 13 additions & 10 deletions kubernetes/apps/default/sonarr/app/resources/refresh-series.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ca1e9bb

Please sign in to comment.