Skip to content

Instantly share code, notes, and snippets.

@jfeilbach
Last active May 28, 2025 15:07
Show Gist options
  • Save jfeilbach/26c5c2d7df004a2dec2b070ce7fec598 to your computer and use it in GitHub Desktop.
Save jfeilbach/26c5c2d7df004a2dec2b070ce7fec598 to your computer and use it in GitHub Desktop.
manipulate seed and move it
#!/bin/bash
# only works if last added torrent
# i could make this better but i don't care
unset GREP_COLOR
NC='\033[0m' # No color
green='\033[0;32m' # Green
white='\033[0;37m' # White
red='\033[0;31m' # Red
cyan='\e[0;36m' # Cyan
seconds=15
src="/dl_2/completed/"
dest="/mnt/plex/f1/Season 2025/"
ratio="0.01"
peers="512"
#args=(--archive --verbose --human-readable --progress --stats --protect-args)
args=(--archive --human-readable --protect-args)
id=$(transmission-remote localhost:9092 -l | tail -n 2 | head -n 1 | awk '{ print $1 }')
limit_before=$(transmission-remote localhost:9092 -t $id -i |grep 'Ratio Limit:')
peers_before=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'Peer limit:')
# set torrent ratio and peers
transmission-remote localhost:9092 -t $id --seedratio "${ratio}" 2>&1 1>/dev/null
transmission-remote localhost:9092 -t $id --peers "${peers}" 2>&1 1>/dev/null
limit=$(transmission-remote localhost:9092 -t $id -i |grep 'Ratio Limit:')
name=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'Name:')
name2=$(transmission-remote localhost:9092 -t ${id} -i |grep 'Name:' |awk '{ print $2}')
peers_after=$(transmission-remote localhost:9092 -t ${id} -i |grep 'Peer limit:')
echo -e "\n${white}${name}${NC} ID: ${white}${id}${NC}\n"
echo -e "${red}Before: ${limit_before}${NC}"
echo -e "${white}Now: ${limit}${NC}\n"
echo -e "${red}Before: ${peers_before}${NC}"
echo -e "${white}Now: ${peers_after}${NC}\n"
until transmission-remote localhost:9092 -t ${id} -i \
| grep 'State:' | awk '{ print $2}' \
| grep -m 1 "Finished"; do \
progress=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'Percent Done:')
eta=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'ETA:')
echo -e "${progress} ${eta}"
sleep 60
done
echo "Sleeping for 15 seconds because transmission sucks sometimes..."
start="$(($(date +%s) + $seconds))"
while [ "$start" -ge `date +%s` ]; do
time="$(( $start - `date +%s` ))"
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
done
echo "rsyncing ${name} to ${dest}"
#rsync -ahs "${src}${name2}" "${dest}"
rsync "${args[@]}" "${src}${name2}" "${dest}"
# extra protection from run away a seed
echo "Stopping torrent ${id} to prevent runaway seed."
transmission-remote localhost:9092 -t $id --stop
# stats
done=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'Percent Done:')
state=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'State:')
ratio=$(transmission-remote localhost:9092 -t ${id} -i |grep --color=always 'Ratio:')
echo -e "${done} ${state} ${ratio}\n"
#transmission-remote localhost:9092 -t ${id} -i |grep --color=always -e 'Percent Done:' -e 'State:' -e 'Ratio:' | tr -d \\n
#echo -e "\n"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment