Skip to content

Commit 6984552

Browse files
Improved
improve waiting time and clear comments
1 parent d62e646 commit 6984552

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

tracker-add-auto.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
auth=user:password
44
while true
55
do
6-
sleep 1
6+
sleep 5
77
add_trackers () {
88
torrent_hash=$1
99
id=$2
@@ -14,14 +14,13 @@ for tracker in $(curl -# "${base_url}") ; do
1414
echo "${tracker}..."
1515
if transmission-remote --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
1616
echo -e 'failed.'
17-
1817
else
1918
echo -e 'done.'
2019
fi
21-
done
2220
done
23-
sleep 5m
24-
rm /tmp/TTAA.$id
21+
done
22+
sleep 3m
23+
rm /tmp/TTAA.$id.lock
2524
}
2625
# Get list of active torrents
2726
ids="$(transmission-remote --auth="$auth" --list | grep -E 'Downloading' | grep '^ ' | awk '{ print $1 }')"
@@ -31,13 +30,12 @@ add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
3130
dater="$(date "+%Y-%m-%d %H:%M")"
3231
dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")"
3332

34-
if [ ! -f /tmp/TTAA.$id ]; then
35-
#if [[ $add_date_t == $dater ]]; then
33+
if [ ! -f /tmp/TTAA.$id.lock ]; then
3634
if [[ ( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" ) ]]; then
3735
hash="$(transmission-remote --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
3836
torrent_name="$(transmission-remote --auth="$auth" --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
3937
add_trackers "$hash" "$id" &
40-
touch /tmp/TTAA.$id
38+
touch /tmp/TTAA.$id.lock
4139
fi
4240
fi
4341
done

0 commit comments

Comments
 (0)