1

I download torrents that are updated periodically. When the torrent is updated / when a new version of the torrent is released, it uses the exact same name as the previous versions of the torrent, contains all the same files as the previous version(s) of the torrent and I download the torrent to the same directory as the previous versions of the torrent.

The first version of the torrent might contain files called-

  • 01.2020.S15.The.Hollis.Hurlbut.Show.Trouble.With.Deluge.1080P.mkv
  • 02.2020.S15.The.Hollis.Hurlbut.Show.Head.Meet.Brick.Wall.1080P.mkv
  • 03.2020.S15.The.Hollis.Hurlbut.Show.Plugin.Problems.1080P.mkv

When a new version of the torrent is released, it contains-

  • 01.2020.S15.The.Hollis.Hurlbut.Show.Trouble.With.Deluge.1080P.mkv
  • 02.2020.S15.The.Hollis.Hurlbut.Show.Head.Meet.Brick.Wall.1080P.mkv
  • 03.2020.S15.The.Hollis.Hurlbut.Show.Plugin.Problems.1080P.mkv
  • 04.2020.S15.The.Hollis.Hurlbut.Show.Is.It.Lunch.Time.Yet.1080P.mkv
  • 05.2020.S15.The.Hollis.Hurlbut.Show.I.Want.A.Beer.Now.1080P.mkv

When new versions of the torrent are added for download, it re-downloads the existing files (which is undesirable as I use a CoW filesystem, and it wastes bandwidth) but if I manually force a recheck of the newly added torrent, Deluge detects the existing files and when the new download resumes (See EDIT), it only downloads the data that is new or missing.

Is there any way I can get Deluge to recheck certain torrents either match a certain naming scheme or have a specific LabelPlus label, when a new torrent is added? Or is a bash script an option / better solution?

[EDIT]I've just been playing around with adding and rechecking torrents and I've found out that when I manually add a torrent to the specific path of the existing download, it automatically rechecks... the problem is that with my setup, the torrents in question are added automatically via the YaRSS2 plugin and then they are labelled, moved and have their download directory set by the LabelPlus plugin, which enables me to set per-event labels and download directories (/genre/year/event/name_of_event).

So what's causing me issues with my current setup is that when a new torrent is added by YaRRS2, it is added to the default download directory. Then when the torrent is moved by LaabelPlus, a recheck is not triggered. To make matters worse, because a recheck is not performed, the new version of the torrent starts overwriting existing files, meaning that a manual recheck will fail.

1 Answers1

0

I've answered my own question using three elements. Deluge's built-in "Execute" plugin, I installed the "deluge-console" package to enable me to issue commands to Deluge via the shell / console, and the last piece of the puzzle was a script I've written.

Deluge is set globally to add torrents in an un-paused state but I've set the YaRSS2 feed to add the torrents in question in a paused state. So YaRSS2 adds the torrent in a paused state, and then the LabelPlus plugin labels it and sets the torrent's download directory. Meanwhile the script triggered by the Execute plugin is runnning.


    #!/bin/bash

    #variables
    torrentid=$1
    torrentname=$2
    torrentpath=$3
    DATE=$(date +"%Y%m%d_%H%M%S")
        
    if [[ $torrentpath == /media/downloads/foo* ]] ; then 
    
         sleep 5 #sleep so that LabelPlus can do it's stuff
         deluge-console "recheck [ * |  $torrentid [$torrentid ...] ]"
         echo  "$DATE Rechecked: " "$torrentname " "$torrentid " "$torrentpath"  >> /home/deluge/media/execute_script.log
         deluge-console "resume [ * |  $torrentid [$torrentid ...] ]"
    
    else
    
         sleep 5 #sleep so that LabelPlus can do it's stuff
         echo  "$DATE Unchecked: " "$torrentname " "$torrentid " "$torrentpath"  >> /home/deluge/media/execute_script.log
         deluge-console "resume [ * |  $torrentid [$torrentid ...] ]"
    
    fi

Just a few notes...

When you enable the Execute plugin, you must restart the Deluge daemon!

The sleep 5 command is there just to avoid any issues with the script running before or whilst LabelPlus is changing the download directory to where the pre-existing data is.

If you use the above script, make sure the user that runs deluged has the required permissions to execute the script and to write to the log (if so desired).

[EDIT] I've added the ability for the script to either recheck or skip rechecking a torrent depending on it's path.