Last active
March 3, 2026 00:11
-
-
Save rabidpug/a023ce2b62c4df806671ad19c105f835 to your computer and use it in GitHub Desktop.
Trigger a search for the first 20 cutoff unmet/missing episodes/movies/albums/books by oldest search time in the ARR suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| __help() { | |
| cat << EOF | |
| Please call this script with \$ARR_API_KEY set, and with the following parameters: | |
| $0 sonarr|radarr|lidarr|readarr https://domain:port cutoff|missing | |
| EOF | |
| exit 1 | |
| } | |
| if [[ -z "$ARR_API_KEY" ]] || [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then | |
| __help | |
| fi | |
| case $1 in | |
| radarr) | |
| api=v3 | |
| sortPart=movie | |
| commandPart=Movies | |
| ;; | |
| lidarr) | |
| api=v1 | |
| sortPart=album | |
| commandPart=Album | |
| ;; | |
| readarr) | |
| api=v1 | |
| sortPart=book | |
| commandPart=Book | |
| ;; | |
| sonarr) | |
| api=v3 | |
| sortPart=episode | |
| commandPart=Episode | |
| ;; | |
| *) | |
| __help | |
| ;; | |
| esac | |
| curl -fsSL \ | |
| -H "X-Api-Key: $ARR_API_KEY" \ | |
| -H 'Content-Type: application/json' \ | |
| -X POST \ | |
| -d "$(curl -fsSL \ | |
| -H "X-Api-Key: $ARR_API_KEY" \ | |
| "$2/api/$api/wanted/$3?page=1&pageSize=20&sortDirection=ascending&sortKey=${sortPart}s.lastSearchTime&monitored=true" \ | |
| | jq -rc --arg name "${commandPart}Search" --arg key "${sortPart}Ids" '{name: $name, $key: [.records[].id]}' \ | |
| )" "$2/api/$api/command" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires curl and jq.
Example systemd service and timer below.
Create the file
/etc/arr-search/sonarr.envwith locked-down permissions and the contents:then create the 2 files below, eg in
/etc/systemd/systemCopy both those files, replacing
missingwithcutoffboth in the names and contents of the files.Then run
systemctl enable --now arr-missing@sonarr.timer arr-cutoff@sonarr.timerYou will now have 20 missing and 20 cutoff unmet episodes searched roughly every hour.