Last active
January 24, 2023 15:13
-
-
Save Erdack54/d33a945c3eea88a90f6aa27bcd67fd64 to your computer and use it in GitHub Desktop.
Script bash to unpause 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 π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ScriptName='qbittorrent-nox-unpause-torrents.sh' | |
ScriptVer='v1' | |
## by Erdack54 .fr / | |
## Usage&Crontab: sh /mnt/vdev0/dataset0/qbittorrent-nox-unpause-torrents.sh > /mnt/vdev0/dataset0/qbittorrent-nox-unpause-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 | |
# Set download speed to 0, just in case | |
curl \ | |
--show-error \ | |
--request GET \ | |
"$ENDPOINT/torrents/setDownloadLimit?limit=0&hashes=all" \ | |
--header 'Fiddler' \ | |
--header 'application/x-www-form-urlencoded' \ | |
--cookie $COOKIE_JAR \ | |
--verbose | |
# Unpause | |
curl \ | |
--show-error \ | |
--request GET \ | |
"$ENDPOINT/torrents/setForceStart?value=true&hashes=all" \ | |
--header 'Fiddler' \ | |
--header 'application/x-www-form-urlencoded' \ | |
--cookie $COOKIE_JAR \ | |
--verbose | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment