Automatically add trackers to torrents in transmission-remote
Thu 06 April 2023 — download

While the BitTorrent protocol is pretty neat to popular content, it's often suboptimal for things with only a handful of seeders, if only because the DHT isn't responsive enough. Fortunately, one can fall back to good old trackers, in which case, the more the merrier, since there is no way to know to which tracker a seeder is announcing to.

Hence why I wanted to have my transmission-remote automatically add a bunch of popular tracker every time I'm throwing a new torrent at it. A bunch of people are using completely over-engineered solutions, like docker containers, inotify-based rube-goldberg machines, … no need for complexity: slap the two following lines into your /var/lib/transmission/config/settings.json file:

"script-torrent-added-enabled": true,
"script-torrent-added-filename": "/opt/add_trackers.sh",

and put the following script in /opt/add_trackers.sh:

#!/bin/sh

TRANSMISSION_REMOTE='/usr/bin/transmission-remote'
AUTH='transmission:hunter2'
TRACKERLIST="/tmp/trackers.list"

trap "rm -f ./$TRACKERLIST" EXIT

wget https://newtrackon.com/api/stable -O "$TRACKERLIST"
wget https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt -O ->> "$TRACKERLIST"

sed -i '/^$/d' $TRACKERLIST
echo "[+] Got $(wc -l $TRACKERLIST) trackers"

# Add trackers to all torrents, just in case™
cat $TRACKERLIST | while read TRACKER; do $TRANSMISSION_REMOTE --auth=$AUTH -t all -td $TRACKER; done

Trackers lists are like religions: everyone has strong opinion on which is the best one and why all the others are dumb, but in the end it doesn't really matter, they're all more or less the same anyway.