Last active
January 6, 2022 11:29
-
-
Save fryfrog/2e33a0001b20f9989e3606c9721eb50c to your computer and use it in GitHub Desktop.
A Sonarr post processing script to change the rTorrent label after import (unnecessary in v3 due to Post-Import Category).
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 | |
# 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:-9081}" | |
# Third argument is new label | |
new_label="${3:-seed}" | |
# Identifiable portion of path to torrents, so it will only run on torrents. | |
# For example, with a path of "/data/torrents/movies", "torrents" is a good choice. | |
torrent_path_portion="torrents" | |
# Check that the movie is a torrent. | |
if ! [[ "${sonarr_episodefile_sourcepath}" =~ ${torrent_path_portion} ]]; then | |
echo "[Torrent Label] Path ${sonarr_episodefile_sourcepath} does not contain \"torrent\", exiting." | |
exit | |
fi | |
# Check for the xmlrpc command | |
if ! [[ -x $( command -v xmlrpc ) ]]; then | |
echo "[Torrent Label] No xmlrpc binary found." | |
exit | |
fi | |
if [[ -n ${sonarr_download_id} ]]; then | |
if xmlrpc "${host}":"${port}" d.custom1.set "${sonarr_download_id}" "${new_label}" > /dev/null 2>&1; then | |
echo "[Torrent Label] Label for torrent ${sonarr_release_title} with hash ${sonarr_download_id} changed to ${new_label}" | |
else | |
echo "[Torrent Label] Label for torrent ${sonarr_release_title} with hash ${sonarr_download_id} NOT CHANGED." | |
exit | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment