Created
August 10, 2017 22:04
-
-
Save LogIN-/643727d768b31a6e18ecc8a29b1e30f4 to your computer and use it in GitHub Desktop.
Transmission CLI add trackers in BULK
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 | |
# I was looking for a way to add/modify all trackers in all torrents in my remote transmission instance. | |
# So I had bunch of old torrents like 500 of them with mostly broken outdated trackers. | |
# This is a small helper script that will loop over all your torrents and add trackers that finds on torrentz domain. | |
# I came out on this: https://github.com/Entware-ng/Entware-ng/wiki/Using-Transmission#adding-more-trackers little script and modify it a bit. | |
# Please modify this script that it suits your environment. | |
base_url='https://torrentz2.is' | |
pattern='announcelist_[0-9]+' | |
TRANSMISSION_GET_REMOTE_TORRENT_IDS='/usr/bin/transmission-remote REPLACE_WITH_YOUR_TRANSMISSION_URL --netrc /home/REPLACE_WITH_YOUR_HOME/.netrc --ssl -l' | |
$TRANSMISSION_GET_REMOTE_TORRENT_IDS | while read REMOTE_IDS_LINE | |
do | |
TORRENT_ID=$(echo $REMOTE_IDS_LINE | awk '{print $1}') | |
TORRENT_ID=$(echo $TORRENT_ID | sed 's/[^0-9]*//g') | |
if [ -n "$TORRENT_ID" ]; then | |
TORRENT_ID=$(($TORRENT_ID + 0)) | |
TRANSMISSION_GET_REMOTE_TORRENT_HASH="$(/usr/bin/transmission-remote REPLACE_WITH_YOUR_TRANSMISSION_URL --netrc /home/REPLACE_WITH_YOUR_HOME/.netrc --ssl -t $TORRENT_ID -i)" | |
TR_TORRENT_HASH=$(echo $TRANSMISSION_GET_REMOTE_TORRENT_HASH | grep -o -P '(?<=Hash:).*(?=Magnet:)' | grep '[[:xdigit:]]\{32\}') | |
TR_TORRENT_HASH="$(echo -e "${TR_TORRENT_HASH}" | tr -d '[:space:]')" | |
PERCENT_DONE=$(echo $TRANSMISSION_GET_REMOTE_TORRENT_HASH | grep -o -P '(?<=Percent Done: ).*(?= ETA)') | |
PERCENT_DONE=${PERCENT_DONE%\%} | |
if (( $(echo "$PERCENT_DONE < 100" |bc -l) )); then | |
announce_list=`wget --no-check-certificate -qO - ${base_url}/$TR_TORRENT_HASH | grep -Eo "${pattern}"` | |
if [ -z "$announce_list" ] ; then | |
echo "No additional trackers found for $TORRENT_ID $TR_TORRENT_HASH $announce_list" | |
else | |
for tracker in $(wget -qO - ${base_url}/${announce_list}) ; do | |
echo "Adding ${tracker} to $TORRENT_ID $TR_TORRENT_HASH" | |
/usr/bin/transmission-remote REPLACE_WITH_YOUR_TRANSMISSION_URL --netrc /home/REPLACE_WITH_YOUR_HOME/.netrc --ssl -t $TR_TORRENT_HASH -td ${tracker} | |
done | |
fi | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. But there is actually an easier way although it was tough the information was hard to find :
But first you need the CLI version of Transmission. If you are on Ubuntu, you get it with
sudo apt-get transmission-cli
There's actually an example in the man page on how to replace your passkey/passcode in the torrents tracker urls:
transmission-edit -r old-passcode new-passcode ~/.config/transmission/torrents/*\.torrent