#!/usr/bin/env bash # scripts/add-tracker.sh — register a tracker with Prowlarr via API. # # Usage: # PROWLARR_API_KEY=xxx ./add-tracker.sh # # Where is Prowlarr's internal ID for the indexer type (look it # up via `curl /api/v1/indexer/schema` — see "Discovering indexer IDs" below). # # This script POSTs a minimal indexer config to Prowlarr. For trackers that # need cookies / passkeys / 2FA, finish the setup in the Prowlarr webui # afterwards. # # Pre-reqs: # - Prowlarr container up. # - PROWLARR_API_KEY exported (Prowlarr → Settings → General → Security). # - PROWLARR_URL defaults to http://127.0.0.1:9696. set -euo pipefail NAME="${1:-}" INDEXER_ID="${2:-}" PROWLARR_URL="${PROWLARR_URL:-http://127.0.0.1:9696}" PROWLARR_API_KEY="${PROWLARR_API_KEY:-}" if [ -z "$NAME" ] || [ -z "$INDEXER_ID" ] || [ -z "$PROWLARR_API_KEY" ]; then cat <&2 Usage: PROWLARR_API_KEY=xxx $0 Env: PROWLARR_URL default: http://127.0.0.1:9696 PROWLARR_API_KEY required — Prowlarr → Settings → General → Security. Discovering indexer IDs: curl -s "\$PROWLARR_URL/api/v1/indexer/schema" \\ -H "X-Api-Key: \$PROWLARR_API_KEY" | \\ jq -r '.[] | "\\(.implementation)\\t\\(.implementationName)"' | sort -u Find the row matching your tracker, then look up its integer id via the full schema entry. Many private trackers use the "Cardigann" implementation with a YAML config — see Prowlarr docs for the full attribute list. EOF exit 2 fi echo "Querying schema for '$INDEXER_ID'..." SCHEMA_JSON="$(curl -fsS \ -H "X-Api-Key: $PROWLARR_API_KEY" \ "$PROWLARR_URL/api/v1/indexer/schema" \ | jq --arg id "$INDEXER_ID" '.[] | select(.id == ($id | tonumber))')" if [ -z "$SCHEMA_JSON" ]; then echo "No schema entry for indexer id=$INDEXER_ID" >&2 exit 1 fi # Override name with the user-provided one and keep all other fields as-is. PAYLOAD="$(jq --arg name "$NAME" '. + {name: $name, enable: true}' <<<"$SCHEMA_JSON")" echo "POSTing indexer config..." RESPONSE="$(curl -fsS -X POST \ -H "X-Api-Key: $PROWLARR_API_KEY" \ -H "Content-Type: application/json" \ -d "$PAYLOAD" \ "$PROWLARR_URL/api/v1/indexer")" NEW_ID="$(jq -r '.id' <<<"$RESPONSE")" echo "OK — indexer '$NAME' added with id=$NEW_ID" echo echo "Next steps:" echo " 1. Open Prowlarr → Indexers → $NAME → fill in cookies/passkey/API key." echo " 2. Test indexer (Settings → Indexers → Test)." echo " 3. Add a row to docs/trackers.md with IP-pinning + ratio notes." echo " 4. Push to Sonarr/Radarr via Prowlarr's Apps → Sync."