Title: Automatically add trackers to torrents in transmission-remote
Date: 2023-04-06 01:00

While the [BitTorrent](https://en.wikipedia.org/wiki/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](https://en.wikipedia.org/wiki/Mainline_DHT)
isn't responsive enough. Fortunately, one can fall back to good old
[trackers](https://en.wikipedia.org/wiki/BitTorrent_tracker), 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](https://transmissionbt.com/) 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:

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

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

```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.
