Initial commit
This commit is contained in:
65
postprocess.sh
Normal file
65
postprocess.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user