Hey there! 👋
I made this little script because I was tired of manually organizing my downloads in Transmission. Transmission can only watch ONE directory and dumps everything in the same place. Its web interface also doesn't help. You have to go through a bunch of manual steps and writting in order to add a remote magnet link.
I have this home server running Ubuntu with Transmission in Docker, and I wanted something simple:
- Drop torrent files in different folders through my SAMBA share
- Have them automatically download to different places
- Get them properly labeled/categorized
- And just... work.
I couldn't find anything that did exactly this (though I'm sure there are better solutions out there), so I decided to code this up. It's not fancy, but it gets the job done!
- A Linux box (I use Ubuntu)
inotify-tools
package- Transmission (either in Docker or native)
- First, grab the required package:
sudo apt-get update
sudo apt-get install inotify-tools
- Get the code:
git clone https://github.com/gcjbr/transmission-watch-router
cd transmission-watch-router
- Make it executable:
chmod +x torrent_watcher.sh
- Customize it! Open
torrent_watcher.sh
and edit these bits:
# Set up your folders and labels
declare -A CATEGORY_MAP=(
["linux-isos"]="#OpenSource"
["open-podcasts"]="#Podcasts"
["educational"]="#Education"
["public-archives"]="#Archives"
)
# Where's your stuff?
HOST_WATCH_DIR="/path/to/watch"
CONTAINER_WATCH_DIR="/watch" # For Docker folks
CONTAINER_DOWNLOADS_DIR="/downloads" # For Docker folks
# Your Transmission details
TRANSMISSION_CONTAINER="transmission" # Docker container name (if using Docker)
TRANSMISSION_USER="transmission"
TRANSMISSION_PASS="your_password"
Want it to run automatically? Here's how:
- Create a service file:
sudo nano /etc/systemd/system/torrent-watcher.service
- Paste this in (change the username and paths!):
[Unit]
Description=Transmission Watch Directory Router
After=network.target transmission-daemon.service docker.service
[Service]
Type=simple
User=your_username
ExecStart=/path/to/torrent_watcher.sh
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
- Start it up:
sudo systemctl daemon-reload
sudo systemctl enable torrent-watcher
sudo systemctl start torrent-watcher
- Make sure it's happy:
sudo systemctl status torrent-watcher
- Set up your watch folders:
mkdir -p /path/to/watch/{linux-isos,open-podcasts,educational,public-archives}
- Then just drop your
.torrent
files in the right folder:
- Linux ISOs go in →
/path/to/watch/linux-isos/
- Podcasts go in →
/path/to/watch/open-podcasts/
- You get the idea!
The script handles the rest - it'll see the new file, add it to Transmission, and put everything in its right place.
Make sure your Transmission container can see the right folders:
volumes:
- /path/to/watch:/watch
- /path/to/downloads:/downloads
- Only works on Linux (needs inotify)
- Make sure your folders have the right permissions
- This was made to work with Transmission in Docker, but it should work with native Transmission too. Just edit the script accordingly.
Do whatever you want with it!
Made with ☕ and a desperate need for organization