I've just spent a few days ironing out a simple script that creates a hardlink of all files in a completed torrent - something that is vital if you are using post-processing applications like couch-potato or sickbeard.
Here's the code - its basic enough that it could be used for a wide range of scenarios and can be triggered to perform different actions based on different trackers.
My current configuration required me to continue seeding the original torrent file, but I also wanted to post-process the file using sickrage and move the processed files into the correctly managed file structures for plex without taking up extra storage space.
Code: Select all
#!/bin/bash
LOGFILE="/path/to/logs/transmission-completed-$TR_TORRENT_NAME.log"
auth=un:pwd
completeddir="/path/to/completed/folder/"
if transmission-remote -n $auth -t "$TR_TORRENT_HASH" -it | grep -q "tracker.url";
then
echo transmission-torrent-complete.sh running on `date` > "$LOGFILE"
echo Directory is "$TR_TORRENT_DIR" >> "$LOGFILE"
echo Torrent Name is "$TR_TORRENT_NAME" >> "$LOGFILE"
echo Torrent ID is "$TR_TORRENT_ID" >> "$LOGFILE"
echo Torrent Hash is "$TR_TORRENT_HASH" >> "$LOGFILE"
cd $TR_TORRENT_DIR
while read line;
do
array[ $i ]="$line"
(( i++ ))
done < <( transmission-remote -n $auth -t $TR_TORRENT_HASH -f | tail -n +3 | cut -c 35-)
count=${#array[@]}
for (( i=0; i<${count}; i++ ));
do
ln "${array[$i]}" $completeddir
echo Torrent "${array[$i]}" successfully moved to $completeddir >> "$LOGFILE"
done
fi