Page 5 of 5

Re: Post your execute plugin scripts!

Posted: Sat Jul 31, 2021 2:20 pm
by mhertz
Here's a thread providing workarounds to achieve label support for execute plugin, through utilizing custom label download/move locations and checking upon that in script to verify if from label or not:

viewtopic.php?t=50141

If on deluge1, Ult.nrg has made an enhanced version of the regular execute plugin, with various nice additions, one of which being label support:

viewtopic.php?t=54216

Additionally Cas has a branch on his private github under his deluge repo, where he added support for adding arbitrary extra status fields in optional text file which then gets appended to output as extra vars to be utilized from your script - I never tried it myself, just noticed it while peeking at his content, there's two branches regarding this btw, though this is newest:

https://github.com/cas--/Deluge/tree/Fe ... tatus-Keys (py2/gtk2 version).

Re: Post your execute plugin scripts!

Posted: Thu Nov 04, 2021 12:05 pm
by merlincool
Post execute_plugin for 2.0.3 deluge is not showing RATIO info

my basic script.

Code: Select all

#!/bin/bash
torrentid=$1
torrentname=$2
torrentpath=$3

sleep 1000

INFO=$(deluge-console -p $daemonport info $torrentid)

echo $INFO >> test.log
This returns only DL, UL amount and ETA, doesn't have any info about ratio or announce url.

PS: It's for deluge 2.0.3
I wish to get RATIO number. If possible I would also like to get complete announce url.

Re: Post your execute plugin scripts!

Posted: Thu Nov 04, 2021 1:00 pm
by mhertz
To get same detailed output from 'info' command on deluge2 as was previously on deluge1, then add '-v' arg to 'info', and enclose in double-quotation marks(as you also reference variables additionally, and single quotes dont support shell expansion), so deluge-console don't think you're querying for version info, so "info -v $torrentid".

Re: Post your execute plugin scripts!

Posted: Fri Nov 05, 2021 2:22 am
by merlincool
Well that worked very well thanks

search for cross seedable torrent on completion

Posted: Fri Apr 29, 2022 9:13 pm
by Jerrk
using the excellent cross-seed app (recommended to run as a docker container)

this execute script will use cross-seed to search for similar/identical torrents on different indexers

you can also specify to only search for torrents that are downloaded to a specific directory, for example if you only want to cross seed your movies but leave your music alone.

Code: Select all

#!/bin/bash
torrentid=$1
torrentname=$2
torrentpath=$3

if [[ $torrentpath == "/torrent/download/directory" ]] ; then
    curl -XPOST http://192.168.1.100:2468/api/webhook \
		--data-urlencode "infoHash=$torrentid" \
		--data-urlencode "name=$torrentname" \
		--data-urlencode "outputDir=/path/you/want/the/.torrent/file/downloaded/seen/from/cross-seed"
elif  [[ $torrentpath == "/torrent/download/directory2" ]] ; then
    curl -XPOST http://cross-seed IP:2468/api/webhook \
		--data-urlencode "infoHash=$torrentid" \
		--data-urlencode "name=$torrentname" \
		--data-urlencode "outputDir=/path2/you/want/the/.torrent/file/downloaded/seen/from/cross-seed"
else
    :
fi
if you don't care about specific output directories you can make it much more simple like so:

Code: Select all

#!/bin/bash
torrentid=$1
torrentname=$2
curl -XPOST http://192.168.1.100:2468/api/webhook \
	--data-urlencode "infoHash=$torrentid" \
	--data-urlencode "name=$torrentname" \
	--data-urlencode "outputDir=/path/you/want/the/.torrent/file/downloaded/seen/from/cross-seed"
you don't need to use both name and infohash, you can just use one or the other if you want

Re: Post your execute plugin scripts!

Posted: Sat Apr 30, 2022 6:34 am
by rick moore
Looking for help for a few simple (I think) scripts, pm me please, can pay for your time but should take few seconds for anyone experienced, you guys would know best, don't really know where else to ask online. thx.

Re: Post your execute plugin scripts!

Posted: Wed Oct 05, 2022 2:00 am
by Embargo0238
Here's mine, which periodically updates the tracker if there's an error with the status (after adding)... the dreaded torrent unregistered error that some trackers have.
For deluge v2+

It will write the logs to the path that the script will be saved (/path/to/script/deluge-update-tracker.log).
/path/to/script/deluge-update-tracker.sh

Code: Select all

#!/bin/bash

torrentId=$1
torrentName=$2
torrentPath=$3

# configure daemon
daemonHost=localhost
daemonPort=
daemonUser=
daemonPass=

# absolute log file path (same dir as this script)
logFilePath="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/deluge-update-tracker.log"

echo "TORRENT NAME: \"$torrentName\", ID: \"$torrentId\"" >> $logFilePath

