From 5134622d13fe83610bd511388b6cd7fc56e7cd36 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Fri, 9 Aug 2024 16:40:21 -0400 Subject: [PATCH] fix: tba sonarr problem solved question mark Signed-off-by: Devin Buhl --- .../apps/default/sonarr/app/helmrelease.yaml | 5 ++++- .../apps/default/sonarr/app/kustomization.yaml | 1 + .../sonarr/app/resources/pushover-notify.sh | 7 ------- .../sonarr/app/resources/refresh-series.sh | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100755 kubernetes/main/apps/default/sonarr/app/resources/refresh-series.sh diff --git a/kubernetes/main/apps/default/sonarr/app/helmrelease.yaml b/kubernetes/main/apps/default/sonarr/app/helmrelease.yaml index ecffdc2eb4044..02084ec29ebde 100644 --- a/kubernetes/main/apps/default/sonarr/app/helmrelease.yaml +++ b/kubernetes/main/apps/default/sonarr/app/helmrelease.yaml @@ -106,7 +106,7 @@ spec: persistence: config: existingClaim: sonarr - pushover-notify: + scripts: type: configMap name: sonarr-configmap defaultMode: 0775 @@ -114,6 +114,9 @@ spec: - path: /scripts/pushover-notify.sh subPath: pushover-notify.sh readOnly: true + - path: /scripts/refresh-series.sh + subPath: refresh-series.sh + readOnly: true tmp: type: emptyDir media: diff --git a/kubernetes/main/apps/default/sonarr/app/kustomization.yaml b/kubernetes/main/apps/default/sonarr/app/kustomization.yaml index bd6d8628bfb3d..6a9c390cb495a 100644 --- a/kubernetes/main/apps/default/sonarr/app/kustomization.yaml +++ b/kubernetes/main/apps/default/sonarr/app/kustomization.yaml @@ -11,6 +11,7 @@ configMapGenerator: - name: sonarr-configmap files: - pushover-notify.sh=./resources/pushover-notify.sh + - refresh-series.sh=./resources/refresh-series.sh generatorOptions: disableNameSuffixHash: true annotations: diff --git a/kubernetes/main/apps/default/sonarr/app/resources/pushover-notify.sh b/kubernetes/main/apps/default/sonarr/app/resources/pushover-notify.sh index 8ff59bb21068e..b2e7120b39244 100755 --- a/kubernetes/main/apps/default/sonarr/app/resources/pushover-notify.sh +++ b/kubernetes/main/apps/default/sonarr/app/resources/pushover-notify.sh @@ -2,13 +2,6 @@ # shellcheck disable=SC2154 PUSHOVER_DEBUG="${PUSHOVER_DEBUG:-"false"}" -# kubectl port-forward service/sonarr -n default 8989:80 -# export PUSHOVER_TOKEN=""; -# export PUSHOVER_USER_KEY=""; -# export sonarr_eventtype=Download; -# ./pushover-notify.sh - -CONFIG_FILE="/config/config.xml" && [[ "${PUSHOVER_DEBUG}" == "true" ]] && CONFIG_FILE="config.xml" ERRORS=() # diff --git a/kubernetes/main/apps/default/sonarr/app/resources/refresh-series.sh b/kubernetes/main/apps/default/sonarr/app/resources/refresh-series.sh new file mode 100755 index 0000000000000..ec7658a235c87 --- /dev/null +++ b/kubernetes/main/apps/default/sonarr/app/resources/refresh-series.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2154 + +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"))' | jq --slurp '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}" \ + --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 + fi +fi