Skip to content

Instantly share code, notes, and snippets.

@kantjer01
Last active August 5, 2023 14:48
Show Gist options
  • Save kantjer01/bbb59f3e6c58abc7c2671aa7047e982d to your computer and use it in GitHub Desktop.
Save kantjer01/bbb59f3e6c58abc7c2671aa7047e982d to your computer and use it in GitHub Desktop.
upgraderr-incomplete.sh
#!/bin/bash
# This script removes torrents with missing files or torrents without any progress.
# load variables
set -o allexport
source /volume1/scripts/upgraderr/upgraderr.env
set +o allexport
log="$log_dir/incomplete.$(date +"%Y-%m-%d_%H.%M").log"
# Remove incomplete torrents on seedbox
echo "Remove incomplete torrents on seedbox" | tee $log
curl -X POST -H "Content-Type: application/json" -d @- "$webhook_url" <<CURL_DATA | tee -a $log
{"host":"${host_remote}",
"user":"${user_remote}",
"password":"${password_remote}",
"action":"delete",
"query":"DisableCrossseed() && State(State) in ['error', 'missingFiles'] || DisableCrossseed() && State(State) == 'stalledDL' && (Progress < 10/100 && Now() - AddedOn > 1*60*60 || Now() - AddedOn > 7*24*60*60)"}
CURL_DATA
# Remove incomplete movies torrents on localhost
echo "Remove incomplete movies torrents on localhost" | tee -a $log
curl -X POST -H "Content-Type: application/json" -d @- "$webhook_url" <<CURL_DATA | tee -a $log
{"host":"${host_movies_local}",
"user":"${user_local}",
"password":"${password_local}",
"action":"delete",
"query":"DisableCrossseed() && Category contains 'movies-lts' && State(State) in ['error', 'missingFiles'] || DisableCrossseed() && State(State) in ['stalledDL', 'forcedDL', 'downloading'] && Progress == 0 && Now() - AddedOn > 1*60*60"}
CURL_DATA
# Remove incomplete series torrents on localhost
echo "Remove incomplete series torrents on localhost" | tee -a $log
curl -X POST -H "Content-Type: application/json" -d @- "$webhook_url" <<CURL_DATA | tee -a $log
{"host":"${host_series_local}",
"user":"${user_local}",
"password":"${password_local}",
"action":"delete",
"query":"DisableCrossseed() && Category contains 'tv-lts' && State(State) in ['error', 'missingFiles'] || DisableCrossseed() && State(State) in ['stalledDL', 'forcedDL', 'downloading'] && Progress == 0 && Now() - AddedOn > 1*60*60"}
CURL_DATA
# cleanup log files
if ls -t $log_dir/incomplete.*.log &>/dev/null; then
ls -t $log_dir/incomplete.*.log | tail -n +4 | xargs rm -f --
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment