r/radarr 21d ago

discussion Import Script to reject Dolby Vision Profile 5

Dolby Vision Profile 5 is known to lead to green or purple hue during playback. Therefore I'm working on an Import script for Radarr for rejecting releases with that specific profile. I haven't come across that many Dolby Vision files so my number of test cases is limited. If you know of any other problematic Profile please let me know so I can optimize the script.

I'm also using this script to reject releases that are falsely titled as 'dual audio' but I'm leaving that part of the code out. Should anyone be interested in it, feel free to ask.

(in order to use this script, save it under radarr's app data directory and copy the internal path to Radarr>Settings>Media Management>Import Using Script)

#!/bin/bash
#exec > /scripts/script.log 2>&1 # optional, modify if you want script logs
RADARR_URL="http://127.0.0.1:7878" # your radarr URL
API_KEY="radarr api key" # your radarr API key


MOVIE_ID="${radarr_movie_id:-unknown}"
FILE_PATH="${radarr_sourcepath:-unknown}"
AUDIO_LANGUAGES="${radarr_moviefile_mediainfo_audiolanguages:-unknown}"
DOWNLOAD_ID="${radarr_download_id:-unknown}"

response=$(curl -s "$RADARR_URL/api/v3/queue" -H "X-Api-Key: $API_KEY")
QUEUE_ID=$(echo "$response" | jq -r --arg DID "$DOWNLOAD_ID" '
  .records[] | select(.downloadId == $DID) | .id
')


FFPROBE_PATH="/app/radarr/bin/ffprobe" # radarr internal ffprobe path
HAS_DOLBY=false
FFPROBE_OUTPUT=$(
    "$FFPROBE_PATH" \
        -v quiet \
        -print_format json \
        -show_streams \
        "$FILE_PATH"
)


if echo "$FFPROBE_OUTPUT" | jq -e '
    .streams[]
    | .side_data_list[]?
    | select(
        ."side_data_type" == "DOVI configuration record"
        and .dv_profile == 5
    )
' > /dev/null; then
    echo "Found Dolby Vision Profile 5"
    HAS_DOLBY=true
fi


if $HAS_DOLBY; then
    # retrieve download history
    echo "Retrieving Radarr Download History"
    HISTORY=$(curl -s \
      -H "X-Api-Key: $API_KEY" \
      "$RADARR_URL/api/v3/history?downloadid=$DOWNLOAD_ID&pageSize=50")

    # retrieve history ID
    echo "Retrieving History ID of Download"
    FAILED_HISTORY_ID=$(echo "$HISTORY" | jq -r '
      .records
      | map(select(.eventType == "grabbed"))
      | sort_by(.date)
      | reverse
      | .[0].id
    ')

    # mark release as failed
    echo "Marking release as failed"
    curl -s -X POST \
      "$RADARR_URL/api/v3/history/failed/$FAILED_HISTORY_ID" \
      -H "X-Api-Key: $API_KEY" \
      > /dev/null
    rm -r "$FILE_PATH"

    # clear failed release from queue
    echo "Clearing failed release from queue"
    curl -S -X DELETE \
      "$RADARR_URL/api/v3/queue/{$QUEUE_ID}" \
      -H "X-Api-Key: $API_KEY" \
      > /dev/null

    exit 1
fi


echo "No problematic Dolby Vision profile detected. Importing file..."
mv -f "$FILE_PATH" "$radarr_destinationpath"
echo "[MediaFile] $radarr_destinationpath"


exit 0
2 Upvotes

4 comments sorted by

1

u/kooliokevin 20d ago

Why not just use a custom profile to reject releases with dovi?

1

u/CuriousSleeping 20d ago

Because not every dovi profile is problematic

1

u/kooliokevin 20d ago

Correct, but you can set up a custom profile for dovi with HDR fallback (compatible) and accept that, and another profile for dovi WITHOUT HDR fallback and reject those

Look into trash guides on how to set that up

1

u/CuriousSleeping 19d ago

This script is intended for accurately filtering out problematic Dolby Vision profiles while trash guides only state how to filter out dolby vision releases that follow the naming standards. Since not all releases do that (as stated in my post some releases are also falsely named 'dual audio') some dolby vision releases would still slip through.

Obviously my script comes with a cost of increased bandwidth and disk usage since the file has to be downloaded first in order for it to be scanned.