Skip to content

Commit 6681fb2

Browse files
Create tracker-add-auto.sh
Automatically checks new torrents and adds trackers
1 parent dc04002 commit 6681fb2

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tracker-add-auto.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash -xv
2+
# Get transmission credentials
3+
auth=user:password
4+
while true
5+
do
6+
sleep 1
7+
add_trackers () {
8+
torrent_hash=$1
9+
id=$2
10+
for base_url in https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt https://hastebin.com/raw/bererufibu ; do
11+
echo -e "\e[1m\e[5m"
12+
echo "URL for ${base_url}"
13+
echo -e "Adding trackers for \e[91m$torrent_name..."
14+
echo -en "\e[0m"
15+
echo -e "\e[2m\e[92m"
16+
for tracker in $(curl -# "${base_url}") ; do
17+
echo -en "\e[0m"
18+
echo -ne "\e[93m*\e[0m ${tracker}..."
19+
if transmission-remote --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
20+
echo -e '\e[91m failed.'
21+
echo -en "\e[0m"
22+
else
23+
echo -e '\e[92m done.'
24+
echo -en "\e[0m"
25+
fi
26+
done
27+
done
28+
sleep 5m
29+
rm /tmp/TTAA.$id
30+
}
31+
# Get list of active torrents
32+
ids="$(transmission-remote --auth="$auth" --list | grep -E 'Downloading' | grep '^ ' | awk '{ print $1 }')"
33+
for id in $ids ; do
34+
add_date="$(transmission-remote --auth="$auth" --torrent "$id" --info| grep '^ Date added: ' |cut -c 21-)"
35+
add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
36+
dater="$(date "+%Y-%m-%d %H:%M")"
37+
dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")"
38+
39+
if [ ! -f /tmp/TTAA.$id ]; then
40+
#if [[ $add_date_t == $dater ]]; then
41+
if [[ ( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" ) ]]; then
42+
hash="$(transmission-remote --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
43+
torrent_name="$(transmission-remote --auth="$auth" --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
44+
add_trackers "$hash" "$id" &
45+
touch /tmp/TTAA.$id
46+
fi
47+
fi
48+
done
49+
done

0 commit comments

Comments
 (0)