commit fc7e75e1ea2cb42e8c522d40db1192bee2c23604 Author: Thomas Gander Date: Sun Mar 1 23:13:13 2026 -0700 Initial commit diff --git a/postprocess.sh b/postprocess.sh new file mode 100644 index 0000000..4c1feac --- /dev/null +++ b/postprocess.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# ===== CONFIG ===== +RADARR_URL="http://localhost:7878" +API_KEY="YOUR_API_KEY" +# ================== + +log() { + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >&2 +} + +# Only act on Import/Upgrade +if [ "$radarr_eventtype" != "Download" ]; then + log "Ignoring event type: $radarr_eventtype" + exit 0 +fi + +MOVIEFILE_ID="$radarr_moviefile_id" +MOVIE_ID="$radarr_movie_id" + +log "Movie Info: FILEID: $MOVIEFILE_ID | ID: $MOVIE_ID" + +if [ -z "$MOVIEFILE_ID" ]; then + log "No moviefile ID supplied." + exit 1 +fi + +log "Processing MovieFile ID: $MOVIEFILE_ID" + +# Get moviefile details +MOVIEFILE=$(curl -s -H "X-Api-Key: $API_KEY" \ + "$RADARR_URL/api/v3/moviefile/$MOVIEFILE_ID") + +SCORE=$(echo "$MOVIEFILE" | jq '.customFormatScore') + +log "Custom Format Score: $SCORE" +if [ "$SCORE" -lt 0 ]; then + log "Score below zero — rejecting release." + + # Delete moviefile + curl -s -X DELETE \ + -H "X-Api-Key: $API_KEY" \ + "$RADARR_URL/api/v3/moviefile/$MOVIEFILE_ID?deleteFiles=true" \ + > /dev/null + + log "Movie file deleted." + + # Trigger re-search + curl -s -X POST "$RADARR_URL/api/v3/command" \ + -H "X-Api-Key: $API_KEY" \ + -H "Content-Type: application/json" \ + -d "{ + \"name\": \"MoviesSearch\", + \"movieIds\": [$MOVIE_ID], + \"ignoreDeleted\": true, + \"searchForUpgrade\": true + }" > /dev/null + + log "Re-search triggered." + + exit 1 +fi + +log "Score acceptable." +exit 0 \ No newline at end of file