Skip to content

Instantly share code, notes, and snippets.

@flying-sausages
Last active May 3, 2020 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flying-sausages/19e8e798c1257b5341c03b5770dd2a80 to your computer and use it in GitHub Desktop.
Save flying-sausages/19e8e798c1257b5341c03b5770dd2a80 to your computer and use it in GitHub Desktop.
Transmission post-download script: Sort Torrents in folders by tracker
#! /bin/bash
#Requires transmission-remote in $PATH.
#Make sure you are allowing the RPC and are not being limited by the whitelist
#First see how can you log in to transmission and then adjust these values
#Try running `transmission-remote` first and see what happens
TR_USERNAME="username"
TR_PASSWORD="password"
# might be able to leave empty, test it out. I'm running mine through an nginx reverse proxy.
TR_HOST="https://localhost/transmission/rpc"
TRACKER=$(transmission-remote $TR_HOST -n "$TR_USERNAME":"$TR_PASSWORD" -t$TR_TORRENT_ID -it | sed -n -e '/[:]/p' | head -1 | awk '{print substr($0, index($0,$3))}' | awk -F[/:] '{print $4}')
dir="${TR_TORRENT_DIR}/${TRACKER}"
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
transmission-remote $TR_HOST -n "$TR_USERNAME":"$TR_PASSWORD" -t$TR_TORRENT_ID --move "$dir"
@flying-sausages
Copy link
Author

flying-sausages commented May 3, 2020

This script will create folders in your default torrent directory based off what the domain of the first tracker is.
For example, if you download The ubuntu 20.04 server torrent, it will make a folder called torrent.ubuntu.com and move the torrent data there.

You can read more about Transmission scripting here https://github.com/transmission/transmission/wiki/Scripts

Originally adapted from the script in this thread https://forum.transmissionbt.com/viewtopic.php?t=12544

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