This repository contains shell scripts and configuration files for Radarr automation, primarily focused on tagging movies with Dolby Vision metadata (FEL/MEL tags).
Primary Script: radarr/connect/tag_dvfelmel.sh - Tags movies with fel or mel based on Dolby Vision Enhancement Layer detection.
ShellCheck - Static analysis for shell scripts:
shellcheck radarr/connect/tag_dvfelmel.shRun with specific rules disabled (as used in this project):
shellcheck -e SC3043 radarr/connect/tag_dvfelmel.shRun the tag script in test mode:
./radarr/connect/tag_dvfelmel.shRun in bulk mode (process all movies):
./radarr/connect/tag_dvfelmel.sh bulkDirect invocation with arguments:
./radarr/connect/tag_dvfelmel.sh <event_type> <movie_id> [movie_file_path]Event types: Test, MovieFileDelete, Download, Bulk
There are no formal test suites in this project. Manual testing can be performed by:
- Running the script with
Testevent type - Using Radarr's built-in "Test" button for Connect scripts
- Shebang: Use
#!/usr/bin/env shfor POSIX compatibility - Disable shellcheck warnings appropriately: Add
# shellcheck disable=SCxxxxcomments when needed (e.g.,SC3043forlocalkeyword in POSIX sh) - Exit codes: Use meaningful exit codes; 0 for success, 1 for general errors, 127 for command not found
- Indent with 4 spaces
- Maximum line length: 100 characters (soft limit)
- Use backslash for line continuation with proper indentation
- Pipe operators should have the pipe character at the end of the line, not the start
- Functions: Use lowercase with underscores:
function_name() - Variables: Use uppercase for global variables, lowercase for locals
- Constants: All uppercase:
NEEDED_EXECUTABLES - Local variables: Prefix with underscore:
local _variable_name - Configuration variables: Prefix with service name:
RADARR_API_URL
# Global constants
NEEDED_EXECUTABLES="curl dovi_tool ffmpeg grep jq mktemp"
# Configuration with defaults
: "${LOG_FILE:=none}"
: "${RADARR_API_URL:=http://ip:7878/api/v3}"
# Local variables
local _movie_id _tag_id- Always redirect errors to stderr:
echo "ERROR: message" >&2 - Use return codes to indicate success/failure
- Check command exit status when needed
- Provide meaningful error messages that include context
if ! command -v "${executable}" >/dev/null 2>&1
then
echo "ERROR: Executable '${executable} not found." >&2
exit 127
fi- Validate function arguments with case statements
- Check for empty strings:
[ -z "$var" ] - Validate numeric input using pattern matching:
case "$1" in
''|*[!0-9]*)
echo "ERROR: Argument is not a movie id: $1" >&2
return 1
;;
*)
_movie_id="$1"
;;
esac- Use curl with
-sfor silent operation - Always set headers:
Accept-Encoding,Content-Type - Parse JSON responses with jq
- Use printf for JSON payloads to avoid injection issues
function_name() {
local _arg1 _arg2
# Input validation
case "$1" in
'')
echo "ERROR: Missing required argument" >&2
return 1
;;
esac
# Main logic
# ...
# Return result
echo "${_result}"
}- Use comments to explain non-obvious logic
- Document function purpose at the top
- Include version history for significant changes
- Reference external sources when basing code on others' work
- Sample files should have
.sampleextension - Document all configuration variables with comments
- Use descriptive variable names
- Place sensitive defaults (like API keys) with placeholder values
- Check for required executables at script start
- Use mktemp for temporary files; always clean up
- Quote all variable expansions:
"$variable" - Use
$()for command substitution (not backticks) - Use arithmetic expansion:
$((_counter+=1)) - Be careful with word splitting - always quote variables
- Use meaningful debug messages:
echo "DEBUG: Doing X for Y"
radarr/connect/
tag_dvfelmel.sh # Main script
scripts.conf.sample # Sample configuration
scripts.conf # Actual configuration (not in git)
Required executables (checked at runtime):
- curl
- dovi_tool
- ffmpeg
- grep
- jq
- mktemp
- For more extensive Radarr taggers, check out Radarr DV HDR Tagarr from TRaSH-
- Scripts are designed to run in Radarr Connect/post-process context
- Compatible with FreeBSD and Linux environments