wiki/External-programs:-savecategory.md
2020-06-20 14:08:27 -04:00

1.9 KiB
Raw Blame History

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 the popular wiki for setting up hard linking Docker and other torrent grabbers.

Installation

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 - \
    --request GET "$host/api/v2/auth/login?username=$username&password=$password")

echo "\tsetting $torrent_name to category $category"

echo "$cookie" | curl --silent --fail --show-error \
    --cookie - \
    --request GET "$host/api/v2/torrents/setCategory?hashes=$torrent_hash&category=$category"

echo "completed savecategory script"

exit 0

Make sure to replace the username and password 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.