qBitTorrent keeps forgetting global download/upload statistics but remembers it on individual torrents. This script uses flood's API (Because I couldn't figure out qBit's API) to calculate those values.
Last active
October 9, 2022 16:19
-
-
Save sussycatgirl/d66a3f937c3630b0d5aae36cb3b08d20 to your computer and use it in GitHub Desktop.
Calculate total torrent down/upload from flood API
This file contains 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 | |
# Username and password can't contain " because I can't be assed to escape those | |
USERNAME=jan | |
FLOOD_URL="https://flood.domain.tld" | |
printf "Password: " | |
read -s PASSWORD | |
echo | |
AUTH_COOKIE=$(curl -so /dev/null "${FLOOD_URL}/api/auth/authenticate" -d "{\"password\":\"$PASSWORD\",\"username\":\"$USERNAME\"}" -H "Content-Type: application/json" --dump-header - | grep -Fi Set-Cookie | sed 's/Set-Cookie: //' | tr -d "[:space:]") | |
DATA=$(curl -s -H "Cookie: $AUTH_COOKIE" "${FLOOD_URL}/api/torrents") | |
UP_TOTAL=$(echo "$DATA" | jq '.torrents[].upTotal' | paste -sd+ | bc | numfmt --to iec --format "%8.4f") | |
DOWN_TOTAL=$(echo "$DATA" | jq '.torrents[].downTotal' | paste -sd+ | bc | numfmt --to iec --format "%8.4f") | |
echo "Total uploaded: $UP_TOTAL" | |
echo "Total downloaded: $DOWN_TOTAL" | |
# Revoke token | |
curl -s "${FLOOD_URL}/api/auth/logout" -H "Cookie: $AUTH_COOKIE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment