Skip to content

Instantly share code, notes, and snippets.

@maesoser
Created March 8, 2024 09:16
Show Gist options
  • Save maesoser/a71e933094ca089bfe7032536bb2fcf4 to your computer and use it in GitHub Desktop.
Save maesoser/a71e933094ca089bfe7032536bb2fcf4 to your computer and use it in GitHub Desktop.
It resumes or pauses all downloads while using qbittorrent
#!/usr/bin/env bash
# 0 23 * * * qbitorrentctl start
# 0 8 * * * qbitorrentctl stop
url="http://127.0.0.1:8080"
passwd="password"
user="user"
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit
fi
SESSION=$(curl -i --data "username=${user}&password=${passwd}" ${url}/api/v2/auth/login 2>&1 | awk -F= '/^set-cookie:/ { print $2; exit }' | cut -d";" -f1)
if [ $1 = "start" ]; then
curl -vvv --data 'hashes=all' --silent --cookie "SID=${SESSION}" "${url}/api/v2/torrents/resume"
elif [ $1 = "stop" ]; then
curl -vvv --data "hashes=all" --silent --cookie "SID=${SESSION}" "${url}/api/v2/torrents/pause"
else
echo "Don't know what you are talking about"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment