Last active
June 12, 2024 05:35
-
-
Save hvmonteiro/78364bb520d6d0b0da1279b110dc181b to your computer and use it in GitHub Desktop.
Script that allows the auto removal of downloaded/completed torrents from transmission BitTorrent daemon in OpenELEC/Kodi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Originaly based on script https://community.wd.com/t/guide-auto-removal-of-downloads-from-transmission-2-82/93156 | |
# adapted for OpenELEC Kodi | |
# port, username, password | |
SERVER="9091 --auth transmission:transmission" | |
# use transmission-remote to get torrent list from transmission-remote list | |
# use sed to delete first / last line of output, and remove leading spaces | |
# use cut to get first field from each line | |
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut -s -d" " -f 1` | |
echo "$TERM" | grep -q "term" | |
if [ $? -eq 0 ]; then | |
transmission-remote $SERVER --list | |
fi | |
# for each torrent in the list | |
for TORRENTID in $TORRENTLIST | |
do | |
echo Processing : $TORRENTID | |
# check if torrent download is completed | |
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "100%"` | |
# check torrents current state is | |
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"` | |
echo "$TERM" | grep -q "term" && echo $STATE_STOPPED | |
# if the torrent is "Stopped", "Finished", or "Idle after downloading 100%" | |
if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then | |
# move the files and remove the torrent from Transmission | |
echo "$TERM" | grep -q "term" && echo "Torrent #$TORRENTID is completed" | |
echo "$TERM" | grep -q "term" && echo "Removing torrent from list" | |
transmission-remote $SERVER --torrent $TORRENTID --remove | |
else | |
echo "$TERM" | grep -q "term" && echo "Torrent #$TORRENTID is not completed. Ignoring." | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stop transmission daemon
systemctl stop service.downloadmanager.transmission.service
Search for and edit TransmissionBT settings file
vi settings.json
change these 2 lines
where “script-torrent-done-filename” matches the path to the above script (ex: /storage/.bin/transmission-purge-completed.sh)
systemctl start service.downloadmanager.transmission.service