# check connection works
$(which deluge-console) "connect $daemonHost:$daemonPort $daemonUser $daemonPass" && {
    echo "CONNECTED TO: \"$(which deluge-console)\"" >> $logFilePath
} || {
    echo "COULD NOT CONNECT TO: \"$(which deluge-console)\"" >> $logFilePath
    exit 1
}

# wait for initial announce
echo "WAITING..." >> $logFilePath
sleep 5

i=0

while [ $i -le 10 ]; do
    echo "GETTING TRACKER STATUS..." >> $logFilePath
    trackerStatus=$($(which deluge-console) "connect $daemonHost:$daemonPort $daemonUser $daemonPass; info -v $torrentId" | grep "Tracker status")

    echo "TRACKER STATUS: \"$trackerStatus\"" >> $logFilePath
    case $trackerStatus in
        # case-sensitive
        *unregistered*|*unreachable*|*Sent*|*Error*|"Tracker status: ")
            echo "UPDATING TRACKER..." >> $logFilePath
            $(which deluge-console) "connect $daemonHost:$daemonPort $daemonUser $daemonPass; update_tracker '$torrentId'"
        ;;

        "")
            echo "INVALID TRACKER STATUS" >> $logFilePath
            echo "" >> $logFilePath
            exit 1
        ;;
        *)
            echo "OK TRACKER STATUS" >> $logFilePath
            echo "" >> $logFilePath
            exit 0
        ;;
    esac

    i=$(( $i + 1 ))

    echo "WAITING..." >> $logFilePath
    sleep 10
done

echo "UPDATE TRACKER DID NOT FINISH IN A TIMELY MANNER" >> $logFilePath
echo "" >> $logFilePath
Example logs

Code: Select all

TORRENT NAME: "The.Great.British.Bake.Off.S13E04.WEBRip.x264-ION10", ID: "9e9524ffcd756243d0e2fe3cf42db4ccf0b2d8f0"
CONNECTED TO: "/usr/bin/deluge-console"
WAITING...
GETTING TRACKER STATUS...
TRACKER STATUS: "Tracker status: Error: skipping tracker announce (unreachable)"
UPDATING TRACKER...
WAITING...
GETTING TRACKER STATUS...
TRACKER STATUS: "Tracker status: Error: skipping tracker announce (unreachable)"
UPDATING TRACKER...
WAITING...
GETTING TRACKER STATUS...
TRACKER STATUS: "Tracker status: Announce OK"
OK TRACKER STATUS


Re: Post your execute plugin scripts!

Posted: Sat Mar 16, 2024 11:39 pm
by CrispEventer
I switched to running my Deluge on windows and had to convert my "torrent ended" script from bash. I rewrote it in powershell only to discover powershell isn't one of the supported languages 🤦‍♂️ viewtopic.php?t=44171

So here it is in batch. I've learnt far too much about batch in the process, would not recommend 😅.

What it does is pretty simple - when a torrent is finished it copies the torrent folder/file to a DESTINATION_DIR. The reason it's a bit verbose is it turns out there's a more than one command for copying files in batch, and some are better for copying single files (copy) vs folders (robocopy)

It also writes to a LOG_FILE for the start of the copy, end of the copy, and if the copy fails. :updateTimestamp is a helper function for this because it turns out just getting a nice timestamp is a whole thing in batch too 💀 https://stackoverflow.com/a/23476347/13762264

Code: Select all

@echo off

set DESTINATION_DIR=C:\Users\hp\finished_torrents\
set LOG_FILE=C:/path/to/log/file/torrent_copy_bat.log
set ERROR_MESSAGE=Error! There was an error when performing the copy

set torrentid=%~1
set torrentname=%~2
set torrentpath=%~3

set srcPath=%torrentpath%\%torrentname%
set destPath=%DESTINATION_DIR%%torrentname%

set isDirectory=0
if exist %srcPath%\* (
	set isDirectory=1
)


call:updateTimestamp
echo %timestamp%, %torrentid%, %isDirectory%, %srcPath%, %destPath% >> %LOG_FILE%

if %isDirectory% == 0 (
	copy "%srcPath%" "%destPath%" || (
		call:updateTimestamp
		echo %timestamp%, %torrentid%, %ERROR_MESSAGE% >> %LOG_FILE
		exit	)
)
if %isDirectory% == 1 (
	robocopy "%srcPath%" "%destPath%" /s /e
	if %ERRORLEVEL% gtr 1 (
		call:updateTimestamp
		echo %timestamp%, %torrentid%, %ERROR_MESSAGE% >> %LOG_FILE%
		exit
	)
)

call:updateTimestamp
echo %timestamp%, %torrentid%, Copying completed :) >> %LOG_FILE%

:updateTimestamp
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set dt=%%a
set year=%dt:~0,4%
set month=%dt:~4,2%
set day=%dt:~6,2%
set hour=%dt:~8,2%
set min=%dt:~10,2%
set sec=%dt:~12,2%
set timestamp=%day%/%month%/%year% %hour%:%min%:%sec%
goto:eof