Skip to content

Commit 39d8fc1

Browse files
committed
Format document
1 parent 52d4ea4 commit 39d8fc1

File tree

2 files changed

+66
-66
lines changed

2 files changed

+66
-66
lines changed

manual-tracker-add.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@ fi
88
host=${TRANSMISSION_HOST:-localhost}
99
list_url=${TRACKER_URL:-https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt}
1010

11-
add_trackers () {
11+
add_trackers() {
1212
torrent_hash=$1
13-
for base_url in "${list_url}" ; do
14-
echo -e "\e[1m\e[5m"
15-
echo "URL for ${base_url}"
16-
echo -e "Adding trackers for \e[91m$torrent_name..."
17-
echo -en "\e[0m"
18-
echo -e "\e[2m\e[92m"
19-
for tracker in $(curl --location -# "${base_url}") ; do
20-
echo -en "\e[0m"
21-
echo -ne "\e[93m*\e[0m ${tracker}..."
22-
if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
23-
echo -e '\e[92m done.'
24-
echo -en "\e[0m"
25-
else
26-
echo -e '\e[93m already added.'
27-
echo -en "\e[0m"
28-
fi
29-
done
30-
done
13+
for base_url in "${list_url}"; do
14+
echo -e "\e[1m\e[5m"
15+
echo "URL for ${base_url}"
16+
echo -e "Adding trackers for \e[91m$torrent_name..."
17+
echo -en "\e[0m"
18+
echo -e "\e[2m\e[92m"
19+
for tracker in $(curl --location -# "${base_url}"); do
20+
echo -en "\e[0m"
21+
echo -ne "\e[93m*\e[0m ${tracker}..."
22+
if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
23+
echo -e '\e[92m done.'
24+
echo -en "\e[0m"
25+
else
26+
echo -e '\e[93m already added.'
27+
echo -en "\e[0m"
28+
fi
29+
done
30+
done
3131
}
3232

3333
# Get list of active torrents
3434
ids=${1:-"$(transmission-remote "$host" ${auth:+--auth="$auth"} --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"}
3535

36-
for id in $ids ; do
37-
hash="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
38-
torrent_name="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
36+
for id in $ids; do
37+
hash="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
38+
torrent_name="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Name: ' | cut -c 9-)"
3939
add_trackers "$hash"
4040
done

tracker-add-auto-router.sh

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,50 @@
33
auth=user:password
44
host=localhost
55

6-
while true ; do
7-
sleep 25
8-
add_trackers () {
9-
torrent_hash=$1
10-
id=$2
11-
trackerslist=/tmp/trackers.txt
12-
for base_url in https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt ; do
13-
if [ ! -f $trackerslist ]; then
14-
curl -o "$trackerslist" "${base_url}"
15-
fi
16-
Local=$(wc -c < $trackerslist)
17-
Remote=$(curl -sI "${base_url}" | awk '/Content-Length/ {sub("\r",""); print $2}')
18-
if [ "$Local" != "$Remote" ]; then
19-
curl -o "$trackerslist" "${base_url}"
20-
fi
21-
echo "URL for ${base_url}"
22-
echo "Adding trackers for $torrent_name..."
23-
for tracker in $(cat $trackerslist) ; do
24-
echo "${tracker}..."
25-
if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
26-
echo ' failed.'
27-
else
28-
echo ' done.'
29-
fi
30-
done
31-
done
32-
sleep 3m
33-
rm -f "/tmp/TTAA.$id.lock"
34-
}
35-
# Get list of active torrents
6+
while true; do
7+
sleep 25
8+
add_trackers() {
9+
torrent_hash=$1
10+
id=$2
11+
trackerslist=/tmp/trackers.txt
12+
for base_url in https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt; do
13+
if [ ! -f $trackerslist ]; then
14+
curl -o "$trackerslist" "${base_url}"
15+
fi
16+
Local=$(wc -c <$trackerslist)
17+
Remote=$(curl -sI "${base_url}" | awk '/Content-Length/ {sub("\r",""); print $2}')
18+
if [ "$Local" != "$Remote" ]; then
19+
curl -o "$trackerslist" "${base_url}"
20+
fi
21+
echo "URL for ${base_url}"
22+
echo "Adding trackers for $torrent_name..."
23+
for tracker in $(cat $trackerslist); do
24+
echo "${tracker}..."
25+
if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
26+
echo ' failed.'
27+
else
28+
echo ' done.'
29+
fi
30+
done
31+
done
32+
sleep 3m
33+
rm -f "/tmp/TTAA.$id.lock"
34+
}
35+
# Get list of active torrents
3636
ids="$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')"
37-
for id in $ids ; do
38-
add_date="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info| grep '^ Date added: ' |cut -c 21-)"
39-
add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
40-
dater="$(date "+%Y-%m-%d %H:%M")"
41-
dateo="$(date -D '%s' -d "$(( `date +%s`+1*60 ))" "+%Y-%m-%d %H:%M")"
37+
for id in $ids; do
38+
add_date="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Date added: ' | cut -c 21-)"
39+
add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
40+
dater="$(date "+%Y-%m-%d %H:%M")"
41+
dateo="$(date -D '%s' -d "$(($(date +%s) + 1 * 60))" "+%Y-%m-%d %H:%M")"
4242

43-
if [ ! -f "/tmp/TTAA.$id.lock" ]; then
44-
if [[ "( "$(add_date_t)" == "$(dater)" || "$(add_date_t)" == "$(dateo)" )" ]]; then
45-
hash="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
46-
torrent_name="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
47-
add_trackers "$hash" "$id" &
48-
touch "/tmp/TTAA.$id.lock"
49-
fi
50-
fi
51-
done
43+
if [ ! -f "/tmp/TTAA.$id.lock" ]; then
44+
if [[ "( "$(add_date_t)" == "$(dater)" || "$(add_date_t)" == "$(dateo)" )" ]]; then
45+
hash="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
46+
torrent_name="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Name: ' | cut -c 9-)"
47+
add_trackers "$hash" "$id" &
48+
touch "/tmp/TTAA.$id.lock"
49+
fi
50+
fi
51+
done
5252
done

0 commit comments

Comments
 (0)