feat: webhook

This commit is contained in:
auricom
2025-04-16 09:36:06 +02:00
parent 7372e1cb94
commit e14d7c3bb4
134 changed files with 951 additions and 264 deletions

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -Eeuo pipefail
function refresh() {
if [[ "${SONARR_EVENT_TYPE}" == "Test" ]]; then
echo "[DEBUG] test event received from ${SONARR_REMOTE_ADDR}, nothing to do ..."
elif [[ "${SONARR_EVENT_TYPE}" == "Grab" ]]; then
episodes=$(
curl -fsSL --header "X-Api-Key: ${SONARR_API_KEY}" "http://${SONARR_REMOTE_ADDR}/api/v3/episode?seriesId=${SERIES_ID}" |
jq --raw-output '[.[] | select((.title == "TBA") or (.title == "TBD"))] | length'
)
if ((episodes > 0)); then
echo "[INFO] episode titles found with TBA/TBD titles, refreshing series ${SONARR_SERIES_TITLE} ..."
curl -fsSL --request POST \
--header "X-Api-Key: ${SONARR_API_KEY}" \
--header "Content-Type: application/json" \
--data-binary "$(jo name=RefreshSeries seriesId="${SERIES_ID}")" \
"http://${SONARR_REMOTE_ADDR}/api/v3/command" &>/dev/null
fi
fi
}
function main() {
refresh
}
main "$@"