[download]

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' | cut -d \| -f 3,9,10
   7 
   8 [[ $(pidof qbittorrent) ]] &&
   9 curl -s http://127.0.0.1:9092/api/v2/sync/maindata |
  10 jq -r '.torrents[] | [.priority, .progress, .state, .name] | @tsv' |
  11 sort -n | awk -F \\t '{ printf "%d%%|%s|%s\n", ($2 * 100), $3, $4 }'
  12 
  13 [[ $(pidof aria2c) ]] &&
  14 curl -s http://127.0.0.1:6800/jsonrpc -d '{
  15     "jsonrpc": "2.0",
  16     "method": "aria2.tellActive",
  17     "id": 0, "params": []
  18 }' | jq -r '.result[] | [
  19     .totalLength, .completedLength, .status,
  20     .bittorrent.info.name, .files[0].path
  21 ] | @tsv' | awk -F \\t '{
  22     sub(".*/", "", $5);
  23     printf "%d%%|%s|%s\n", ($2 / $1 * 100), $3, ($4 ? $4 : $5)
  24 }'