mirror of
https://github.com/auricom/home-cluster.git
synced 2025-09-17 18:24:14 +02:00
🐛 fix sonarr
This commit is contained in:
@@ -16,7 +16,7 @@ spec:
|
|||||||
data:
|
data:
|
||||||
# App
|
# App
|
||||||
SONARR__API_KEY: "{{ .SONARR__API_KEY }}"
|
SONARR__API_KEY: "{{ .SONARR__API_KEY }}"
|
||||||
PUSHOVER_API_TOKEN: "{{ .PUSHOVER_API_TOKEN }}"
|
PUSHOVER_TOKEN: "{{ .PUSHOVER_API_TOKEN }}"
|
||||||
PUSHOVER_USER_KEY: "{{ .PUSHOVER_USER_KEY }}"
|
PUSHOVER_USER_KEY: "{{ .PUSHOVER_USER_KEY }}"
|
||||||
dataFrom:
|
dataFrom:
|
||||||
- extract:
|
- extract:
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
PUSHOVER_DEBUG="${PUSHOVER_DEBUG:-"true"}"
|
PUSHOVER_DEBUG="${PUSHOVER_DEBUG:-"true"}"
|
||||||
# kubectl port-forward service/sonarr -n default 8989:8989
|
# kubectl port-forward service/sonarr -n default 8989:80
|
||||||
# export PUSHOVER_APP_URL="";
|
|
||||||
# export PUSHOVER_TOKEN="";
|
# export PUSHOVER_TOKEN="";
|
||||||
# export PUSHOVER_USER_KEY="";
|
# export PUSHOVER_USER_KEY="";
|
||||||
# export sonarr_eventtype=Download;
|
# export sonarr_eventtype=Download;
|
||||||
# ./notify.sh
|
# ./pushover-notify.sh
|
||||||
|
|
||||||
CONFIG_FILE="/config/config.xml" && [[ "${PUSHOVER_DEBUG}" == "true" ]] && CONFIG_FILE="config.xml"
|
CONFIG_FILE="/config/config.xml" && [[ "${PUSHOVER_DEBUG}" == "true" ]] && CONFIG_FILE="config.xml"
|
||||||
ERRORS=()
|
ERRORS=()
|
||||||
@@ -15,15 +14,12 @@ ERRORS=()
|
|||||||
# Discoverable variables
|
# Discoverable variables
|
||||||
#
|
#
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
PUSHOVER_STARR_PORT="$(xmlstarlet sel -t -v "//Port" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_PORT}" ]] && ERRORS+=("PUSHOVER_STARR_PORT not defined")
|
|
||||||
PUSHOVER_STARR_APIKEY="$(xmlstarlet sel -t -v "//ApiKey" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_APIKEY}" ]] && ERRORS+=("PUSHOVER_STARR_APIKEY not defined")
|
PUSHOVER_STARR_APIKEY="$(xmlstarlet sel -t -v "//ApiKey" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_APIKEY}" ]] && ERRORS+=("PUSHOVER_STARR_APIKEY not defined")
|
||||||
PUSHOVER_STARR_INSTANCE_NAME="$(xmlstarlet sel -t -v "//InstanceName" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_INSTANCE_NAME}" ]] && ERRORS+=("PUSHOVER_STARR_INSTANCE_NAME not defined")
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configurable variables
|
# Configurable variables
|
||||||
#
|
#
|
||||||
# Required
|
# Required
|
||||||
PUSHOVER_APP_URL="${PUSHOVER_APP_URL:-}" && [[ -z "${PUSHOVER_APP_URL}" ]] && ERRORS+=("PUSHOVER_APP_URL not defined")
|
|
||||||
PUSHOVER_USER_KEY="${PUSHOVER_USER_KEY:-}" && [[ -z "${PUSHOVER_USER_KEY}" ]] && ERRORS+=("PUSHOVER_USER_KEY not defined")
|
PUSHOVER_USER_KEY="${PUSHOVER_USER_KEY:-}" && [[ -z "${PUSHOVER_USER_KEY}" ]] && ERRORS+=("PUSHOVER_USER_KEY not defined")
|
||||||
PUSHOVER_TOKEN="${PUSHOVER_TOKEN:-}" && [[ -z "${PUSHOVER_TOKEN}" ]] && ERRORS+=("PUSHOVER_TOKEN not defined")
|
PUSHOVER_TOKEN="${PUSHOVER_TOKEN:-}" && [[ -z "${PUSHOVER_TOKEN}" ]] && ERRORS+=("PUSHOVER_TOKEN not defined")
|
||||||
# Optional
|
# Optional
|
||||||
@@ -53,41 +49,38 @@ fi
|
|||||||
#
|
#
|
||||||
if [[ "${sonarr_eventtype:-}" == "Test" ]]; then
|
if [[ "${sonarr_eventtype:-}" == "Test" ]]; then
|
||||||
PUSHOVER_TITLE="Test Notification"
|
PUSHOVER_TITLE="Test Notification"
|
||||||
PUSHOVER_MESSAGE="Howdy this is a test notification from ${PUSHOVER_STARR_INSTANCE_NAME}"
|
PUSHOVER_MESSAGE="Howdy this is a test notification from ${sonarr_instancename:-Sonarr}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Send notification on Download or Upgrade
|
# Send notification on Download or Upgrade
|
||||||
#
|
#
|
||||||
if [[ "${sonarr_eventtype:-}" == "Download" ]]; then
|
if [[ "${sonarr_eventtype:-}" == "Download" ]]; then
|
||||||
printf -v PUSHOVER_TITLE "%s - S%02dE%02d - %s [%s]" \
|
printf -v PUSHOVER_TITLE "New Episode %s" "${sonarr_eventtype:-Download}"
|
||||||
"${sonarr_series_title:-"That '70s Show"}" \
|
printf -v PUSHOVER_MESSAGE "<b>%s (S%02dE%02d)</b><small>\n%s</small><small>\n\n<b>Quality:</b> %s</small><small>\n<b>Client:</b> %s</small><small>\n<b>Upgrade:</b> %s</small>" \
|
||||||
|
"${sonarr_series_title:-"Mystery Science Theater 3000"}" \
|
||||||
"${sonarr_episodefile_seasonnumber:-"8"}" \
|
"${sonarr_episodefile_seasonnumber:-"8"}" \
|
||||||
"${sonarr_episodefile_episodenumbers:-"22"}" \
|
"${sonarr_episodefile_episodenumbers:-"20"}" \
|
||||||
"${sonarr_episodefile_episodetitles:-"That '70s Finale"}" \
|
"${sonarr_episodefile_episodetitles:-"Space Mutiny"}" \
|
||||||
"${sonarr_episodefile_quality:-"Bluray-720p"}"
|
"${sonarr_episodefile_quality:-"DVD"}" \
|
||||||
printf -v PUSHOVER_MESSAGE "%s" \
|
"${sonarr_download_client:-"qbittorrent"}" \
|
||||||
"$(curl --silent --header "X-Api-Key:${PUSHOVER_STARR_APIKEY}" "http://localhost:${PUSHOVER_STARR_PORT}/api/v3/episode?seriesId=${sonarr_series_id:-"1653"}" \
|
"${sonarr_isupgrade:-"False"}"
|
||||||
| jq -r ".[] | select(.episodeFileId==${sonarr_episodefile_id:-"167750"}) | .overview")"
|
printf -v PUSHOVER_URL "%s/series/%s" "${sonarr_applicationurl:-localhost}" "${sonarr_series_titleslug:-""}"
|
||||||
printf -v PUSHOVER_URL "https://%s/series/%s" \
|
printf -v PUSHOVER_URL_TITLE "View series in %s" "${sonarr_instancename:-Sonarr}"
|
||||||
"${PUSHOVER_APP_URL}" \
|
|
||||||
"$(curl --silent --header "X-Api-Key:${PUSHOVER_STARR_APIKEY}" "http://localhost:${PUSHOVER_STARR_PORT}/api/v3/series/${sonarr_series_id:-"1653"}" \
|
|
||||||
| jq -r ".titleSlug")"
|
|
||||||
printf -v PUSHOVER_URL_TITLE "View series in %s" \
|
|
||||||
"${PUSHOVER_STARR_INSTANCE_NAME}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
notification=$(jq -n \
|
notification=$(jq -n \
|
||||||
--arg token "${PUSHOVER_TOKEN}" \
|
--arg token "${PUSHOVER_TOKEN}" \
|
||||||
--arg user "${PUSHOVER_USER_KEY}" \
|
--arg user "${PUSHOVER_USER_KEY}" \
|
||||||
--arg title "${PUSHOVER_TITLE}" \
|
--arg title "${PUSHOVER_TITLE}" \
|
||||||
--arg message "${PUSHOVER_MESSAGE:-"Unable to obtain plot summary"}" \
|
--arg message "${PUSHOVER_MESSAGE}" \
|
||||||
--arg url "${PUSHOVER_URL}" \
|
--arg url "${PUSHOVER_URL}" \
|
||||||
--arg url_title "${PUSHOVER_URL_TITLE}" \
|
--arg url_title "${PUSHOVER_URL_TITLE}" \
|
||||||
--arg priority "${PUSHOVER_PRIORITY}" \
|
--arg priority "${PUSHOVER_PRIORITY}" \
|
||||||
--arg sound "${PUSHOVER_SOUND}" \
|
--arg sound "${PUSHOVER_SOUND}" \
|
||||||
--arg device "${PUSHOVER_DEVICE}" \
|
--arg device "${PUSHOVER_DEVICE}" \
|
||||||
'{token: $token, user: $user, title: $title, message: $message, url: $url, url_title: $url_title, priority: $priority, sound: $sound, device: $device}' \
|
--arg html "1" \
|
||||||
|
'{token: $token, user: $user, title: $title, message: $message, url: $url, url_title: $url_title, priority: $priority, sound: $sound, device: $device, html: $html}' \
|
||||||
)
|
)
|
||||||
|
|
||||||
status_code=$(curl \
|
status_code=$(curl \
|
||||||
|
Reference in New Issue
Block a user