oops
This commit is contained in:
parent
dc9d014802
commit
3cc3092cb0
1 changed files with 52 additions and 37 deletions
|
@ -1,48 +1,63 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
while true ; do
|
while true; do
|
||||||
sleep ${INTERVAL:-25}
|
sleep ${INTERVAL:-25}
|
||||||
add_trackers () {
|
|
||||||
|
add_trackers() {
|
||||||
torrent_hash=$1
|
torrent_hash=$1
|
||||||
id=$2
|
id=$2
|
||||||
for base_url in "$TORRENTLIST" ; do
|
for base_url in "$TORRENTLIST"; do
|
||||||
if [ ! -f /tmp/trackers.txt ]; then
|
if [ ! -f /tmp/trackers.txt ]; then
|
||||||
curl -o "/tmp/trackers.txt" "${base_url}"
|
curl -o "/tmp/trackers.txt" "${base_url}"
|
||||||
fi
|
|
||||||
Local=$(wc -c < /tmp/trackers.txt)
|
if [ -f /opt/trackers.txt ]; then
|
||||||
Remote=$(curl -sI "${base_url}" | awk '/Content-Length/ {sub("\r",""); print $2}')
|
cat /opt/trackers.txt >>/tmp/trackers.txt
|
||||||
if [ $Local != $Remote ]; then
|
fi
|
||||||
curl -o "/tmp/trackers.txt" "${base_url}"
|
fi
|
||||||
fi
|
|
||||||
echo "URL for ${base_url}"
|
Local=$(wc -c </tmp/trackers.txt)
|
||||||
echo "Adding trackers for $torrent_name..."
|
Remote=$(curl -sI "${base_url}" | awk '/Content-Length/ {sub("\r",""); print $2}')
|
||||||
for tracker in $(cat /tmp/trackers.txt) ; do
|
|
||||||
echo -n "${tracker}..."
|
if [ $Local != $Remote ]; then
|
||||||
if transmission-remote "$HOSTPORT" --authenv --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
|
curl -o "/tmp/trackers.txt" "${base_url}"
|
||||||
echo ' failed.'
|
|
||||||
else
|
if [ -f /opt/trackers.txt ]; then
|
||||||
echo ' done.'
|
cat /opt/trackers.txt >>/tmp/trackers.txt
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
done
|
|
||||||
|
echo "URL for ${base_url}"
|
||||||
|
echo "Adding trackers for $torrent_name..."
|
||||||
|
|
||||||
|
for tracker in $(cat /tmp/trackers.txt); do
|
||||||
|
echo -n "${tracker}..."
|
||||||
|
if transmission-remote "$HOSTPORT" --authenv --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
|
||||||
|
echo ' failed.'
|
||||||
|
else
|
||||||
|
echo ' done.'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
sleep 3m
|
sleep 3m
|
||||||
rm -f /tmp/TTAA.$id.lock
|
rm -f /tmp/TTAA.$id.lock
|
||||||
}
|
}
|
||||||
# Get list of active torrents
|
|
||||||
ids="$(transmission-remote "$HOSTPORT" --authenv --list | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')"
|
# Get list of active torrents
|
||||||
for id in $ids ; do
|
ids="$(transmission-remote "$HOSTPORT" --authenv --list | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')"
|
||||||
add_date="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info| grep '^ Date added: ' |cut -c 21-)"
|
for id in $ids; do
|
||||||
|
add_date="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info | grep '^ Date added: ' | cut -c 21-)"
|
||||||
add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
|
add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
|
||||||
dater="$(date "+%Y-%m-%d %H:%M")"
|
dater="$(date "+%Y-%m-%d %H:%M")"
|
||||||
dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")"
|
dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")"
|
||||||
|
|
||||||
if [ ! -f /tmp/TTAA.$id.lock ]; then
|
if [ ! -f /tmp/TTAA.$id.lock ]; then
|
||||||
if [[ ( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" ) ]]; then
|
if [[ ("$add_date_t" == "$dater" || "$add_date_t" == "$dateo") ]]; then
|
||||||
hash="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
|
hash="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
|
||||||
torrent_name="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
|
torrent_name="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info | grep '^ Name: ' | cut -c 9-)"
|
||||||
add_trackers "$hash" "$id" &
|
add_trackers "$hash" "$id" &
|
||||||
touch /tmp/TTAA.$id.lock
|
touch /tmp/TTAA.$id.lock
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue