Instead of having the files deleted directly from this script, call the APIs for Sonarr and/or Radarr to have those items removed and marked as unmonitored (or remove the Sonarr/Radarr item completely) to prevent the items from being re-downloaded automatically.
It appears that the configuration of this script does not allow for the arrs to be on different IP addresses.
Would it be possible to change the configuration to support multiple IP addresses also support for multiple instances of Radarr and Sonarr would be great.