*nohtml*

local/bin/torrents

   1 #!/bin/bash
   2 
   3 exec > >(column -ts \|)
   4 
   5 [[ $(pidof transmission transmission-gtk) ]] &&
   6 transmission-remote -l | sed '1d; $d; s/\s\+\s/|/g' |
   7 cut -d \| -f 3,9,10
   8 
   9 [[ $(pidof qbittorrent) ]] &&
  10 curl -s http://127.0.0.1:9092/api/v2/sync/maindata |
  11 jq -r '.torrents[] | [.priority, .progress, .state, .name] | @tsv' | sort -n |
  12 awk -F \\t '{ printf "%d%%|%s|%s\n", ($2 * 100), $3, $4 }'
  13 
  14 [[ $(pidof aria2c) ]] &&
  15 curl -s http://127.0.0.1:6800/jsonrpc -d '{ "jsonrpc": "2.0", "method": "aria2.tellActive",  "id": 0, "params": [] }' |
  16 jq -r '.result[] | [.totalLength, .completedLength, .status, .bittorrent.info.name] | @tsv' |
  17 awk -F \\t '{ sub(".*/", "", $4); printf "%d%%|%s|%s\n", ($2 / $1 * 100), $3, $4 }'