This script add Categories to Automatically add torrents from per Monitored Folder
👉 This script is in flux, as it may be implemented into qBittorrent in the future.
savecategory
expects the user's watch directories to look similar to something like this:
It's based off Docker guide for setting up hard links between virtual volumes (Docker) and machine volumes.
Save the script below as savecategory
and make it executable via chmod 755 /path/to/savecategory
.
#!/bin/sh
category="$(basename $1)"
torrent_hash="$2"
torrent_name="$3"
host="http://localhost:8112"
username="admin"
password="adminadmin"
echo "running savecategory script"
echo "\tgetting cookie"
cookie=$(curl --silent --fail --show-error \
--header "Referer: $host" \
--cookie-jar - \
--data "username=$username&password=$password" \
--request POST "$host/api/v2/auth/login")
if [ -z "$cookie" ]; then
echo "Login failed, exiting script."
exit 1
fi
echo "\tsetting $torrent_name to category $category"
echo "$cookie" | curl --silent --fail --show-error \
--cookie - \
--header "Content-Type: application/x-www-form-urlencoded" \
--data "hashes=$torrent_hash&category=$category" \
--request POST "$host/api/v2/torrents/setCategory"
echo "completed savecategory script"
exit 0
ℹ️ Make sure to replace the
username
andpassword
with your credentials before using or else this will not work. Another caveat is that if your password contains#
or&
, you'll need to replace with ASCII encoded characters.🔗 gist for potential script changes or comments.
And set Run external program on torrent completion to:
/path/to/savecategory "%D" "%I" "%N"
On completion, the category will change based on the directory name the .torrent
file was placed in the watch directory.
Hi, as it stands the script no longer works perhaps due to changes in the qBittorrrent API but here are the updates required as of December 13th 2023.
https://gist.github.com/kevingatera/1f2860ecf68782ab413468d6e961f8da/revisions#diff-ddc2c72e571aef7c0ac8419e261d52f0f17d515df62f9b06d3cbb9cd0e1ba231