Add SABnzbd client and Downloads view (M4)
SABnzbd client (queue, history, pause/resume, delete, retry) with lenient number decoding and API-key-safe errors. Downloads view polls while visible, shows queue and history, and supports pause, delete (with confirmation) and retry. Add dev/ with pinned Radarr/Sonarr/SABnzbd containers wired together for manual testing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
# Start the local Radarr/Sonarr/SABnzbd test instances and configure them (idempotent).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
RADARR_KEY=devradarrapikey00000000000000000
|
||||
SONARR_KEY=devsonarrapikey00000000000000000
|
||||
SAB_KEY=devsabnzbdapikey0000000000000000
|
||||
RADARR=http://127.0.0.1:17878
|
||||
SONARR=http://127.0.0.1:18989
|
||||
SAB=http://127.0.0.1:18080
|
||||
|
||||
mkdir -p data/{radarr,sonarr,sabnzbd,downloads,media/movies,media/tv}
|
||||
[ -f data/sabnzbd/sabnzbd.ini ] || cp seed/sabnzbd.ini data/sabnzbd/sabnzbd.ini
|
||||
|
||||
docker compose -f compose.yaml up -d
|
||||
|
||||
wait_for() { # name url [header]
|
||||
for _ in $(seq 60); do
|
||||
curl -sf -m3 ${3:+-H "$3"} "$2" >/dev/null && return 0
|
||||
sleep 2
|
||||
done
|
||||
echo "timed out waiting for $1" >&2; exit 1
|
||||
}
|
||||
wait_for radarr "$RADARR/api/v3/system/status" "X-Api-Key: $RADARR_KEY"
|
||||
wait_for sonarr "$SONARR/api/v3/system/status" "X-Api-Key: $SONARR_KEY"
|
||||
wait_for sabnzbd "$SAB/api?mode=version&output=json&apikey=$SAB_KEY"
|
||||
|
||||
# Radarr/Sonarr reach SABnzbd as "sabnzbd"; its hostname check must allow that.
|
||||
curl -sf "$SAB/api?mode=set_config§ion=misc&keyword=host_whitelist&value=sabnzbd,localhost&output=json&apikey=$SAB_KEY" >/dev/null
|
||||
|
||||
for cat in radarr sonarr; do
|
||||
curl -sf "$SAB/api?mode=set_config§ion=categories&name=$cat&dir=$cat&output=json&apikey=$SAB_KEY" >/dev/null
|
||||
done
|
||||
|
||||
post_once() { # base key path jq-check body : POST body unless GET path already matches
|
||||
local base=$1 key=$2 path=$3 check=$4 body=$5
|
||||
if curl -sf -H "X-Api-Key: $key" "$base/api/v3/$path" | grep -q "$check"; then return 0; fi
|
||||
curl -sf -H "X-Api-Key: $key" -H 'Content-Type: application/json' -d "$body" "$base/api/v3/$path" >/dev/null
|
||||
}
|
||||
|
||||
post_once "$RADARR" "$RADARR_KEY" rootfolder '"/media/movies' '{"path":"/media/movies"}'
|
||||
post_once "$SONARR" "$SONARR_KEY" rootfolder '"/media/tv' '{"path":"/media/tv"}'
|
||||
|
||||
client() { # category-field category
|
||||
printf '{"enable":true,"protocol":"usenet","priority":1,"name":"SABnzbd","implementation":"Sabnzbd","configContract":"SabnzbdSettings","tags":[],"fields":[{"name":"host","value":"sabnzbd"},{"name":"port","value":8080},{"name":"useSsl","value":false},{"name":"apiKey","value":"%s"},{"name":"%s","value":"%s"}]}' "$SAB_KEY" "$1" "$2"
|
||||
}
|
||||
post_once "$RADARR" "$RADARR_KEY" downloadclient '"SABnzbd"' "$(client movieCategory radarr)"
|
||||
post_once "$SONARR" "$SONARR_KEY" downloadclient '"SABnzbd"' "$(client tvCategory sonarr)"
|
||||
|
||||
cat <<MSG
|
||||
Dev instances are ready:
|
||||
Radarr $RADARR key $RADARR_KEY
|
||||
Sonarr $SONARR key $SONARR_KEY
|
||||
SABnzbd $SAB key $SAB_KEY
|
||||
MSG
|
||||
Reference in New Issue
Block a user