Skip to content

Instantly share code, notes, and snippets.

@neuthral
Created November 26, 2022 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neuthral/07e9dd23970efb154c362ca202ea4104 to your computer and use it in GitHub Desktop.
Save neuthral/07e9dd23970efb154c362ca202ea4104 to your computer and use it in GitHub Desktop.
add list of trackers to transmission downloads
#!/bin/bash
# Get transmission credentials, if set
if [[ -n "$TRANSMISSION_USER" && -n "$TRANSMISSION_PASS" ]]; then
auth="${TRANSMISSION_USER:-user}:${TRANSMISSION_PASS:-password}"
else
auth=
fi
#https://gist.github.com/neuthral/3690548c19a7740a9620794bc4537568/raw/62791f6884897420c96c86c121529f1ef1671b84/alive_trackers_26_11_2022.txt
#https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt
host=${TRANSMISSION_HOST:-localhost:65535}
list_url=${TRACKER_URL:-"file://$(pwd)/trackers_26_11_2022_alive.txt"}
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" --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
sleep 0.1
done
done
}
# Get list of active torrents
ids=${1:-"$(transmission-remote "$host" --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"}
for id in $ids ; do
hash="$(transmission-remote "$host" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
torrent_name="$(transmission-remote "$host" --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
add_trackers "$hash"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment