- Copy and modify the script as needed - check the comments for the first few lines
- Place the script where Deluge can access it
- Make it executable (
chmod +x /path/to/retry-stalled-autodl-torrents.sh
) - Enable the Execute plugin in deluge
- Create a new executable entry with the event being
Torrent Added
and the command being./path/to/retry-stalled-autodl-torrents.sh
- Notice the
./
at the beginning
- Notice the
- If you want, you can test it manually with
./path/to/retry-stalled-autodl-torrents.sh abc123
(replacingabc123
with the actual torrent hash)
Created
February 26, 2024 01:40
-
-
Save kieraneglin/944572302e8be1a38507d9e86583ab7c to your computer and use it in GitHub Desktop.
Retry stalled fresh torrents from Autobrr/autodl-irssi in Deluge 2.x
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/bash | |
daemon_port=58846 | |
# The Daemon username and password may not be the same as the web UI. | |
# Google "deluge daemon username password" for more info. | |
username=deluge | |
password=deluge | |
# If you want to only retry stalled torrents that were | |
# added by autobrr/autodl-irssi/etc, set `auto_dl_only` to 1 | |
# and set `auto_dl_label` to whatever you've set up for your auto-downloader. | |
auto_dl_only=0 | |
auto_dl_label="autobrr" | |
# Set to 1 if you need to troubleshoot | |
debug=0 | |
torrentid=$1 | |
# These two aren't used but are here for reference | |
torrentname=$2 | |
torrentpath=$3 | |
# Sleep to ensure the torrent has enough time to attempt start | |
# Can possibly be removed or lowered (esp. if you have a delay configured elsewhere), | |
# but this produced the best results. | |
sleep 5 | |
x=1 | |
while [ $x -le 20 ]; do | |
echo "Checking tracker status for $torrentid" | |
torrent_info=$(deluge-console "connect 127.0.0.1:$daemon_port $username $password; info -v '$torrentid'") | |
tracker_status=$(echo "$torrent_info" | grep "Tracker status") | |
label=$(echo "$torrent_info" | grep "Label") | |
if [[ $debug -eq 1 ]]; then | |
echo "-----------" | |
echo "Torrent info: $torrent_info" | |
echo "-----------" | |
echo "Tracker status: $tracker_status" | |
echo "Label: $label" | |
echo "-----------" | |
fi | |
if [[ $auto_dl_only -eq 1 ]]; then | |
if [[ ! $label == *"$auto_dl_label"* ]]; then | |
echo "Label does not contain '$auto_dl_label'. Taking no action." | |
break | |
else | |
echo "Label contains '$auto_dl_label'. Continuing." | |
fi | |
fi | |
case "$tracker_status" in | |
*error* | *Error* | *Sent* | *End*of*file* | *Bad*Gateway*) | |
echo "Tracker status error, pausing and resuming torrent. Attempt: $x" | |
deluge-console "connect 127.0.0.1:$daemon_port $username $password; pause '$torrentid'" | |
sleep 5 | |
deluge-console "connect 127.0.0.1:$daemon_port $username $password; resume '$torrentid'" | |
;; | |
*) | |
echo "Tracker status is good. Exiting" | |
printf -- "-----------\n\n\n" | |
break | |
;; | |
esac | |
x=$(($x + 1)) | |
sleep 2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment