Delete all foder content of torrent

Suggest, post, or discuss plugins for Deluge
Post Reply
themsk
New User
New User
Posts: 2
Joined: Thu May 07, 2020 8:03 pm

Delete all foder content of torrent

Post by themsk »

This can be useful to some guys that like things to be automated, on a seed box on linux or distributions of it
As we know, deluge cant delete folders that have files added by other way than thru download by torrent. Like subtitles, you downloaded a show and then added in that folder the subtitles founded on other site. Deluge will delete only the files from torrent and the folder will remain with the files you added.
So, lets use the plugin Execute, this plugin let us use a command when something happen to a torrent, eg, added, completed, removed.
We will use when torrent removed (the remove can be made manual or by another plugin like AutoRemovePlus)
The files:
file 1:
remove.sh

Code: Select all

#!/bin/bash
torrentid="$1"
torrentname="$2"
echo $(/home/pi/scripts/copytoplex/remove.py $torrentid $torrentname) > /dev/null
please change the path for remove.py with your file location
and file 2:
remove.py

Code: Select all

#!/usr/bin/python

import sys, os, fnmatch, re, shutil, logging
import stat

logger = logging.getLogger('copytoplex')
hdlr = logging.FileHandler('/home/pi/scripts/copytoplex/remove.log')
formatter = logging.Formatter('%(asctime)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)

torrentid = sys.argv[1]
torrentname = sys.argv[2]

def rem_files(torrentname, torrentpath):
    shutil.rmtree("/mnt/hdd/downloading/" +torrentname)
    logger.info(torrentname) 

rem_files(torrentname, '/mnt/hdd/downloading')
exit()

as you can see in the script, my downloaded files are in /mnt/hdd/downloading , so, change this with your folder of downloaded files and also, change the path of this files in the script.

In plugin Execute, select when torrent removed and put the path to the remove.sh file, mine is /home/pi/scripts/copytoplex/remove.sh

Notice that you have to restart deluge daemon otherwise the execute plugin will not call the remove.sh script.
A remove.log file will be created containing the torrent name that have been removed.
Now, with the AutoRemovePlus, Execute plugins and this simple script, you can forgot about your torrents..

Also, see this tool to copy your cleaned content to Plex library :
viewtopic.php?f=9&t=55680
Post Reply