From ce1d3a2b95343a83174b52951e4989f42613c9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iwan=20Cl=C3=A9ment?= Date: Sun, 30 Dec 2018 14:15:08 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20du=20fichier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/transmission-script.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Scripts/transmission-script.sh diff --git a/Scripts/transmission-script.sh b/Scripts/transmission-script.sh new file mode 100644 index 0000000..ec0d42d --- /dev/null +++ b/Scripts/transmission-script.sh @@ -0,0 +1,27 @@ +#!/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 \ No newline at end of file