Set torrent uploaded sizes in torrent files


/ Published in: Bash
Save to your folder(s)

Used parts of this in resetting my torrent upload information after losing if (was experimenting with switching to a new torrent-client). Only works on transmission-gtk torrent files [i think]


Copy this code and paste it in your HTML
  1. rm -f $tname
  2. tname=`ls | grep torrent$ | head --lines=1`
  3. namehead=`grep -oa name[0-9]*: $tname`
  4. namesize=${namehead:4}
  5. namesize=${namesize%?}
  6. offset=`grep --byte-offset --only-matching --text name[0-9]*: $tname`
  7. cutsize=${#namehead}
  8. cutsize=`expr $cutsize + 1`
  9. cutsize=`expr -$cutsize`
  10. expression="\${offset:0:$cutsize}"
  11. eval "offset=$expression"
  12. offset=`expr $offset + ${#namehead}`
  13. limit=`expr $offset + $namesize`
  14. outputname=`head --bytes=$limit $tname | tail --bytes=$namesize`
  15. echo $outputname
  16.  
  17. uploadedsize=`du -b $outputname | awk '{ print $1 }'`
  18. downloadedsize=`expr $uploadedsize \+ 1000`
  19. uploadedsize=$downloadedsize
  20. uploadedsize=`expr 3 \* $uploadedsize`
  21. uploadedsize=`expr $uploadedsize / 2`
  22. echo $uploadedsize
  23. echo $tname
  24. echo $outputname
  25.  
  26. resumename="${tname:0:-8}.resume"
  27.  
  28. paddingstring="eeeeeeeeeeee"
  29. pad=`expr ${paddingstring:${#uploadedsize}}`
  30. echo $uploadedsize$pad
  31.  
  32.  
  33. mv $tname /home/xand/.config/transmission/torrents/
  34. cd /home/xand/.config/transmission/resume
  35. cp my.resume.template $resumename
  36. test="sed -i \"s/uploadedi1098378065ee/uploadedi$uploadedsize$pad/g\" $resumename"
  37. echo $tname $resumename $downloadedsize $uploadedsize $test
  38. sed -i "s/uploadedi1098378065ee/uploadedi$uploadedsize$pad/g" $resumename
  39.  
  40. cdb -g down

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.