Files
states/Scripts/transmission-script.sh
2018-12-30 14:15:08 +01:00

27 lines
939 B
Bash

#!/bin/bash
# script to check for completed torrents and stop and move them
BLOCKLIST="/var/lib/transmission/.config/transmission-daemon/blocklists/blocklist.bin"
# Update blocklist if older than 1 day
if [[ $(find "$BLOCKLIST" -mtime +0 -print) ]]; then
transmission-remote --blocklist-update
fi
TORRENTLIST=`transmission-remote --list | sed -e '1d;$d;s/^ *//' | cut -f1 -d' '`
for TORRENTID in $TORRENTLIST
do
TORRENTID=`echo "$TORRENTID" | sed 's:*::'`
INFO=`transmission-remote --torrent $TORRENTID --info`
NAME=`echo "$INFO" | grep "Name: *"`
DL_COMPLETED=`echo "$INFO" | grep "Percent Done: 100%"`
STATE_STOPPED=`echo "$INFO" | grep "State: Stopped\|Finished\|Idle"`
if [ "$DL_COMPLETED" != "" ] && [ "$STATE_STOPPED" != "" ]; then
echo "Removing torrent from list"
transmission-remote --torrent $TORRENTID --remove
fi
done