Skip to content

Instantly share code, notes, and snippets.

@fryfrog
Last active April 1, 2023 06:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fryfrog/b8e224ff1f92dd8b38f0e5afef9a215b to your computer and use it in GitHub Desktop.
Save fryfrog/b8e224ff1f92dd8b38f0e5afef9a215b to your computer and use it in GitHub Desktop.
A Radarr post processing script to change the rTorrent label after import.
#!/bin/bash
# This script uses the xmlrpc command from the xmlrpc-c package to change the label of an imported torrent in rTorrent.
# First argument is host
host="${1:-localhost}"
# Second argument is port
port="${2:-9082}"
# Third argument is new label
new_label="${3:-seed}"
# Identifiable portion of path to torrents, so it will only run on torrents.
# For example, a path of "/data/torrents/movies", "torrents" is a good choice.
torrent_path_portion="torrents"
# Check that the movie is a torrent.
if ! [[ "${radarr_moviefile_sourcepath}" =~ ${torrent_path_portion} ]]; then
echo "[Torrent Label] Path ${radarr_moviefile_sourcepath} does not contain \"torrent\", exiting."
exit
fi
if ! [[ -x $( command -v xmlrpc ) ]]; then
echo "[Torrent Label] No xmlrpc binary found."
exit
fi
if [[ -n ${radarr_download_id} ]]; then
if xmlrpc "${host}":"${port}" d.custom1.set "${radarr_download_id}" "${new_label}" > /dev/null 2>&1; then
echo "[Torrent Label] Label for torrent ${radarr_release_title} with hash ${radarr_download_id} changed to ${new_label}"
else
echo "[Torrent Label] Label for torrent ${radarr_release_title} with hash ${radarr_download_id} NOT CHANGED."
exit
fi
fi
@yjiawqgj
Copy link

yjiawqgj commented Apr 1, 2023

Master! I have a question to ask you, I wrote a script to use tinyMediaManager to grab movie data after radarr downloads and imports movies. The script content is:
!#/bin/bash
/volume1/tmm/tinyMediaManager -u -n
The script passed the radarr test, but the script was triggered by grabbing, downloading, and importing movies through radarr, but the tinyMediaManager has never been run. However, if the script is manually executed on the SSH terminal, tinyMediaManager can run normally to grab movie data. The official wiki of radarr mentions that there are environment variables, but it does not mention how to use them. Seeking help from radarr staff on Discord has not been resolved, saying that the script needs to be written by myself, I said I can't, they said let me search with google, but I have not found a way to write custom scripts about radarr.
I saw your script today, there are environment variables, but I don't know how to write them. Can you help me write a script like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment