Skip to content

Instantly share code, notes, and snippets.

@Erdack54
Last active January 24, 2023 15:13
Show Gist options
  • Save Erdack54/86d9a24731e77e6b9a233a80f60a4449 to your computer and use it in GitHub Desktop.
Save Erdack54/86d9a24731e77e6b9a233a80f60a4449 to your computer and use it in GitHub Desktop.
Script bash to pause qBittorrent-Nox torrent's through WebUI API, for exemple during night <|> Sorry about my English and probably "my" code if it's absolutely a piece of garbage, it's work for me so i think it can be usefull, feel free to comment ๐Ÿ™‚
#!/bin/bash
ScriptName='qbittorrent-nox-pause-torrents.sh'
ScriptVer='v1'
## by Erdack54 .fr /
## Usage&Crontab: sh /mnt/vdev0/dataset0/qbittorrent-nox-pause-torrents.sh > /mnt/vdev0/dataset0/qbittorrent-nox-pause-torrents.sh.log 2>&1
# -------------------------
# qBittorrent Credentials
USER="admin"
PASSWORD="adminadmin"
# qBittorrent WebUI API (4.1.x)
ENDPOINT="http://172.16.0.2:8080/api/v2"
# File to store the cookie
COOKIE_JAR="qbittorrent-nox-cookies.txt"
# -------------------------
# Check if cURL is installed
if curl --version 2>&1 | grep -w "libcurl" ; then
echo
else
echo "Humm, cURL is not installed."
exit 1
fi
# Login method
AUTH=$(curl -sS $ENDPOINT/auth/login --cookie-jar $COOKIE_JAR -d "username=$USER&password=$PASSWORD")
# Check if login work
if echo "$AUTH" 2>&1 | grep -w "Ok." ; then
echo
else
echo "Humm, something went wrong when authenticate."
exit 1
fi
# Pause
curl \
--show-error \
--request GET \
"$ENDPOINT/torrents/pause?hashes=all" \
--cookie $COOKIE_JAR \
--verbose
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment