Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only download list(s) of trackers ONCE per run
Uses a temporary file to store the list of trackers.
  • Loading branch information
dlenski committed Feb 17, 2021
commit 06d5cc4724fda789d1400aba260dee7d00014f6b
42 changes: 28 additions & 14 deletions manual-tracker-add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,40 @@ fi
host=${TRANSMISSION_HOST:-localhost}
list_url=${TRACKER_URL:-https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt}

# Download list(s) of trackers to temporary file
list_file=$(mktemp --tmpdir trackers.XXXXX.txt)
echo -e "\e[1m\e[5m"
echo "Downloading trackers into ${list_file}"
for base_url in ${list_url}; do
echo -e "\e[1m\e[5m"
echo "URL for ${base_url}"
echo -en "\e[0m"
if curl --location -# "${base_url}" >> "${list_file}"; then
echo -e '\e[92m done.'
echo -en "\e[0m"
else
echo -e '\e[91m failed.'
echo -en "\e[0m"
fi
done

add_trackers () {
torrent_hash=$1
for base_url in ${list_url}; do
echo -e "\e[1m\e[5m"
echo "URL for ${base_url}"
echo -e "Adding trackers for \e[91m$torrent_name..."
echo -en "\e[0m"
echo -e "\e[2m\e[92m"
for tracker in $(curl --location -# "${base_url}") ; do
echo -en "\e[0m"
echo -ne "\e[93m*\e[0m ${tracker}..."
if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
echo -e '\e[92m done.'
echo -en "\e[0m"
else
echo -e '\e[93m already added.'
echo -en "\e[0m"
fi
done
done
for tracker in $(cat "${list_file}"); do
echo -en "\e[0m"
echo -ne "\e[93m*\e[0m ${tracker}..."
if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
echo -e '\e[91m failed.'
echo -en "\e[0m"
else
echo -e '\e[92m done.'
echo -en "\e[0m"
fi
done
}

# Get list of active torrents
Expand Down