Skip to content

Instantly share code, notes, and snippets.

@kantjer01
Created July 29, 2023 13:14
Show Gist options
  • Save kantjer01/3802ae104692ff4691b57d861d85bb68 to your computer and use it in GitHub Desktop.
Save kantjer01/3802ae104692ff4691b57d861d85bb68 to your computer and use it in GitHub Desktop.
upgraderr-move-export.sh
#!/bin/bash
# This script moves torrents older than a set threshold to the export category.
# load variables
set -o allexport
source /volume1/scripts/upgraderr/upgraderr.env
set +o allexport
# set variables.
lts_treshold="$1" # argunent in minutes, from main script
log="$log_dir/move-export.$(date +"%Y-%m-%d_%H.%M").log"
# Move movies torrents above export treshold to export category
echo "Move movies torrents completed more than $lts_treshold minutes ago to the export category" | 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":"category",
"subject":"movies-lts",
"query":"DisableCrossseed() && Category startsWith 'movies' && Category not contains 'lts' && Now() - CompletionOn >= $lts_treshold*60 && CompletionOn > 0"}
CURL_DATA
# Move race-movies torrents above export treshold to export category
echo "Move race-movies torrents completed more than $lts_treshold minutes ago to the export category" | tee -a $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":"category",
"subject":"race-movies-lts",
"query":"DisableCrossseed() && Category startsWith 'race-movies' && Category not contains 'lts' && Now() - CompletionOn >= $lts_treshold*60 && CompletionOn > 0"}
CURL_DATA
# Move series torrents above export treshold to export category
echo "Move series torrents completed more than $lts_treshold minutes ago to the export category" | tee -a $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":"category",
"subject":"tv-lts",
"query":"DisableCrossseed() && Category startsWith 'tv' && Category not contains 'lts' && Now() - CompletionOn >= $lts_treshold*60 && CompletionOn > 0"}
CURL_DATA
# Move race-series torrents above export treshold to export category
echo "Move race-series torrents completed more than $lts_treshold minutes ago to the export category" | tee -a $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":"category",
"subject":"race-tv-lts",
"query":"DisableCrossseed() && Category startsWith 'race-tv' && Category not contains 'lts' && Now() - CompletionOn >= $lts_treshold*60 && CompletionOn > 0"}
CURL_DATA
# cleanup log files
if ls -t $log_dir/move-export.*.log &>/dev/null; then
ls -t $log_dir/move-export.*.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